dgenerate-ultralytics-headless 8.3.239__py3-none-any.whl → 8.3.240__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dgenerate-ultralytics-headless
3
- Version: 8.3.239
3
+ Version: 8.3.240
4
4
  Summary: Automatically built Ultralytics package with python-opencv-headless dependency instead of python-opencv
5
5
  Author-email: Glenn Jocher <glenn.jocher@ultralytics.com>, Jing Qiu <jing.qiu@ultralytics.com>
6
6
  Maintainer-email: Ultralytics <hello@ultralytics.com>
@@ -57,6 +57,7 @@ Provides-Extra: export
57
57
  Requires-Dist: numpy<2.0.0; extra == "export"
58
58
  Requires-Dist: onnx>=1.12.0; platform_system != "Darwin" and extra == "export"
59
59
  Requires-Dist: onnx<1.18.0,>=1.12.0; platform_system == "Darwin" and extra == "export"
60
+ Requires-Dist: onnxslim>=0.1.80; extra == "export"
60
61
  Requires-Dist: coremltools>=9.0; (platform_system != "Windows" and python_version <= "3.13") and extra == "export"
61
62
  Requires-Dist: scikit-learn>=1.3.2; (platform_system != "Windows" and python_version <= "3.13") and extra == "export"
62
63
  Requires-Dist: openvino>=2024.0.0; extra == "export"
@@ -1,4 +1,4 @@
1
- dgenerate_ultralytics_headless-8.3.239.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
1
+ dgenerate_ultralytics_headless-8.3.240.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
2
2
  tests/__init__.py,sha256=bCox_hLdGRFYGLb2kd722VdNP2zEXNYNuLLYtqZSrbw,804
3
3
  tests/conftest.py,sha256=mOy9lGpNp7lk1hHl6_pVE0f9cU-72gnkoSm4TO-CNZU,2318
4
4
  tests/test_cli.py,sha256=GhIFHi-_WIJpDgoGNRi0DnjbfwP1wHbklBMnkCM-P_4,5464
@@ -8,7 +8,7 @@ tests/test_exports.py,sha256=8dxll33sqhlHeWplly5xxSdT-Nqw2cRRZWN3jZeRWWc,14155
8
8
  tests/test_integrations.py,sha256=6QgSh9n0J04RdUYz08VeVOnKmf4S5MDEQ0chzS7jo_c,6220
9
9
  tests/test_python.py,sha256=viMvRajIbDZdm64hRRg9i8qZ1sU9frwB69e56mxwEXk,29266
10
10
  tests/test_solutions.py,sha256=CIaphpmOXgz9AE9xcm1RWODKrwGfZLCc84IggGXArNM,14122
11
- ultralytics/__init__.py,sha256=Kkc0zFGRthNdbe2UViHpuowgEH5NVweklAPQWaMxVHg,1302
11
+ ultralytics/__init__.py,sha256=O1bEyzXhjMQlfHguL1N3w9J7Xh5FIOC83E2vphoVoJw,1302
12
12
  ultralytics/py.typed,sha256=la67KBlbjXN-_-DfGNcdOcjYumVpKG_Tkw-8n5dnGB4,8
13
13
  ultralytics/assets/bus.jpg,sha256=wCAZxJecGR63Od3ZRERe9Aja1Weayrb9Ug751DS_vGM,137419
14
14
  ultralytics/assets/zidane.jpg,sha256=Ftc4aeMmen1O0A3o6GCDO9FlfBslLpTAw0gnetx7bts,50427
@@ -155,7 +155,7 @@ ultralytics/models/sam/amg.py,sha256=aYvJ7jQMkTR3X9KV7SHi3qP3yNchQggWNUurTRZwxQg
155
155
  ultralytics/models/sam/build.py,sha256=rEaFXA4R1nyutSonIenRKcuNtO1FgEojnkcayo0FTP4,12867
156
156
  ultralytics/models/sam/build_sam3.py,sha256=Gg_LiqNrCDTYaDWrob05vj-ln2AhkfMa5KkKhyk5wdE,11976
157
157
  ultralytics/models/sam/model.py,sha256=cOawDSkFqJPbt3455aTZ8tjaoWshFWFHQGGqxzsL_QQ,7372
