xttmp 2.3.0.7__tar.gz → 2.3.0.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. {xttmp-2.3.0.7/src/xttmp.egg-info → xttmp-2.3.0.9}/PKG-INFO +1 -1
  2. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/pyproject.toml +1 -1
  3. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/core/math_operator.py +10 -15
  4. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/core/stmdplus_core.py +11 -8
  5. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/core/vstmd_core.py +5 -0
  6. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/model/feedback_model.py +7 -11
  7. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/util/iostream.py +2 -0
  8. {xttmp-2.3.0.7 → xttmp-2.3.0.9/src/xttmp.egg-info}/PKG-INFO +1 -1
  9. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/LICENSE +0 -0
  10. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/README.md +0 -0
  11. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/setup.cfg +0 -0
  12. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/__init__.py +0 -0
  13. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/api/__init__.py +0 -0
  14. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/api/evaluate.py +0 -0
  15. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/api/get_visualize_handle.py +0 -0
  16. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/api/instancing_model.py +0 -0
  17. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/core/__init__.py +0 -0
  18. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/core/apgstmd_core.py +0 -0
  19. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/core/apgstmdv2_core.py +0 -0
  20. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/core/base_core.py +0 -0
  21. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/core/dstmd_core.py +0 -0
  22. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/core/estmd_backbone.py +0 -0
  23. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/core/estmd_core.py +0 -0
  24. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/core/feedbackstmd_core.py +0 -0
  25. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/core/fracstmd_core.py +0 -0
  26. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/core/fstmd_core.py +0 -0
  27. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/core/fstmdv2_core.py +0 -0
  28. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/core/haarstmd_core.py +0 -0
  29. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/core/stfeedbackstmd_core.py +0 -0
  30. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/core/stmdplusv2_core.py +0 -0
  31. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/demo/evaluate_model.py +0 -0
  32. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/demo/inference_gui.py +0 -0
  33. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/demo/inference_gui_single_process.py +0 -0
  34. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/demo/inference_image_stream.py +0 -0
  35. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/demo/inference_video.py +0 -0
  36. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/main.py +0 -0
  37. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/model/__init__.py +0 -0
  38. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/model/backbone.py +0 -0
  39. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/model/facilitated_model.py +0 -0
  40. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/model/haarstmd.py +0 -0
  41. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/model/vstmd.py +0 -0
  42. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/util/__init__.py +0 -0
  43. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/util/compute_module.py +0 -0
  44. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/util/create_kernel.py +0 -0
  45. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/util/evaluate_module.py +0 -0
  46. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp/util/stmd.ico +0 -0
  47. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp.egg-info/SOURCES.txt +0 -0
  48. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp.egg-info/dependency_links.txt +0 -0
  49. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp.egg-info/entry_points.txt +0 -0
  50. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp.egg-info/requires.txt +0 -0
  51. {xttmp-2.3.0.7 → xttmp-2.3.0.9}/src/xttmp.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xttmp
3
- Version: 2.3.0.7
3
+ Version: 2.3.0.9
4
4
  Summary: eXtremely Tiny Target - Motion Perception
5
5
  Author-email: Shawn MX <mingshuoxu@hotmail.com>
6
6
  Project-URL: Homepage, https://github.com/MingshuoXu/Small-Target-Motion-Detectors
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "xttmp"
7
- version = "2.3.0.7"
7
+ version = "2.3.0.9"
8
8
  description = "eXtremely Tiny Target - Motion Perception"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -114,31 +114,30 @@ class GammaDelay(BaseCore):
114
114
  Implements a gamma filter used in the lamina layer of the ESTMD neural network
115
115
  using pure PyTorch and collections.deque for efficient temporal sliding windows.
116
116
  """
117
- def __init__(self, order=1, tau=1.0, kernel_len=None):
117
+ def __init__(self, order=1, tau=1.0):
118
118
  """
119
119
  Constructor method.
120
120
 
121
121
  Parameters:
122
122
  order (int): Order of the gamma filter (n). Default is 1.
123
123
  tau (float): Time constant of the filter (\tau).
