dgenerate-ultralytics-headless 8.3.239__py3-none-any.whl → 8.3.241__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.
- {dgenerate_ultralytics_headless-8.3.239.dist-info → dgenerate_ultralytics_headless-8.3.241.dist-info}/METADATA +3 -2
- {dgenerate_ultralytics_headless-8.3.239.dist-info → dgenerate_ultralytics_headless-8.3.241.dist-info}/RECORD +13 -13
- ultralytics/__init__.py +1 -1
- ultralytics/engine/exporter.py +2 -1
- ultralytics/models/sam/modules/utils.py +8 -3
- ultralytics/models/sam/predict.py +29 -14
- ultralytics/nn/autobackend.py +44 -38
- ultralytics/utils/__init__.py +1 -0
- ultralytics/utils/plotting.py +13 -11
- {dgenerate_ultralytics_headless-8.3.239.dist-info → dgenerate_ultralytics_headless-8.3.241.dist-info}/WHEEL +0 -0
- {dgenerate_ultralytics_headless-8.3.239.dist-info → dgenerate_ultralytics_headless-8.3.241.dist-info}/entry_points.txt +0 -0
- {dgenerate_ultralytics_headless-8.3.239.dist-info → dgenerate_ultralytics_headless-8.3.241.dist-info}/licenses/LICENSE +0 -0
- {dgenerate_ultralytics_headless-8.3.239.dist-info → dgenerate_ultralytics_headless-8.3.241.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dgenerate-ultralytics-headless
|
|
3
|
-
Version: 8.3.
|
|
3
|
+
Version: 8.3.241
|
|
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>
|
|
@@ -51,12 +51,13 @@ Requires-Dist: pytest; extra == "dev"
|
|
|
51
51
|
Requires-Dist: pytest-cov; extra == "dev"
|
|
52
52
|
Requires-Dist: coverage[toml]; extra == "dev"
|
|
53
53
|
Requires-Dist: zensical>=0.0.9; python_version >= "3.10" and extra == "dev"
|
|
54
|
-
Requires-Dist: mkdocs-ultralytics-plugin>=0.2.
|
|
54
|
+
Requires-Dist: mkdocs-ultralytics-plugin>=0.2.4; extra == "dev"
|
|
55
55
|
Requires-Dist: minijinja>=2.0.0; extra == "dev"
|
|
56
56
|
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.
|
|
1
|
+
dgenerate_ultralytics_headless-8.3.241.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=
|
|
11
|
+
ultralytics/__init__.py,sha256=S3XtXs_EbjQDpks7nIo7kSOhs1K6f8di-vl6nLmJ6_g,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
|
|
@@ -123,7 +123,7 @@ ultralytics/data/scripts/get_coco.sh,sha256=UuJpJeo3qQpTHVINeOpmP0NYmg8PhEFE3A8J
|
|
|
123
123
|
ultralytics/data/scripts/get_coco128.sh,sha256=qmRQl_hOKrsdHrTrnyQuFIH01oDz3lfaz138OgGfLt8,650
|
|
124
124
|
ultralytics/data/scripts/get_imagenet.sh,sha256=hr42H16bM47iT27rgS7MpEo-GeOZAYUQXgr0B2cwn48,1705
|
|
125
125
|
ultralytics/engine/__init__.py,sha256=lm6MckFYCPTbqIoX7w0s_daxdjNeBeKW6DXppv1-QUM,70
|
|
126
|
-
ultralytics/engine/exporter.py,sha256=
|
|
126
|
+
ultralytics/engine/exporter.py,sha256=XG7JOdeJb_4pQF-iQkf1pCTCsFn_VVLILhBI_wu-iPM,73038
|
|
127
127
|
ultralytics/engine/model.py,sha256=RkjMWXkyGmYjmMYIG8mPX8Cf1cJvn0ccOsXt03g7tIk,52999
|
|
128
128
|
ultralytics/engine/predictor.py,sha256=neYmNDX27Vv3ggk9xqaKlH6XzB2vlFIghU5o7ZC0zFo,22838
|
|
129
129
|
ultralytics/engine/results.py,sha256=LHX0AaVOv3CEjYjw8i4LThXqihxmahWCxpH20b4s9dM,68030
|
|
@@ -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=
|
|
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=
|
|
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
|
|
@@ -210,7 +210,7 @@ ultralytics/models/yolo/yoloe/train.py,sha256=giX6zDu5Z3z48PCaBHzu7v9NH3BrpUaGAY
|
|
|
210
210
|
ultralytics/models/yolo/yoloe/train_seg.py,sha256=0hRByMXsEJA-J2B1wXDMVhiW9f9MOTj3LlrGTibN6Ww,4919
|
|
211
211
|
ultralytics/models/yolo/yoloe/val.py,sha256=utUFWeFKRFWZrPr1y3A8ztbTwdoWMYqzlwBN7CQ0tCA,9418
|
|
212
212
|
ultralytics/nn/__init__.py,sha256=538LZPUKKvc3JCMgiQ4VLGqRN2ZAaVLFcQbeNNHFkEA,545
|
|
213
|
-
ultralytics/nn/autobackend.py,sha256=
|
|
213
|
+
ultralytics/nn/autobackend.py,sha256=mCPRyW3OGt_jzi1dwAJXH93ntsHqg_95AfSjWhjt-cw,44612
|
|
214
214
|
ultralytics/nn/tasks.py,sha256=636MN27VvlupIaHPpV4r0J705RUdV-giNKjIeJbRkxI,70448
|
|
215
215
|
ultralytics/nn/text_model.py,sha256=novnuosqXnW1NmlOzWOk7dEKuN6Vq40CTksr6hI3Knc,15109
|
|
216
216
|
ultralytics/nn/modules/__init__.py,sha256=5Sg_28MDfKwdu14Ty_WCaiIXZyjBSQ-xCNCwnoz_w-w,3198
|
|
@@ -250,7 +250,7 @@ ultralytics/trackers/utils/__init__.py,sha256=lm6MckFYCPTbqIoX7w0s_daxdjNeBeKW6D
|
|
|
250
250
|
ultralytics/trackers/utils/gmc.py,sha256=cvvhNXOhylVQti4pJQSNPx4yPqhhhw1k2yzY0JFl7Zo,13760
|
|
251
251
|
ultralytics/trackers/utils/kalman_filter.py,sha256=crgysL2bo0v1eTljOlP2YqIJDLBcHjl75MRpbxfaR_M,21514
|
|
252
252
|
ultralytics/trackers/utils/matching.py,sha256=jRZQrYSECQEwILn3mr7OodB8o7GawV-1v869plHstwk,7147
|
|
253
|
-
ultralytics/utils/__init__.py,sha256=
|
|
253
|
+
ultralytics/utils/__init__.py,sha256=JfvODTB4mG_JOhTeCiPtq0iCEgiCh14hJf195rnOhLQ,55145
|
|
254
254
|
ultralytics/utils/autobatch.py,sha256=jiE4m_--H9UkXFDm_FqzcZk_hSTCGpS72XdVEKgZwAo,5114
|
|
255
255
|
ultralytics/utils/autodevice.py,sha256=rXlPuo-iX-vZ4BabmMGEGh9Uxpau4R7Zlt1KCo9Xfyc,8892
|
|
256
256
|
ultralytics/utils/benchmarks.py,sha256=S_W4S4pe2ktSRdSuWb6m09UEFQmZhmjl943bbo67hOI,32277
|
|
@@ -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=
|
|
272
|
+
ultralytics/utils/plotting.py,sha256=nLProk2U3xYBwV4CdkeBx1mrPnrPA550cNSQRGbcLsg,48368
|
|
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.
|
|
295
|
-
dgenerate_ultralytics_headless-8.3.
|
|
296
|
-
dgenerate_ultralytics_headless-8.3.
|
|
297
|
-
dgenerate_ultralytics_headless-8.3.
|
|
298
|
-
dgenerate_ultralytics_headless-8.3.
|
|
294
|
+
dgenerate_ultralytics_headless-8.3.241.dist-info/METADATA,sha256=9qvOTFpuIuFvwutj2DJnpJkcuGoXmoIulGzzZ-e6gw8,38798
|
|
295
|
+
dgenerate_ultralytics_headless-8.3.241.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
296
|
+
dgenerate_ultralytics_headless-8.3.241.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
|
|
297
|
+
dgenerate_ultralytics_headless-8.3.241.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
|
|
298
|
+
dgenerate_ultralytics_headless-8.3.241.dist-info/RECORD,,
|
ultralytics/__init__.py
CHANGED
ultralytics/engine/exporter.py
CHANGED
|
@@ -1205,8 +1205,9 @@ class Exporter:
|
|
|
1205
1205
|
# Setuptools bug: https://github.com/pypa/setuptools/issues/4483
|
|
1206
1206
|
check_requirements("setuptools<71.0.0") # Setuptools bug: https://github.com/pypa/setuptools/issues/4483
|
|
1207
1207
|
check_requirements(("executorch==1.0.1", "flatbuffers"))
|
|
1208
|
+
# Pin numpy to avoid coremltools errors with numpy>=2.4.0, must be separate
|
|
1209
|
+
check_requirements("numpy<=2.3.5")
|
|
1208
1210
|
|
|
1209
|
-
import torch
|
|
1210
1211
|
from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner
|
|
1211
1212
|
from executorch.exir import to_edge_transform_and_lower
|
|
1212
1213
|
|
|
@@ -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
|
-
|
|
215
|
-
|
|
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
|
-
|
|
2479
|
-
|
|
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=
|
|
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(
|
|
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"
|
|
3655
|
-
|
|
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`
|
ultralytics/nn/autobackend.py
CHANGED
|
@@ -245,15 +245,20 @@ class AutoBackend(nn.Module):
|
|
|
245
245
|
check_requirements(("onnx", "onnxruntime-gpu" if cuda else "onnxruntime"))
|
|
246
246
|
import onnxruntime
|
|
247
247
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
248
|
+
# Select execution provider: CUDA > CoreML (mps) > CPU
|
|
249
|
+
available = onnxruntime.get_available_providers()
|
|
250
|
+
if cuda and "CUDAExecutionProvider" in available:
|
|
251
|
+
providers = [("CUDAExecutionProvider", {"device_id": device.index}), "CPUExecutionProvider"]
|
|
252
|
+
elif device.type == "mps" and "CoreMLExecutionProvider" in available:
|
|
253
|
+
providers = ["CoreMLExecutionProvider", "CPUExecutionProvider"]
|
|
254
|
+
else:
|
|
255
|
+
providers = ["CPUExecutionProvider"]
|
|
256
|
+
if cuda:
|
|
257
|
+
LOGGER.warning("CUDA requested but CUDAExecutionProvider not available. Using CPU...")
|
|
258
|
+
device, cuda = torch.device("cpu"), False
|
|
259
|
+
LOGGER.info(
|
|
260
|
+
f"Using ONNX Runtime {onnxruntime.__version__} with {providers[0] if isinstance(providers[0], str) else providers[0][0]}"
|
|
261
|
+
)
|
|
257
262
|
if onnx:
|
|
258
263
|
session = onnxruntime.InferenceSession(w, providers=providers)
|
|
259
264
|
else:
|
|
@@ -271,7 +276,10 @@ class AutoBackend(nn.Module):
|
|
|
271
276
|
metadata = session.get_modelmeta().custom_metadata_map
|
|
272
277
|
dynamic = isinstance(session.get_outputs()[0].shape[0], str)
|
|
273
278
|
fp16 = "float16" in session.get_inputs()[0].type
|
|
274
|
-
|
|
279
|
+
|
|
280
|
+
# Setup IO binding for optimized inference (CUDA only, not supported for CoreML)
|
|
281
|
+
use_io_binding = not dynamic and cuda
|
|
282
|
+
if use_io_binding:
|
|
275
283
|
io = session.io_binding()
|
|
276
284
|
bindings = []
|
|
277
285
|
for output in session.get_outputs():
|
|
@@ -371,32 +379,33 @@ class AutoBackend(nn.Module):
|
|
|
371
379
|
is_trt10 = not hasattr(model, "num_bindings")
|
|
372
380
|
num = range(model.num_io_tensors) if is_trt10 else range(model.num_bindings)
|
|
373
381
|
for i in num:
|
|
382
|
+
# Get tensor info using TRT10+ or legacy API
|
|
374
383
|
if is_trt10:
|
|
375
384
|
name = model.get_tensor_name(i)
|
|
376
385
|
dtype = trt.nptype(model.get_tensor_dtype(name))
|
|
377
386
|
is_input = model.get_tensor_mode(name) == trt.TensorIOMode.INPUT
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
context.set_input_shape(name, tuple(model.get_tensor_profile_shape(name, 0)[2]))
|
|
382
|
-
if dtype == np.float16:
|
|
383
|
-
fp16 = True
|
|
384
|
-
else:
|
|
385
|
-
output_names.append(name)
|
|
386
|
-
shape = tuple(context.get_tensor_shape(name))
|
|
387
|
-
else: # TensorRT < 10.0
|
|
387
|
+
shape = tuple(model.get_tensor_shape(name))
|
|
388
|
+
profile_shape = tuple(model.get_tensor_profile_shape(name, 0)[2]) if is_input else None
|
|
389
|
+
else:
|
|
388
390
|
name = model.get_binding_name(i)
|
|
389
391
|
dtype = trt.nptype(model.get_binding_dtype(i))
|
|
390
392
|
is_input = model.binding_is_input(i)
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
393
|
+
shape = tuple(model.get_binding_shape(i))
|
|
394
|
+
profile_shape = tuple(model.get_profile_shape(0, i)[1]) if is_input else None
|
|
395
|
+
|
|
396
|
+
# Process input/output tensors
|
|
397
|
+
if is_input:
|
|
398
|
+
if -1 in shape:
|
|
399
|
+
dynamic = True
|
|
400
|
+
if is_trt10:
|
|
401
|
+
context.set_input_shape(name, profile_shape)
|
|
402
|
+
else:
|
|
403
|
+
context.set_binding_shape(i, profile_shape)
|
|
404
|
+
if dtype == np.float16:
|
|
405
|
+
fp16 = True
|
|
406
|
+
else:
|
|
407
|
+
output_names.append(name)
|
|
408
|
+
shape = tuple(context.get_tensor_shape(name)) if is_trt10 else tuple(context.get_binding_shape(i))
|
|
400
409
|
im = torch.from_numpy(np.empty(shape, dtype=dtype)).to(device)
|
|
401
410
|
bindings[name] = Binding(name, dtype, shape, im, int(im.data_ptr()))
|
|
402
411
|
binding_addrs = OrderedDict((n, d.ptr) for n, d in bindings.items())
|
|
@@ -418,8 +427,7 @@ class AutoBackend(nn.Module):
|
|
|
418
427
|
LOGGER.info(f"Loading {w} for TensorFlow SavedModel inference...")
|
|
419
428
|
import tensorflow as tf
|
|
420
429
|
|
|
421
|
-
|
|
422
|
-
model = tf.keras.models.load_model(w) if keras else tf.saved_model.load(w)
|
|
430
|
+
model = tf.saved_model.load(w)
|
|
423
431
|
metadata = Path(w) / "metadata.yaml"
|
|
424
432
|
|
|
425
433
|
# TF GraphDef
|
|
@@ -699,10 +707,7 @@ class AutoBackend(nn.Module):
|
|
|
699
707
|
|
|
700
708
|
# ONNX Runtime
|
|
701
709
|
elif self.onnx or self.imx:
|
|
702
|
-
if self.
|
|
703
|
-
im = im.cpu().numpy() # torch to numpy
|
|
704
|
-
y = self.session.run(self.output_names, {self.session.get_inputs()[0].name: im})
|
|
705
|
-
else:
|
|
710
|
+
if self.use_io_binding:
|
|
706
711
|
if not self.cuda:
|
|
707
712
|
im = im.cpu()
|
|
708
713
|
self.io.bind_input(
|
|
@@ -715,6 +720,9 @@ class AutoBackend(nn.Module):
|
|
|
715
720
|
)
|
|
716
721
|
self.session.run_with_iobinding(self.io)
|
|
717
722
|
y = self.bindings
|
|
723
|
+
else:
|
|
724
|
+
im = im.cpu().numpy() # torch to numpy
|
|
725
|
+
y = self.session.run(self.output_names, {self.session.get_inputs()[0].name: im})
|
|
718
726
|
if self.imx:
|
|
719
727
|
if self.task == "detect":
|
|
720
728
|
# boxes, conf, cls
|
|
@@ -839,7 +847,7 @@ class AutoBackend(nn.Module):
|
|
|
839
847
|
else:
|
|
840
848
|
im = im.cpu().numpy()
|
|
841
849
|
if self.saved_model: # SavedModel
|
|
842
|
-
y = self.model
|
|
850
|
+
y = self.model.serving_default(im)
|
|
843
851
|
if not isinstance(y, list):
|
|
844
852
|
y = [y]
|
|
845
853
|
elif self.pb: # GraphDef
|
|
@@ -884,8 +892,6 @@ class AutoBackend(nn.Module):
|
|
|
884
892
|
y[1] = np.transpose(y[1], (0, 3, 1, 2)) # should be y = (1, 116, 8400), (1, 32, 160, 160)
|
|
885
893
|
y = [x if isinstance(x, np.ndarray) else x.numpy() for x in y]
|
|
886
894
|
|
|
887
|
-
# for x in y:
|
|
888
|
-
# print(type(x), len(x)) if isinstance(x, (list, tuple)) else print(type(x), x.shape) # debug shapes
|
|
889
895
|
if isinstance(y, (list, tuple)):
|
|
890
896
|
if len(self.names) == 999 and (self.task == "segment" or len(y) == 2): # segments and names not defined
|
|
891
897
|
nc = y[0].shape[1] - y[1].shape[1] - 4 # y = (1, 32, 160, 160), (1, 116, 8400)
|
ultralytics/utils/__init__.py
CHANGED
ultralytics/utils/plotting.py
CHANGED
|
@@ -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):
|
|
@@ -203,6 +203,8 @@ class Annotator:
|
|
|
203
203
|
if not input_is_pil:
|
|
204
204
|
if im.shape[2] == 1: # handle grayscale
|
|
205
205
|
im = cv2.cvtColor(im, cv2.COLOR_GRAY2BGR)
|
|
206
|
+
elif im.shape[2] == 2: # handle 2-channel images
|
|
207
|
+
im = np.ascontiguousarray(np.dstack((im, np.zeros_like(im[..., :1]))))
|
|
206
208
|
elif im.shape[2] > 3: # multispectral
|
|
207
209
|
im = np.ascontiguousarray(im[..., :3])
|
|
208
210
|
if self.pil: # use PIL
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|