158
- ultralytics/models/sam/predict.py,sha256=g-p88aNSeWql6bsjRb5FmjOXHGKvG0aJ9aIIlub7juU,203078
158
+ ultralytics/models/sam/predict.py,sha256=rvUXBzNMvKlfjWP6UoKNm9GGpLcxJGsZGTkFq-7UOhI,203675
159
159
  ultralytics/models/sam/modules/__init__.py,sha256=lm6MckFYCPTbqIoX7w0s_daxdjNeBeKW6DXppv1-QUM,70
160
160
  ultralytics/models/sam/modules/blocks.py,sha256=ZU2aY4h6fmosj5pZ5EOEuO1O8Cl8UYeH11eOxkqCt8M,44570
161
161
  ultralytics/models/sam/modules/decoders.py,sha256=G4li37ahUe5rTTNTKibWMsAoz6G3R18rI8OPvfunVX8,25045
@@ -164,7 +164,7 @@ ultralytics/models/sam/modules/memory_attention.py,sha256=jFVWVbgDS7VXPqOL1e3gAz
164
164
  ultralytics/models/sam/modules/sam.py,sha256=-KV-1PZK39DTdSpR5DI3E8I6gGVLja3tMv1MH7Au_eA,61654
165
165
  ultralytics/models/sam/modules/tiny_encoder.py,sha256=RJQTHjfUe2N3cm1EZHXObJlKqVn10EnYJFla1mnWU_8,42065
166
166
  ultralytics/models/sam/modules/transformer.py,sha256=NmTuyxS9PNsg66tKY9_Q2af4I09VW5s8IbfswyTT3ao,14892
167
- ultralytics/models/sam/modules/utils.py,sha256=ztihxg0ssx0W-CKiqV-8KzB4og39TKnbmV3YO96ENPw,20770
167
+ ultralytics/models/sam/modules/utils.py,sha256=Re09hcKe9LJpFzKHxpbwEmoMpPImnJaoNw7pe62_ui0,21129
168
168
  ultralytics/models/sam/sam3/__init__.py,sha256=aM4-KimnYgIFe-e5ctLT8e6k9PagvuvKFaHaagDZM7E,144
169
169
  ultralytics/models/sam/sam3/decoder.py,sha256=kXgPOjOh63ttJPFwMF90arK9AKZwPmhxOiexnPijiTE,22872
170
170
  ultralytics/models/sam/sam3/encoder.py,sha256=zP934Q_7B2I9UJvQY4Ghimu7Y8dQjBCGqUmSv5zbsq0,21794
@@ -269,7 +269,7 @@ ultralytics/utils/metrics.py,sha256=pP1LoKweL3Iga5dvCBVoqMSi5TwaaHERKKugDUloUs8,
269
269
  ultralytics/utils/nms.py,sha256=zv1rOzMF6WU8Kdk41VzNf1H1EMt_vZHcbDFbg3mnN2o,14248
270
270
  ultralytics/utils/ops.py,sha256=Se_Vb_smotVZ4g9gW4x56LpflAmbNDCEaeQz5BmUiD0,25637
271
271
  ultralytics/utils/patches.py,sha256=mD3slAMAhcezzP42_fOWmacNMU6zXB68Br4_EBCyIjs,7117
272
- ultralytics/utils/plotting.py,sha256=ivlhx4PZP80O-E8r4ruwxLYQEc6BLq5fmveKHgSi-EA,48219
272
+ ultralytics/utils/plotting.py,sha256=bDOi3hmFaiJBuQyI3Ew-arliDNStuRIP7oM_Gq8C7Ac,48219
273
273
  ultralytics/utils/tal.py,sha256=w7oi6fp0NmL6hHh-yvCCX1cBuuB4JuX7w1wiR4_SMZs,20678
274
274
  ultralytics/utils/torch_utils.py,sha256=zOPUQlorTiEPSkqlSEPyaQhpmzmgOIKF7f3xJb0UjdQ,40268
275
275
  ultralytics/utils/tqdm.py,sha256=5PtGvRE9Xq8qugWqBSvZefAoFOnv3S0snETo5Z_ohNE,16185
@@ -291,8 +291,8 @@ ultralytics/utils/export/__init__.py,sha256=Cfh-PwVfTF_lwPp-Ss4wiX4z8Sm1XRPklsqd
291
291
  ultralytics/utils/export/engine.py,sha256=23-lC6dNsmz5vprSJzaN7UGNXrFlVedNcqhlOH_IXes,9956
292
292
  ultralytics/utils/export/imx.py,sha256=UHIq_PObOphIxctgSi0-5WaHvolHsHd3r5TTSjQSdgo,12860
293
293
  ultralytics/utils/export/tensorflow.py,sha256=igYzwbdblb9YgfV4Jgl5lMvynuVRcF51dAzI7j-BBI0,9966
294
- dgenerate_ultralytics_headless-8.3.239.dist-info/METADATA,sha256=PgCv3h3IXNlDfEVMUUSY2zWtTEV0HThO2cyZfavlRak,38747
295
- dgenerate_ultralytics_headless-8.3.239.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
296
- dgenerate_ultralytics_headless-8.3.239.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
297
- dgenerate_ultralytics_headless-8.3.239.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
298
- dgenerate_ultralytics_headless-8.3.239.dist-info/RECORD,,
294
+ dgenerate_ultralytics_headless-8.3.240.dist-info/METADATA,sha256=PT70UGSI51ivueJSk6BunjPAeZNEjMe9pr2HIf3JKKU,38798
295
+ dgenerate_ultralytics_headless-8.3.240.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
296
+ dgenerate_ultralytics_headless-8.3.240.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
297
+ dgenerate_ultralytics_headless-8.3.240.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
298
+ dgenerate_ultralytics_headless-8.3.240.dist-info/RECORD,,
ultralytics/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
2
 
3
- __version__ = "8.3.239"
3
+ __version__ = "8.3.240"
4
4
 
5
5
  import importlib
6
6
  import os
@@ -210,9 +210,14 @@ def apply_rotary_enc(
210
210
  # No keys to rotate, due to dropout
211
211
  return xq_out.type_as(xq).to(xq.device), xk
212
212
  # Repeat freqs along seq_len dim to match k seq_len
213
- if repeat_freqs_k:
214
- r = xk_.shape[-2] // xq_.shape[-2]
215
- freqs_cis = freqs_cis.repeat(*([1] * (freqs_cis.ndim - 2)), r, 1)
213
+ if repeat_freqs_k and (r := xk_.shape[-2] // xq_.shape[-2]) > 1:
214
+ # MPS doesn't support repeat on complex tensors, decompose to real representation
215
+ if freqs_cis.device.type == "mps":
216
+ freqs_cis = torch.view_as_real(freqs_cis)
217
+ freqs_cis = freqs_cis.repeat(*([1] * (freqs_cis.ndim - 3)), r, 1, 1)
218
+ freqs_cis = torch.view_as_complex(freqs_cis.contiguous())
219
+ else:
220
+ freqs_cis = freqs_cis.repeat(*([1] * (freqs_cis.ndim - 2)), r, 1)
216
221
  xk_out = torch.view_as_real(xk_ * freqs_cis).flatten(3)
217
222
  return xq_out.type_as(xq).to(xq.device), xk_out.type_as(xk).to(xk.device)
218
223
 
@@ -878,6 +878,7 @@ class SAM2VideoPredictor(SAM2Predictor):
878
878
  self.clear_non_cond_mem_around_input = False
879
879
  self.clear_non_cond_mem_for_multi_obj = False
880
880
  self.callbacks["on_predict_start"].append(self.init_state)
881
+ self.clear_non_cond_mem = True # Whether to clear non-conditioning memory periodically
881
882
 
882
883
  def get_model(self):
883
884
  """Retrieve and configure the model with binarization enabled.
@@ -952,6 +953,7 @@ class SAM2VideoPredictor(SAM2Predictor):
952
953
  run_mem_encoder=True,
953
954
  )
954
955
  output_dict[storage_key][frame] = current_out
956
+ self._prune_non_cond_memory(frame)
955
957
  # Create slices of per-object outputs for subsequent interaction with each
956
958
  # individual object after tracking.
957
959
  self._add_output_per_object(frame, current_out, storage_key)
@@ -1830,6 +1832,25 @@ class SAM2VideoPredictor(SAM2Predictor):
1830
1832
  inference_state["frames_already_tracked"].clear()
1831
1833
  inference_state["first_ann_frame_idx"] = None
1832
1834
 
1835
+ def _prune_non_cond_memory(self, frame_idx, inference_state=None):
1836
+ """Prune old non-conditioning frames to bound memory usage."""
1837
+ if not self.clear_non_cond_mem:
1838
+ return
1839
+ inference_state = inference_state or self.inference_state
1840
+
1841
+ # Determine window size
1842
+ min_frame = frame_idx - self.model.num_maskmem * self.model.memory_temporal_stride_for_eval
1843
+ output_dict = inference_state["output_dict"]
1844
+
1845
+ # Prune global non_cond_frame_outputs
1846
+ for f in [k for k in output_dict["non_cond_frame_outputs"] if k < min_frame]:
1847
+ output_dict["non_cond_frame_outputs"].pop(f, None)
1848
+
1849
+ # Prune per-object non_cond_frame_outputs
1850
+ for obj_output_dict in inference_state.get("output_dict_per_obj", {}).values():
1851
+ for f in [k for k in obj_output_dict["non_cond_frame_outputs"] if k < min_frame]:
1852
+ obj_output_dict["non_cond_frame_outputs"].pop(f, None)
1853
+
1833
1854
 
1834
1855
  class SAM2DynamicInteractivePredictor(SAM2Predictor):
1835
1856
  """SAM2DynamicInteractivePredictor extends SAM2Predictor to support dynamic interactions with video frames or a
@@ -2423,6 +2444,7 @@ class SAM3VideoPredictor(SAM2VideoPredictor, SAM3Predictor):
2423
2444
  inference_state=inference_state,
2424
2445
  )
2425
2446
  output_dict[storage_key][frame] = current_out
2447
+ self._prune_non_cond_memory(frame, inference_state=inference_state)
2426
2448
  # Create slices of per-object outputs for subsequent interaction with each
2427
2449
  # individual object after tracking.
2428
2450
  self._add_output_per_object(frame, current_out, storage_key, inference_state=inference_state)
@@ -2475,14 +2497,12 @@ class SAM3VideoSemanticPredictor(SAM3SemanticPredictor):
2475
2497
  hotstart_delay=0,
2476
2498
  hotstart_unmatch_thresh=3,
2477
2499
  hotstart_dup_thresh=3,
2478
- # Whether to suppress masks only within hotstart. If False, we can suppress masks even if they start before hotstart period.
2479
- suppress_unmatched_only_within_hotstart=True,
2480
- init_trk_keep_alive=0,
2481
- max_trk_keep_alive=8,
2500
+ init_trk_keep_alive=30,
2501
+ max_trk_keep_alive=30,
2482
2502
  min_trk_keep_alive=-4,
2483
2503
  # Threshold for suppressing overlapping objects based on recent occlusion
2484
2504
  suppress_overlapping_based_on_recent_occlusion_threshold=0.0,
2485
- decrease_trk_keep_alive_for_empty_masklets=False,
2505
+ decrease_trk_keep_alive_for_empty_masklets=True,
2486
2506
  o2o_matching_masklets_enable=False, # Enable hungarian matching to match existing masklets
2487
2507
  suppress_det_close_to_boundary=False,
2488
2508
  fill_hole_area=16,
@@ -2513,7 +2533,6 @@ class SAM3VideoSemanticPredictor(SAM3SemanticPredictor):
2513
2533
  self.hotstart_delay = hotstart_delay
2514
2534
  self.hotstart_unmatch_thresh = hotstart_unmatch_thresh
2515
2535
  self.hotstart_dup_thresh = hotstart_dup_thresh
2516
- self.suppress_unmatched_only_within_hotstart = suppress_unmatched_only_within_hotstart
2517
2536
  self.init_trk_keep_alive = init_trk_keep_alive
2518
2537
  self.max_trk_keep_alive = max_trk_keep_alive
2519
2538
  self.min_trk_keep_alive = min_trk_keep_alive
@@ -2638,7 +2657,7 @@ class SAM3VideoSemanticPredictor(SAM3SemanticPredictor):
2638
2657
  ) > 0
2639
2658
 
2640
2659
  # names = getattr(self.model, "names", [str(i) for i in range(pred_scores.shape[0])])
2641
- names = dict(enumerate(str(i) for i in range(pred_masks.shape[0])))
2660
+ names = dict(enumerate(str(i) for i in range(pred_boxes.shape[0])))
2642
2661
  results = []
2643
2662
  for masks, boxes, orig_img, img_path in zip([pred_masks], [pred_boxes], orig_imgs, self.batch[0]):
2644
2663
  results.append(Results(orig_img, path=img_path, names=names, masks=masks, boxes=boxes))
@@ -2689,7 +2708,6 @@ class SAM3VideoSemanticPredictor(SAM3SemanticPredictor):
2689
2708
  metadata = tracker_metadata_new["metadata"]
2690
2709
  removed_obj_ids = metadata["removed_obj_ids"]
2691
2710
  out["removed_obj_ids"] = removed_obj_ids
2692
- out["suppressed_obj_ids"] = metadata["suppressed_obj_ids"][frame_idx]
2693
2711
  out["frame_stats"] = frame_stats
2694
2712
  if self.masklet_confirmation_enable:
2695
2713
  status = metadata["masklet_confirmation"]["status"]
@@ -3597,7 +3615,6 @@ class SAM3VideoSemanticPredictor(SAM3SemanticPredictor):
3597
3615
  overlap_pair_to_frame_inds = metadata["overlap_pair_to_frame_inds"]
3598
3616
  # removed_obj_ids: object IDs that are suppressed via hot-start
3599
3617
  removed_obj_ids = metadata["removed_obj_ids"]
3600
- suppressed_obj_ids = metadata["suppressed_obj_ids"][frame_idx]
3601
3618
 
3602
3619
  obj_ids_newly_removed = set() # object IDs to be newly removed on this frame
3603
3620
  hotstart_diff = frame_idx - self.hotstart_delay if not reverse else frame_idx + self.hotstart_delay
@@ -3647,12 +3664,12 @@ class SAM3VideoSemanticPredictor(SAM3SemanticPredictor):
3647
3664
  )
3648
3665
  if (
3649
3666
  trk_keep_alive[obj_id] <= 0 # Object has not been matched for too long
3650
- and not self.suppress_unmatched_only_within_hotstart
3651
3667
  and obj_id not in removed_obj_ids
3652
3668
  and obj_id not in obj_ids_newly_removed
3653
3669
  ):
3654
- LOGGER.debug(f"Suppressing object {obj_id} at frame {frame_idx}, due to being unmatched")
3655
- suppressed_obj_ids.add(obj_id)
3670
+ LOGGER.debug(f"Removing object {obj_id} at frame {frame_idx}, due to being unmatched")
3671
+ # directly removed the object instead of suppressing it
3672
+ obj_ids_newly_removed.add(obj_id)
3656
3673
 
3657
3674
  # Step 3: removed tracks that overlaps with another track for `hotstart_dup_thresh` frames
3658
3675
  # a) find overlaps tracks -- we consider overlap if they match to the same detection
@@ -3831,8 +3848,6 @@ class SAM3VideoSemanticPredictor(SAM3SemanticPredictor):
3831
3848
  "trk_keep_alive": defaultdict(int), # This is used only for object suppression not for removal
3832
3849
  "overlap_pair_to_frame_inds": defaultdict(list),
3833
3850
  "removed_obj_ids": set(),
3834
- # frame_idx --> set of objects with suppressed outputs, but still continue to be tracked
3835
- "suppressed_obj_ids": defaultdict(set),
3836
3851
  }
3837
3852
  if self.masklet_confirmation_enable:
3838
3853
  # all the following are np.ndarray with the same shape as `obj_ids_all_gpu`
@@ -24,17 +24,6 @@ class Colors:
24
24
  This class provides methods to work with the Ultralytics color palette, including converting hex color codes to RGB
25
25
  values and accessing predefined color schemes for object detection and pose estimation.
26
26
 
27
- Attributes:
28
- palette (list[tuple]): List of RGB color tuples for general use.
29
- n (int): The number of colors in the palette.
30
- pose_palette (np.ndarray): A specific color palette array for pose estimation with dtype np.uint8.
31
-
32
- Examples:
33
- >>> from ultralytics.utils.plotting import Colors
34
- >>> colors = Colors()
35
- >>> colors(5, True) # Returns BGR format: (221, 111, 255)
36
- >>> colors(5, False) # Returns RGB format: (255, 111, 221)
37
-
38
27
  ## Ultralytics Color Palette
39
28
 
40
29
  | Index | Color | HEX | RGB |
@@ -89,6 +78,17 @@ class Colors:
89
78
 
90
79
  For Ultralytics brand colors see [https://www.ultralytics.com/brand](https://www.ultralytics.com/brand).
91
80
  Please use the official Ultralytics colors for all marketing materials.
81
+
82
+ Attributes:
83
+ palette (list[tuple]): List of RGB color tuples for general use.
84
+ n (int): The number of colors in the palette.
85
+ pose_palette (np.ndarray): A specific color palette array for pose estimation with dtype np.uint8.
86
+
87
+ Examples:
88
+ >>> from ultralytics.utils.plotting import Colors
89
+ >>> colors = Colors()
90
+ >>> colors(5, True) # Returns BGR format: (221, 111, 255)
91
+ >>> colors(5, False) # Returns RGB format: (255, 111, 221)
92
92
  """
93
93
 
94
94
  def __init__(self):