124
- kernel_len (int): Length of the filter kernel (T).
125
124
  """
126
125
  super().__init__()
127
126
  self.order = max(1, int(order))
128
127
  self.tau = tau
129
- # 如果未指定长度,默认使用 3 * tau (覆盖大部分有效权重)
130
- self.kernel_len = int(3 * tau) if kernel_len is None else kernel_len
128
+
131
129
 
132
130
  self.setup()
133
131
 
134
132
  def setup(self):
133
+ _kernel_len = int(3 * self.tau)
135
134
  # 1. 预计算 Gamma 滤波器的时域权重
136
- kernel = create_gamma_kernel(self.order, self.tau, self.kernel_len)
135
+ kernel = create_gamma_kernel(self.order, self.tau, _kernel_len)
137
136
  # 注册为 buffer,随模型自动转移设备 (如 .cuda())
138
137
  self.register_buffer('gamma_kernel', kernel)
139
138
 
140
139
  # 2. 初始化双端队列作为时序状态缓存区
141
- self.buffer = deque(maxlen=self.kernel_len)
140
+ self.buffer = deque(maxlen=_kernel_len)
142
141
 
143
142
  def reset_buffer(self):
144
143
  """
@@ -179,15 +178,13 @@ class GammaBandPassFilter(BaseCore):
179
178
 
180
179
  def __init__(self,
181
180
  order1=2, tau1=3.0,
182
- order2=6, tau2=9.0,
183
- kernel_len=None):
181
+ order2=6, tau2=9.0):
184
182
  """
185
183
  Constructor method.
186
184
 
187
185
  Parameters:
188
186
  - order1, tau1: Parameters for the excitatory (positive) Gamma filter.
189
187
  - order2, tau2: Parameters for the inhibitory (negative) Gamma filter.
190
- - kernel_len: Temporal length of the filter. If None, auto-calculated.
191
188
  """
192
189
  super().__init__()
193
190
 
@@ -196,17 +193,15 @@ class GammaBandPassFilter(BaseCore):
196
193
  self.order2 = max(1, int(order2))
197
194
  self.tau2 = tau2
198
195
 
199
- # 自动计算所需的历史帧缓存最大长度
200
- self.kernel_len = kernel_len if kernel_len is not None else max(int(3 * tau1), int(3 * tau2))
201
-
202
196
  self.in_loop = False # 默认不覆盖历史帧,直接追加
203
197
 
204
198
  self.setup()
205
199
 
206
200
  def setup(self):
201
+ _kernel_len = max(int(3 * self.tau1), int(3 * self.tau2))
207
202
  # 1. 预计算两个 Gamma 滤波器的权重,并补齐到相同的长度 self.T
208
- k1 = create_gamma_kernel(self.order1, self.tau1, self.kernel_len)
209
- k2 = create_gamma_kernel(self.order2, self.tau2, self.kernel_len)
203
+ k1 = create_gamma_kernel(self.order1, self.tau1, _kernel_len)
204
+ k2 = create_gamma_kernel(self.order2, self.tau2, _kernel_len)
210
205
 
211
206
  # 2. 算子融合 (Operator Fusion):W_bandpass = W1 - W2
212
207
  # 直接将差值注册为模型的 buffer,前向传播只需计算一次
@@ -214,7 +209,7 @@ class GammaBandPassFilter(BaseCore):
214
209
  self.register_buffer('bandpass_kernel', bandpass_kernel)
215
210
 
216
211
  # 3. 初始化单一的高效时序状态缓存区
217
- self.buffer = deque(maxlen=self.kernel_len)
212
+ self.buffer = deque(maxlen=_kernel_len)
218
213
 
219
214
  def reset_buffer(self):
220
215
  """
@@ -21,6 +21,8 @@ class ContrastPathway(BaseCore):
21
21
 
22
22
  self.register_buffer('T1_kernel', torch.empty(0))
23
23
 
24
+ self.setup()
25
+
24
26
  def setup(self):
25
27
  """Initialization method."""
26
28
  # 假设 create_T1_kernels 返回的是 4 个 kernel 的 List 或 NumPy array
@@ -34,9 +36,9 @@ class ContrastPathway(BaseCore):
34
36
  """
35
37
 
36
38
  # out 的形状是 (1, 4, H, W)
37
- self.Opt = F.conv2d(x, self.T1_kernel, padding='same')
39
+ self.output = F.conv2d(x, self.T1_kernel, padding='same')
38
40
 
39
- return self.Opt
41
+ return self.output
40
42
 
41
43
 
42
44
  class MushroomBody(BaseCore):
@@ -59,6 +61,8 @@ class MushroomBody(BaseCore):
59
61
  self.trackLens = None # 张量: [N] (记录当前轨迹有效长度)
60
62
  self.trackPtr = None # 张量: [N] (记录环形缓冲区的写入指针)
61
63
 
64
+ self.setup()
65
+
62
66
  def setup(self):
63
67
  self.torch_nms = AreaNMS(self.nms_size)
64
68
 
@@ -69,18 +73,18 @@ class MushroomBody(BaseCore):
69
73
  nmsLobulaOpt = self.torch_nms(maxLobulaOpt)
70
74
 
71
75
  mask_not_nms = (nmsLobulaOpt == 0)
72
- mushroomBodyOpt = lobulaOpt * mask_not_nms
76
+ self.output = lobulaOpt * mask_not_nms
73
77
 
74
78
  maxNumber = torch.max(nmsLobulaOpt)
75
79
  if maxNumber <= 0:
76
80
  self.trackID = None
77
- return mushroomBodyOpt
81
+ return self.output
78
82
 
79
83
  # --- 获取新检测点 ---
80
84
  newID = torch.nonzero(nmsLobulaOpt > 0).float()
81
85
  if len(newID) == 0:
82
86
  self.trackID = None
83
- return mushroomBodyOpt
87
+ return self.output
84
88
 
85
89
  curr_y, curr_x = newID[:, -2].long(), newID[:, -1].long()
86
90
  # all_new_contrasts 形状 [C, M], M是新目标数
@@ -180,8 +184,7 @@ class MushroomBody(BaseCore):
180
184
  e_y = erase_coords[:, -2].long()
181
185
  e_x = erase_coords[:, -1].long()
182
186
  # 终极一键批量擦除
183
- mushroomBodyOpt[..., e_y, e_x] = 0
187
+ self.output[..., e_y, e_x] = 0
184
188
 
185
- self.Opt = mushroomBodyOpt
186
- return mushroomBodyOpt
189
+ return self.output
187
190
 
@@ -73,6 +73,11 @@ class Medulla(BaseCore):
73
73
  self.on_pathway.setup()
74
74
  self.off_pathway.setup()
75
75
 
76
+ def reset_buffer(self):
77
+ # Reset buffers for both pathways
78
+ self.on_pathway.reset_buffer()
79
+ self.off_pathway.reset_buffer()
80
+
76
81
  def forward(self, lamina_ON, lamina_OFF):
77
82
  """
78
83
  Process the input through the Medulla layer.
@@ -41,8 +41,8 @@ class FeedbackSTMD(ESTMDBackbone):
41
41
  # lamina
42
42
  'n1' : 'lamina.order1', # Eq. (3)
43
43
  'tau1' : 'lamina.tau1',
44
- 'n2' : 'lamina.order1',
45
- 'tau2' : 'lamina.tau1',
44
+ 'n2' : 'lamina.order2',
45
+ 'tau2' : 'lamina.tau2',
46
46
  # medulla
47
47
  'n3' : ('medulla.tm1.order', 'medulla.mi1.order'), # Eq. (7)
48
48
  'tau3' : ('medulla.tm1.tau', 'medulla.mi1.tau'),
@@ -70,15 +70,11 @@ class FeedbackSTMD(ESTMDBackbone):
70
70
  # Customize Lobula component
71
71
  self.lobula = feedbackstmd_core.Lobula()
72
72
 
73
- # Customize Lamina's GammaBankPassFilter properties
74
- self.lamina.order1 = 4
75
- self.lamina.tau1 = 8
76
- self.lamina.order2 = 16
77
- self.lamina.tau2 = 32
78
-
79
- # Customize Medulla's Tm1 component properties
80
- self.medulla.tm1.order = 9
81
- self.medulla.tm1.tau = 45
73
+ self.set_para(n1=4, tau1=8,
74
+ n2=16, tau2=32,
75
+ n3=9, tau3=45)
76
+
77
+ self.setup()
82
78
 
83
79
  def forward(self, x):
84
80
  """ MODEL_STRUCTURE Method
@@ -282,6 +282,8 @@ class FrameVisualizer:
282
282
  cv2.putText(frame, str(show_str),
283
283
  (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 0.8,
284
284
  (0, 255, 0), 2, cv2.LINE_AA)
285
+
286
+ self.showed_frame = frame # 保存当前帧,便于后续处理或保存
285
287
 
286
288
  # --- 视频保存 (安全检查) ---
287
289
  if self.save_output and self.video_writer is not None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xttmp
3
- Version: 2.3.0.7
3
+ Version: 2.3.0.9
4
4
  Summary: eXtremely Tiny Target - Motion Perception
5
5
  Author-email: Shawn MX <mingshuoxu@hotmail.com>
6
6
  Project-URL: Homepage, https://github.com/MingshuoXu/Small-Target-Motion-Detectors
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes