dgenerate-ultralytics-headless 8.3.140__py3-none-any.whl → 8.3.143__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.140.dist-info → dgenerate_ultralytics_headless-8.3.143.dist-info}/METADATA +1 -1
- {dgenerate_ultralytics_headless-8.3.140.dist-info → dgenerate_ultralytics_headless-8.3.143.dist-info}/RECORD +24 -24
- {dgenerate_ultralytics_headless-8.3.140.dist-info → dgenerate_ultralytics_headless-8.3.143.dist-info}/WHEEL +1 -1
- tests/test_cuda.py +1 -1
- tests/test_solutions.py +4 -3
- ultralytics/__init__.py +1 -1
- ultralytics/cfg/__init__.py +6 -6
- ultralytics/cfg/datasets/open-images-v7.yaml +4 -7
- ultralytics/engine/model.py +6 -3
- ultralytics/engine/results.py +0 -1
- ultralytics/models/yolo/classify/predict.py +1 -1
- ultralytics/models/yolo/model.py +7 -1
- ultralytics/solutions/distance_calculation.py +2 -1
- ultralytics/solutions/object_counter.py +3 -5
- ultralytics/solutions/object_cropper.py +9 -3
- ultralytics/solutions/solutions.py +32 -11
- ultralytics/utils/autodevice.py +9 -7
- ultralytics/utils/loss.py +1 -2
- ultralytics/utils/plotting.py +14 -16
- ultralytics/utils/tal.py +3 -6
- ultralytics/utils/torch_utils.py +1 -1
- {dgenerate_ultralytics_headless-8.3.140.dist-info → dgenerate_ultralytics_headless-8.3.143.dist-info}/entry_points.txt +0 -0
- {dgenerate_ultralytics_headless-8.3.140.dist-info → dgenerate_ultralytics_headless-8.3.143.dist-info}/licenses/LICENSE +0 -0
- {dgenerate_ultralytics_headless-8.3.140.dist-info → dgenerate_ultralytics_headless-8.3.143.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.143
|
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>
|
@@ -1,17 +1,17 @@
|
|
1
|
-
dgenerate_ultralytics_headless-8.3.
|
1
|
+
dgenerate_ultralytics_headless-8.3.143.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
|
2
2
|
tests/__init__.py,sha256=xnMhv3O_DF1YrW4zk__ZywQzAaoTDjPKPoiI1Ktss1w,670
|
3
3
|
tests/conftest.py,sha256=rsIAipRKfrVNoTaJ1LdpYue8AbcJ_fr3d3WIlM_6uXY,2982
|
4
4
|
tests/test_cli.py,sha256=vXUC_EK0fa87JRhHsCOZf7AJQ5_Jm1sL8u-yhmsaQh0,5851
|
5
|
-
tests/test_cuda.py,sha256=
|
5
|
+
tests/test_cuda.py,sha256=bT_IzqxKQW3u2E06_Gcox2tZfmadMEv0W66OUrPF0P4,7917
|
6
6
|
tests/test_engine.py,sha256=aGqZ8P7QO5C_nOa1b4FOyk92Ysdk5WiP-ST310Vyxys,4962
|
7
7
|
tests/test_exports.py,sha256=dhZn86LdbapW15RthQF870LGxDjC1MUZhlGdBgPmgIQ,9716
|
8
8
|
tests/test_integrations.py,sha256=dQteeRsRVuT_p5-T88-7jqT65Zm9iAXkyKg-KQ1_TQ8,6341
|
9
9
|
tests/test_python.py,sha256=Zx9OlPN11_D1WSLpi9nPFqORNHNz0lEn6mxVNL2ZHjE,25852
|
10
|
-
tests/test_solutions.py,sha256=
|
11
|
-
ultralytics/__init__.py,sha256=
|
10
|
+
tests/test_solutions.py,sha256=4TryDaWOeY3HF33RZuYe9ofUZhgQrp4_nFI8tPUdiOc,13080
|
11
|
+
ultralytics/__init__.py,sha256=XEt2XO7rEliN-Fgis0qJ7S8kTmeX8cMWBWgI0jROIRY,730
|
12
12
|
ultralytics/assets/bus.jpg,sha256=wCAZxJecGR63Od3ZRERe9Aja1Weayrb9Ug751DS_vGM,137419
|
13
13
|
ultralytics/assets/zidane.jpg,sha256=Ftc4aeMmen1O0A3o6GCDO9FlfBslLpTAw0gnetx7bts,50427
|
14
|
-
ultralytics/cfg/__init__.py,sha256=
|
14
|
+
ultralytics/cfg/__init__.py,sha256=nDPCpYipxJ5XLjwwaoB5DNbovbOH-GM26_e2G5jDQ28,39580
|
15
15
|
ultralytics/cfg/default.yaml,sha256=oFG6llJO-Py5H-cR9qs-7FieJamroDLwpbrkhmfROOM,8307
|
16
16
|
ultralytics/cfg/datasets/Argoverse.yaml,sha256=_xlEDIJ9XkUo0v_iNL7FW079BoSeZtKSuLteKTtGbA8,3275
|
17
17
|
ultralytics/cfg/datasets/DOTAv1.5.yaml,sha256=SHND_CFkojxw5iQD5Mcgju2kCZIl0gW2ajuzv1cqoL0,1224
|
@@ -41,7 +41,7 @@ ultralytics/cfg/datasets/dota8.yaml,sha256=W43bp_6yUUVjs6vpogNrGI9vU7rLbEsSx6vyf
|
|
41
41
|
ultralytics/cfg/datasets/hand-keypoints.yaml,sha256=5vue4kvPrAdd6ZyB90rZgtGUUHvSi3s_ht7jBBqX7a4,989
|
42
42
|
ultralytics/cfg/datasets/lvis.yaml,sha256=jD-z6cny0l_Cl7xN6RqiFAc7a7odcVwr3E8_jmH-wzA,29716
|
43
43
|
ultralytics/cfg/datasets/medical-pills.yaml,sha256=3ho9VW8p5Hm1TuicguiL-akfC9dCZO5nwthO4sUR3k0,848
|
44
|
-
ultralytics/cfg/datasets/open-images-v7.yaml,sha256=
|
44
|
+
ultralytics/cfg/datasets/open-images-v7.yaml,sha256=uhsujByejzeysTB10QnSLfDNb9U_HqoES45QJrqMC7g,12132
|
45
45
|
ultralytics/cfg/datasets/package-seg.yaml,sha256=uechtCYfX8OrJrO5zV1-uGwbr69lUSuon1oXguEkLGg,864
|
46
46
|
ultralytics/cfg/datasets/signature.yaml,sha256=eABYny9n4w3RleR3RQmb505DiBll8R5cvcjWj8wkuf0,789
|
47
47
|
ultralytics/cfg/datasets/tiger-pose.yaml,sha256=gCQc1AX04Xfhnms4czm7R_XnT2XFL2u-t3M8Yya20ds,925
|
@@ -120,9 +120,9 @@ ultralytics/data/scripts/get_coco128.sh,sha256=qmRQl_hOKrsdHrTrnyQuFIH01oDz3lfaz
|
|
120
120
|
ultralytics/data/scripts/get_imagenet.sh,sha256=hr42H16bM47iT27rgS7MpEo-GeOZAYUQXgr0B2cwn48,1705
|
121
121
|
ultralytics/engine/__init__.py,sha256=lm6MckFYCPTbqIoX7w0s_daxdjNeBeKW6DXppv1-QUM,70
|
122
122
|
ultralytics/engine/exporter.py,sha256=BZWa7Mnl1BPvbPiD-RJs6M5Bca4sm3_MQgjoHesvXEs,70949
|
123
|
-
ultralytics/engine/model.py,sha256=
|
123
|
+
ultralytics/engine/model.py,sha256=6AhrrcuLOQk_JuOAPQt3uNktAhEBWcBBh_AP2DGEbAs,53147
|
124
124
|
ultralytics/engine/predictor.py,sha256=rZ5mIPeejkxUerpTfUf_1rSAklOR3THqoejlil4C04w,21651
|
125
|
-
ultralytics/engine/results.py,sha256=
|
125
|
+
ultralytics/engine/results.py,sha256=BOpn7RihPt8OUpdklWs1iL3LCxVXOiynPGpaR_MPToQ,70036
|
126
126
|
ultralytics/engine/trainer.py,sha256=xdgNAgq6umJ6915tiCK3U22NeY7w1HnvmAhXlwS_hYI,38955
|
127
127
|
ultralytics/engine/tuner.py,sha256=zEW1UpLlZ6N4xbvS7MxICkshRlaFgLNfuADA0VfRpao,12629
|
128
128
|
ultralytics/engine/validator.py,sha256=f9UUv3QqQStLrO1nojrHkdS58qYQxKXaoIQQria6WyA,17054
|
@@ -164,9 +164,9 @@ ultralytics/models/utils/__init__.py,sha256=lm6MckFYCPTbqIoX7w0s_daxdjNeBeKW6DXp
|
|
164
164
|
ultralytics/models/utils/loss.py,sha256=FShJFvzFBk0HRepRhiSVNz9J-Cq08FxkSNXhLppycI0,19993
|
165
165
|
ultralytics/models/utils/ops.py,sha256=SuBnwwgUTqByNHpufobGLW72yO2cyfZFi14KAFWSjjw,13613
|
166
166
|
ultralytics/models/yolo/__init__.py,sha256=or0j5xvcM0usMlsFTYhNAOcQUri7reD0cD9JR5b7zDk,307
|
167
|
-
ultralytics/models/yolo/model.py,sha256=
|
167
|
+
ultralytics/models/yolo/model.py,sha256=Akq0TuthKAWDIa2l2gNs3QLWVV5Zpk520fdnNa7zxm0,14648
|
168
168
|
ultralytics/models/yolo/classify/__init__.py,sha256=9--HVaNOfI1K7rn_rRqclL8FUAnpfeBrRqEQIaQw2xM,383
|
169
|
-
ultralytics/models/yolo/classify/predict.py,sha256=
|
169
|
+
ultralytics/models/yolo/classify/predict.py,sha256=aSNANtN4pbuaiprGR9d3krIfqnAMcAGhnOM8KRh8wR0,4639
|
170
170
|
ultralytics/models/yolo/classify/train.py,sha256=rv2CJv9fzvtHf2q4l5g0RsjplWKeLpz637kKqjtrLNY,9737
|
171
171
|
ultralytics/models/yolo/classify/val.py,sha256=xk-YwSQdl_oqyCBV0OOAOcXFL6CchebFOc36AkRSyjE,9992
|
172
172
|
ultralytics/models/yolo/detect/__init__.py,sha256=GIRsLYR-kT4JJx7lh4ZZAFGBZj0aebokuU0A7JbjDVA,257
|
@@ -208,18 +208,18 @@ ultralytics/solutions/__init__.py,sha256=ZoeAQavTLp8aClnhZ9tbl6lxy86GxofyGvZWTx2
|
|
208
208
|
ultralytics/solutions/ai_gym.py,sha256=QRTFwuD0g9KJgAjqdww4OeitXm-hsyXL1pJlrAhTyqA,5347
|
209
209
|
ultralytics/solutions/analytics.py,sha256=u-khRAViGupjq9mkuAFCl9G3yE8hXfXASfKZd_SQZ-8,12111
|
210
210
|
ultralytics/solutions/config.py,sha256=TLxQuZjqW-vhbS2OFmTT188-31ukHg1XP7l-BeOmqbU,5427
|
211
|
-
ultralytics/solutions/distance_calculation.py,sha256=
|
211
|
+
ultralytics/solutions/distance_calculation.py,sha256=JyB1KC1WihwGLFX2R2kk4QEvo8Qm0f3CD8fYqchzmfU,5807
|
212
212
|
ultralytics/solutions/heatmap.py,sha256=0Hw2Vhg4heglpnbNkM-RiGrQOkvgYbPRf4x8x4-zTjg,5418
|
213
213
|
ultralytics/solutions/instance_segmentation.py,sha256=IuAxxEkKrbTPHmD0jV3VEjNWpBc78o8exg00nE0ldeQ,3558
|
214
214
|
ultralytics/solutions/object_blurrer.py,sha256=-wXOdqqZisVhxLutZz7JvZmdgVGmsN7Ymary0JHc2qo,3946
|
215
|
-
ultralytics/solutions/object_counter.py,sha256=
|
216
|
-
ultralytics/solutions/object_cropper.py,sha256=
|
215
|
+
ultralytics/solutions/object_counter.py,sha256=49ixmy1OPv5D3CZmsZWQCigJstQvYIdK5aHypNBsZg8,9519
|
216
|
+
ultralytics/solutions/object_cropper.py,sha256=s56XQMpgCgeQg9KEZs2_7_cP_V-eH6315cY1bxt2oGs,3456
|
217
217
|
ultralytics/solutions/parking_management.py,sha256=BV-2lpSfgmK7fib3DnPSZ5rtLdy11c8pBQm-72iTetc,13289
|
218
218
|
ultralytics/solutions/queue_management.py,sha256=p1-cuI_rs4ygtlBryXjE65NYG2bnZXhp3ylggFnWcRs,4344
|
219
219
|
ultralytics/solutions/region_counter.py,sha256=Zn35YRXNzhBk27D9MLOHBYe2L1o6H2ey3mEwCXofB_E,5418
|
220
220
|
ultralytics/solutions/security_alarm.py,sha256=JdkQUjqJl3iCd2MLVYkh1L7askvhi3_gp0RLXG6s390,6247
|
221
221
|
ultralytics/solutions/similarity_search.py,sha256=NVjrlxWStXPhSaE_tGW0g1_j8vD0evaT9IjGOHYERFg,7323
|
222
|
-
ultralytics/solutions/solutions.py,sha256=
|
222
|
+
ultralytics/solutions/solutions.py,sha256=zJ7CZh2U2VEUWe5LfC3XhVuc_HGOAQeHPM8ls3cmiZU,33681
|
223
223
|
ultralytics/solutions/speed_estimation.py,sha256=r7S5nGIx8PTV-zC4zCI36lQD2DVy5cen5cTXItfQIHo,5318
|
224
224
|
ultralytics/solutions/streamlit_inference.py,sha256=p1bBKTtmvB6zStXdOzS0CGYurm4zu82WKii5rJriizA,9849
|
225
225
|
ultralytics/solutions/trackzone.py,sha256=mfklnZcVRqI3bbhPiHF2iSoV6INcd10wwwGP4tlK7L0,3854
|
@@ -236,7 +236,7 @@ ultralytics/trackers/utils/kalman_filter.py,sha256=A0CqOnnaKH6kr0XwuHzyHmIU6aJAj
|
|
236
236
|
ultralytics/trackers/utils/matching.py,sha256=7eIufSdeN7cXuFMjvcfvz0Ldq84m4YKZl5IGxBR8IIo,7169
|
237
237
|
ultralytics/utils/__init__.py,sha256=7VT2VSCIgDPInuNKO0sy2_3-qUwuCafLG0wF4wAyjBg,59059
|
238
238
|
ultralytics/utils/autobatch.py,sha256=kg05q2qKg74y_Uq2vvr01i3KhLfpVR7sT0IXBt3_kyI,4921
|
239
|
-
ultralytics/utils/autodevice.py,sha256=
|
239
|
+
ultralytics/utils/autodevice.py,sha256=gSai9YvsDTYj5Kj18n4XGtf0oXXVPbjanKrO1C1w0C4,7454
|
240
240
|
ultralytics/utils/benchmarks.py,sha256=iqjxD29srcCpimtAhbSidpsjnUlMhNR5S6QGPZyz16I,30287
|
241
241
|
ultralytics/utils/checks.py,sha256=SinI5gY-znVbQ-JXk1JaHIlSp2kuBv92Rv99NWFzOFg,33763
|
242
242
|
ultralytics/utils/dist.py,sha256=aytW0JEkcA5ZTZucV92ot7Bn-apiej8aLk3QNWicjAc,4103
|
@@ -245,13 +245,13 @@ ultralytics/utils/errors.py,sha256=vY9h2evFSrHnZdHJVVrmm8Zzw4qVDLyo9DeYW5g0dFk,1
|
|
245
245
|
ultralytics/utils/export.py,sha256=Rr5R3GdJBapJJt1XHkH6VQwYN52-L_7wGiRDCgnb7BY,8817
|
246
246
|
ultralytics/utils/files.py,sha256=0K4O1cgqRiXaDw7EQK13TqA5SME_RrvfDVQSPetNr5w,8042
|
247
247
|
ultralytics/utils/instance.py,sha256=UOEsXR9V-bXNRk6BTonASBEgeMqvzzAk4S7VdXZJUAM,18090
|
248
|
-
ultralytics/utils/loss.py,sha256=
|
248
|
+
ultralytics/utils/loss.py,sha256=KMug5vHESghC3B3V5Vi-fhGVDdTjG9nGkGJmgO_WnPI,37575
|
249
249
|
ultralytics/utils/metrics.py,sha256=8x4S7y-rBKRkM47f_o7jfMHA1Bz8SDq3t-R1FXlQNEM,59267
|
250
250
|
ultralytics/utils/ops.py,sha256=YFwPrKlPcgEmgAWqnJVR0Ccx5NQgp5e3P-YYHwVSP0k,34779
|
251
251
|
ultralytics/utils/patches.py,sha256=_dhIU_eDklQE-aWIjpyjPHl_wOwZoGuIUQnXgdSwk_A,5020
|
252
|
-
ultralytics/utils/plotting.py,sha256=
|
253
|
-
ultralytics/utils/tal.py,sha256=
|
254
|
-
ultralytics/utils/torch_utils.py,sha256=
|
252
|
+
ultralytics/utils/plotting.py,sha256=WAWTGQAsM-cWy08QmcYOXrzFMHd24i8deYTed_u4kbg,47027
|
253
|
+
ultralytics/utils/tal.py,sha256=fkOdogPqPBUN07ThixpI8X7hea-oEfTIaaBLc26_O2s,20610
|
254
|
+
ultralytics/utils/torch_utils.py,sha256=WGNxGocstHD6ljhvujSCWjsYd4xWjNIXk_pq53zcKCc,39675
|
255
255
|
ultralytics/utils/triton.py,sha256=9P2rlQcGCTMFVKLA5S5mTYzU9cKbR5HF9ruVkPpVBE8,5307
|
256
256
|
ultralytics/utils/tuner.py,sha256=0Bp7l5dWZe1RzdvAIa11wQoX6eoAaoNRcA-EAnpofbk,6755
|
257
257
|
ultralytics/utils/callbacks/__init__.py,sha256=hzL63Rce6VkZhP4Lcim9LKjadixaQG86nKqPhk7IkS0,242
|
@@ -265,8 +265,8 @@ ultralytics/utils/callbacks/neptune.py,sha256=yYUgEgSv6L39sSev6vjwhAWU3DlPDsbSDV
|
|
265
265
|
ultralytics/utils/callbacks/raytune.py,sha256=A8amUGpux7dYES-L1iSeMoMXBySGWCD1aUqT7vcG-pU,1284
|
266
266
|
ultralytics/utils/callbacks/tensorboard.py,sha256=jgYnym3cUQFAgN1GzTyO7l3jINtfAh8zhrllDvnLuVQ,5339
|
267
267
|
ultralytics/utils/callbacks/wb.py,sha256=iDRFXI4IIDm8R5OI89DMTmjs8aHLo1HRCLkOFKdaMG4,7507
|
268
|
-
dgenerate_ultralytics_headless-8.3.
|
269
|
-
dgenerate_ultralytics_headless-8.3.
|
270
|
-
dgenerate_ultralytics_headless-8.3.
|
271
|
-
dgenerate_ultralytics_headless-8.3.
|
272
|
-
dgenerate_ultralytics_headless-8.3.
|
268
|
+
dgenerate_ultralytics_headless-8.3.143.dist-info/METADATA,sha256=wqUmvH5KB1dRscjqNnjTtPutbgrLN7uYxR4GhovGWfw,38296
|
269
|
+
dgenerate_ultralytics_headless-8.3.143.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
270
|
+
dgenerate_ultralytics_headless-8.3.143.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
|
271
|
+
dgenerate_ultralytics_headless-8.3.143.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
|
272
|
+
dgenerate_ultralytics_headless-8.3.143.dist-info/RECORD,,
|
tests/test_cuda.py
CHANGED
@@ -22,7 +22,7 @@ if CUDA_IS_AVAILABLE:
|
|
22
22
|
else:
|
23
23
|
gpu_info = GPUInfo()
|
24
24
|
gpu_info.print_status()
|
25
|
-
idle_gpus = gpu_info.select_idle_gpu(count=2,
|
25
|
+
idle_gpus = gpu_info.select_idle_gpu(count=2, min_memory_fraction=0.2)
|
26
26
|
if idle_gpus:
|
27
27
|
DEVICES = idle_gpus
|
28
28
|
|
tests/test_solutions.py
CHANGED
@@ -205,12 +205,12 @@ def test_solution(name, solution_class, needs_frame_count, video, kwargs):
|
|
205
205
|
)
|
206
206
|
|
207
207
|
|
208
|
-
@pytest.mark.slow
|
209
208
|
@pytest.mark.skipif(checks.IS_PYTHON_3_8, reason="Disabled due to unsupported CLIP dependencies.")
|
210
209
|
@pytest.mark.skipif(IS_RASPBERRYPI, reason="Disabled due to slow performance on Raspberry Pi.")
|
211
210
|
def test_similarity_search():
|
212
211
|
"""Test similarity search solution."""
|
213
|
-
|
212
|
+
safe_download(f"{ASSETS_URL}/4-imgs-similaritysearch.zip", dir=TMP) # 4 dog images for testing in a zip file.
|
213
|
+
searcher = solutions.VisualAISearch(data=str(TMP / "4-imgs-similaritysearch"))
|
214
214
|
_ = searcher("a dog sitting on a bench") # Returns the results in format "- img name | similarity score"
|
215
215
|
|
216
216
|
|
@@ -245,7 +245,7 @@ def test_analytics_graph_not_supported():
|
|
245
245
|
"""Test that unsupported analytics type raises ModuleNotFoundError."""
|
246
246
|
try:
|
247
247
|
analytics = solutions.Analytics(analytics_type="test") # 'test' is unsupported
|
248
|
-
analytics.process(im0=
|
248
|
+
analytics.process(im0=np.zeros((640, 480, 3), dtype=np.uint8), frame_number=0)
|
249
249
|
assert False, "Expected ModuleNotFoundError for unsupported chart type"
|
250
250
|
except ModuleNotFoundError as e:
|
251
251
|
assert "test chart is not supported" in str(e)
|
@@ -297,6 +297,7 @@ def test_streamlit_handle_video_upload_creates_file():
|
|
297
297
|
os.remove("ultralytics.mp4")
|
298
298
|
|
299
299
|
|
300
|
+
@pytest.mark.skipif(checks.IS_PYTHON_3_8, reason="Disabled due to unsupported CLIP dependencies.")
|
300
301
|
@pytest.mark.skipif(IS_RASPBERRYPI, reason="Disabled due to slow performance on Raspberry Pi.")
|
301
302
|
def test_similarity_search_app_init():
|
302
303
|
"""Test SearchApp initializes with required attributes."""
|
ultralytics/__init__.py
CHANGED
ultralytics/cfg/__init__.py
CHANGED
@@ -108,8 +108,8 @@ CLI_HELP_MSG = f"""
|
|
108
108
|
|
109
109
|
yolo TASK MODE ARGS
|
110
110
|
|
111
|
-
Where TASK (optional) is one of {TASKS}
|
112
|
-
MODE (required) is one of {MODES}
|
111
|
+
Where TASK (optional) is one of {list(TASKS)}
|
112
|
+
MODE (required) is one of {list(MODES)}
|
113
113
|
ARGS (optional) are any number of custom 'arg=value' pairs like 'imgsz=320' that override defaults.
|
114
114
|
See all ARGS at https://docs.ultralytics.com/usage/cfg or with 'yolo cfg'
|
115
115
|
|
@@ -909,9 +909,9 @@ def entrypoint(debug: str = "") -> None:
|
|
909
909
|
mode = overrides.get("mode")
|
910
910
|
if mode is None:
|
911
911
|
mode = DEFAULT_CFG.mode or "predict"
|
912
|
-
LOGGER.warning(f"'mode' argument is missing. Valid modes are {MODES}. Using default 'mode={mode}'.")
|
912
|
+
LOGGER.warning(f"'mode' argument is missing. Valid modes are {list(MODES)}. Using default 'mode={mode}'.")
|
913
913
|
elif mode not in MODES:
|
914
|
-
raise ValueError(f"Invalid 'mode={mode}'. Valid modes are {MODES}.\n{CLI_HELP_MSG}")
|
914
|
+
raise ValueError(f"Invalid 'mode={mode}'. Valid modes are {list(MODES)}.\n{CLI_HELP_MSG}")
|
915
915
|
|
916
916
|
# Task
|
917
917
|
task = overrides.pop("task", None)
|
@@ -919,11 +919,11 @@ def entrypoint(debug: str = "") -> None:
|
|
919
919
|
if task not in TASKS:
|
920
920
|
if task == "track":
|
921
921
|
LOGGER.warning(
|
922
|
-
f"invalid 'task=track', setting 'task=detect' and 'mode=track'. Valid tasks are {TASKS}.\n{CLI_HELP_MSG}."
|
922
|
+
f"invalid 'task=track', setting 'task=detect' and 'mode=track'. Valid tasks are {list(TASKS)}.\n{CLI_HELP_MSG}."
|
923
923
|
)
|
924
924
|
task, mode = "detect", "track"
|
925
925
|
else:
|
926
|
-
raise ValueError(f"Invalid 'task={task}'. Valid tasks are {TASKS}.\n{CLI_HELP_MSG}")
|
926
|
+
raise ValueError(f"Invalid 'task={task}'. Valid tasks are {list(TASKS)}.\n{CLI_HELP_MSG}")
|
927
927
|
if "model" not in overrides:
|
928
928
|
overrides["model"] = TASK2MODEL[task]
|
929
929
|
|
@@ -622,21 +622,18 @@ names:
|
|
622
622
|
download: |
|
623
623
|
import warnings
|
624
624
|
|
625
|
-
from ultralytics.utils import LOGGER, SETTINGS, Path
|
626
|
-
from ultralytics.utils.checks import check_requirements
|
625
|
+
from ultralytics.utils import LOGGER, SETTINGS, Path
|
626
|
+
from ultralytics.utils.checks import check_requirements
|
627
627
|
|
628
628
|
check_requirements("fiftyone")
|
629
|
-
|
630
|
-
# Ubuntu>=22.04 patch https://github.com/voxel51/fiftyone/issues/2961#issuecomment-1666519347
|
631
|
-
check_requirements("fiftyone-db-ubuntu2204")
|
632
|
-
|
629
|
+
|
633
630
|
import fiftyone as fo
|
634
631
|
import fiftyone.zoo as foz
|
635
632
|
|
636
633
|
name = "open-images-v7"
|
637
634
|
fo.config.dataset_zoo_dir = Path(SETTINGS["datasets_dir"]) / "fiftyone" / name
|
638
635
|
fraction = 1.0 # fraction of full dataset to use
|
639
|
-
LOGGER.warning("
|
636
|
+
LOGGER.warning("Open Images V7 dataset requires at least **561 GB of free space. Starting download...")
|
640
637
|
for split in "train", "validation": # 1743042 train, 41620 val images
|
641
638
|
train = split == "train"
|
642
639
|
|
ultralytics/engine/model.py
CHANGED
@@ -79,7 +79,7 @@ class Model(torch.nn.Module):
|
|
79
79
|
|
80
80
|
def __init__(
|
81
81
|
self,
|
82
|
-
model: Union[str, Path] = "yolo11n.pt",
|
82
|
+
model: Union[str, Path, "Model"] = "yolo11n.pt",
|
83
83
|
task: str = None,
|
84
84
|
verbose: bool = False,
|
85
85
|
) -> None:
|
@@ -92,8 +92,8 @@ class Model(torch.nn.Module):
|
|
92
92
|
prediction, or export.
|
93
93
|
|
94
94
|
Args:
|
95
|
-
model (str | Path): Path or name of the model to load or create. Can be a local file path, a
|
96
|
-
model name from Ultralytics HUB,
|
95
|
+
model (str | Path | Model): Path or name of the model to load or create. Can be a local file path, a
|
96
|
+
model name from Ultralytics HUB, a Triton Server model, or an already initialized Model instance.
|
97
97
|
task (str | None): The task type associated with the YOLO model, specifying its application domain.
|
98
98
|
verbose (bool): If True, enables verbose output during the model's initialization and subsequent
|
99
99
|
operations.
|
@@ -108,6 +108,9 @@ class Model(torch.nn.Module):
|
|
108
108
|
>>> model = Model("path/to/model.yaml", task="detect")
|
109
109
|
>>> model = Model("hub_model", verbose=True)
|
110
110
|
"""
|
111
|
+
if isinstance(model, Model):
|
112
|
+
self.__dict__ = model.__dict__ # accepts an already initialized Model
|
113
|
+
return
|
111
114
|
super().__init__()
|
112
115
|
self.callbacks = callbacks.get_default_callbacks()
|
113
116
|
self.predictor = None # reuse predictor
|
ultralytics/engine/results.py
CHANGED
@@ -57,7 +57,7 @@ class ClassificationPredictor(BasePredictor):
|
|
57
57
|
super().setup_source(source)
|
58
58
|
updated = (
|
59
59
|
self.model.model.transforms.transforms[0].size != max(self.imgsz)
|
60
|
-
if hasattr(self.model.model, "transforms")
|
60
|
+
if hasattr(self.model.model, "transforms") and hasattr(self.model.model.transforms.transforms[0], "size")
|
61
61
|
else True
|
62
62
|
)
|
63
63
|
self.transforms = self.model.model.transforms if not updated else classify_transforms(self.imgsz)
|
ultralytics/models/yolo/model.py
CHANGED
@@ -39,7 +39,7 @@ class YOLO(Model):
|
|
39
39
|
>>> model = YOLO("yolo11n.pt") # load a pretrained YOLOv11n detection model
|
40
40
|
>>> model = YOLO("yolo11n-seg.pt") # load a pretrained YOLO11n segmentation model
|
41
41
|
"""
|
42
|
-
path = Path(model)
|
42
|
+
path = Path(model if isinstance(model, (str, Path)) else "")
|
43
43
|
if "-world" in path.stem and path.suffix in {".pt", ".yaml", ".yml"}: # if YOLOWorld PyTorch model
|
44
44
|
new_instance = YOLOWorld(path, verbose=verbose)
|
45
45
|
self.__class__ = type(new_instance)
|
@@ -51,6 +51,12 @@ class YOLO(Model):
|
|
51
51
|
else:
|
52
52
|
# Continue with default YOLO initialization
|
53
53
|
super().__init__(model=model, task=task, verbose=verbose)
|
54
|
+
if hasattr(self.model, "model") and "RTDETR" in self.model.model[-1]._get_name(): # if RTDETR head
|
55
|
+
from ultralytics import RTDETR
|
56
|
+
|
57
|
+
new_instance = RTDETR(self)
|
58
|
+
self.__class__ = type(new_instance)
|
59
|
+
self.__dict__ = new_instance.__dict__
|
54
60
|
|
55
61
|
@property
|
56
62
|
def task_map(self):
|
@@ -118,7 +118,8 @@ class DistanceCalculation(BaseSolution):
|
|
118
118
|
self.centroids = [] # Reset centroids for next frame
|
119
119
|
plot_im = annotator.result()
|
120
120
|
self.display_output(plot_im) # Display output with base class function
|
121
|
-
|
121
|
+
if self.CFG.get("show") and self.env_check:
|
122
|
+
cv2.setMouseCallback("Ultralytics Solutions", self.mouse_event_for_distance)
|
122
123
|
|
123
124
|
# Return SolutionResults with processed image and calculated metrics
|
124
125
|
return SolutionResults(plot_im=plot_im, pixels_distance=pixels_distance, total_tracks=len(self.track_ids))
|
@@ -160,7 +160,7 @@ class ObjectCounter(BaseSolution):
|
|
160
160
|
self.annotator = SolutionAnnotator(im0, line_width=self.line_width) # Initialize annotator
|
161
161
|
|
162
162
|
is_obb = getattr(self.tracks[0], "obb", None) is not None # True if OBB results exist
|
163
|
-
if is_obb:
|
163
|
+
if is_obb and self.track_data and self.track_data.id is not None:
|
164
164
|
self.boxes = self.track_data.xyxyxyxy.reshape(-1, 4, 2).cpu()
|
165
165
|
|
166
166
|
self.annotator.draw_region(
|
@@ -170,10 +170,8 @@ class ObjectCounter(BaseSolution):
|
|
170
170
|
# Iterate over bounding boxes, track ids and classes index
|
171
171
|
for box, track_id, cls, conf in zip(self.boxes, self.track_ids, self.clss, self.confs):
|
172
172
|
# Draw bounding box and counting region
|
173
|
-
self.annotator.box_label(
|
174
|
-
|
175
|
-
)
|
176
|
-
self.store_tracking_history(track_id, box, is_obb=is_obb) # Store track history
|
173
|
+
self.annotator.box_label(box, label=self.adjust_box_label(cls, conf, track_id), color=colors(cls, True))
|
174
|
+
self.store_tracking_history(track_id, box) # Store track history
|
177
175
|
|
178
176
|
# Store previous position of track for object counting
|
179
177
|
prev_position = None
|
@@ -67,9 +67,15 @@ class ObjectCropper(BaseSolution):
|
|
67
67
|
>>> results = cropper.process(frame)
|
68
68
|
>>> print(f"Total cropped objects: {results.total_crop_objects}")
|
69
69
|
"""
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
with self.profilers[0]:
|
71
|
+
results = self.model.predict(
|
72
|
+
im0,
|
73
|
+
classes=self.classes,
|
74
|
+
conf=self.conf,
|
75
|
+
iou=self.iou,
|
76
|
+
device=self.CFG["device"],
|
77
|
+
verbose=False,
|
78
|
+
)[0]
|
73
79
|
|
74
80
|
for box in results.boxes:
|
75
81
|
self.crop_idx += 1
|
@@ -8,7 +8,7 @@ import numpy as np
|
|
8
8
|
|
9
9
|
from ultralytics import YOLO
|
10
10
|
from ultralytics.solutions.config import SolutionConfig
|
11
|
-
from ultralytics.utils import ASSETS_URL, LOGGER
|
11
|
+
from ultralytics.utils import ASSETS_URL, LOGGER, ops
|
12
12
|
from ultralytics.utils.checks import check_imshow, check_requirements
|
13
13
|
from ultralytics.utils.plotting import Annotator
|
14
14
|
|
@@ -75,6 +75,7 @@ class BaseSolution:
|
|
75
75
|
self.track_line = None
|
76
76
|
self.masks = None
|
77
77
|
self.r_s = None
|
78
|
+
self.frame_no = -1 # Only for logging
|
78
79
|
|
79
80
|
self.LOGGER.info(f"Ultralytics Solutions: ✅ {self.CFG}")
|
80
81
|
self.region = self.CFG["region"] # Store region data for other classes usage
|
@@ -88,9 +89,10 @@ class BaseSolution:
|
|
88
89
|
self.classes = self.CFG["classes"]
|
89
90
|
self.show_conf = self.CFG["show_conf"]
|
90
91
|
self.show_labels = self.CFG["show_labels"]
|
92
|
+
self.device = self.CFG["device"]
|
91
93
|
|
92
94
|
self.track_add_args = { # Tracker additional arguments for advance configuration
|
93
|
-
k: self.CFG[k] for k in ["iou", "conf", "device", "max_det", "half", "tracker"
|
95
|
+
k: self.CFG[k] for k in ["iou", "conf", "device", "max_det", "half", "tracker"]
|
94
96
|
} # verbose must be passed to track method; setting it False in YOLO still logs the track information.
|
95
97
|
|
96
98
|
if is_cli and self.CFG["source"] is None:
|
@@ -105,6 +107,11 @@ class BaseSolution:
|
|
105
107
|
self.env_check = check_imshow(warn=True)
|
106
108
|
self.track_history = defaultdict(list)
|
107
109
|
|
110
|
+
self.profilers = (
|
111
|
+
ops.Profile(device=self.device), # track
|
112
|
+
ops.Profile(device=self.device), # solution
|
113
|
+
)
|
114
|
+
|
108
115
|
def adjust_box_label(self, cls, conf, track_id=None):
|
109
116
|
"""
|
110
117
|
Generates a formatted label for a bounding box.
|
@@ -136,7 +143,10 @@ class BaseSolution:
|
|
136
143
|
>>> frame = cv2.imread("path/to/image.jpg")
|
137
144
|
>>> solution.extract_tracks(frame)
|
138
145
|
"""
|
139
|
-
|
146
|
+
with self.profilers[0]:
|
147
|
+
self.tracks = self.model.track(
|
148
|
+
source=im0, persist=True, classes=self.classes, verbose=False, **self.track_add_args
|
149
|
+
)
|
140
150
|
self.track_data = self.tracks[0].obb or self.tracks[0].boxes # Extract tracks for OBB or object detection
|
141
151
|
|
142
152
|
if self.track_data and self.track_data.id is not None:
|
@@ -148,7 +158,7 @@ class BaseSolution:
|
|
148
158
|
self.LOGGER.warning("no tracks found!")
|
149
159
|
self.boxes, self.clss, self.track_ids, self.confs = [], [], [], []
|
150
160
|
|
151
|
-
def store_tracking_history(self, track_id, box
|
161
|
+
def store_tracking_history(self, track_id, box):
|
152
162
|
"""
|
153
163
|
Stores the tracking history of an object.
|
154
164
|
|
@@ -158,7 +168,6 @@ class BaseSolution:
|
|
158
168
|
Args:
|
159
169
|
track_id (int): The unique identifier for the tracked object.
|
160
170
|
box (List[float]): The bounding box coordinates of the object in the format [x1, y1, x2, y2].
|
161
|
-
is_obb (bool): True if OBB model is used (applies to object counting only).
|
162
171
|
|
163
172
|
Examples:
|
164
173
|
>>> solution = BaseSolution()
|
@@ -166,7 +175,7 @@ class BaseSolution:
|
|
166
175
|
"""
|
167
176
|
# Store tracking history
|
168
177
|
self.track_line = self.track_history[track_id]
|
169
|
-
self.track_line.append(tuple(box.mean(dim=0)) if
|
178
|
+
self.track_line.append(tuple(box.mean(dim=0)) if box.numel() > 4 else (box[:4:2].mean(), box[1:4:2].mean()))
|
170
179
|
if len(self.track_line) > 30:
|
171
180
|
self.track_line.pop(0)
|
172
181
|
|
@@ -209,9 +218,20 @@ class BaseSolution:
|
|
209
218
|
|
210
219
|
def __call__(self, *args, **kwargs):
|
211
220
|
"""Allow instances to be called like a function with flexible arguments."""
|
212
|
-
|
213
|
-
|
214
|
-
|
221
|
+
with self.profilers[1]:
|
222
|
+
result = self.process(*args, **kwargs) # Call the subclass-specific process method
|
223
|
+
track_or_predict = "predict" if type(self).__name__ == "ObjectCropper" else "track"
|
224
|
+
track_or_predict_speed = self.profilers[0].dt * 1e3
|
225
|
+
solution_speed = (self.profilers[1].dt - self.profilers[0].dt) * 1e3 # solution time = process - track
|
226
|
+
result.speed = {track_or_predict: track_or_predict_speed, "solution": solution_speed}
|
227
|
+
if self.CFG["verbose"]:
|
228
|
+
self.frame_no += 1
|
229
|
+
LOGGER.info(
|
230
|
+
f"{self.frame_no}: {result.plot_im.shape[0]}x{result.plot_im.shape[1]} {solution_speed:.1f}ms\n"
|
231
|
+
f"Speed: {track_or_predict_speed:.1f}ms {track_or_predict}, "
|
232
|
+
f"{solution_speed:.1f}ms solution per image at shape "
|
233
|
+
f"(1, {getattr(self.model, 'ch', 3)}, {result.plot_im.shape[0]}, {result.plot_im.shape[1]})\n"
|
234
|
+
)
|
215
235
|
return result
|
216
236
|
|
217
237
|
|
@@ -703,8 +723,9 @@ class SolutionResults:
|
|
703
723
|
self.email_sent = False
|
704
724
|
self.total_tracks = 0
|
705
725
|
self.region_counts = {}
|
706
|
-
self.speed_dict = {}
|
726
|
+
self.speed_dict = {} # for speed estimation
|
707
727
|
self.total_crop_objects = 0
|
728
|
+
self.speed = {}
|
708
729
|
|
709
730
|
# Override with user-defined values
|
710
731
|
self.__dict__.update(kwargs)
|
@@ -721,4 +742,4 @@ class SolutionResults:
|
|
721
742
|
for k, v in self.__dict__.items()
|
722
743
|
if k != "plot_im" and v not in [None, {}, 0, 0.0, False] # Exclude `plot_im` explicitly
|
723
744
|
}
|
724
|
-
return
|
745
|
+
return ", ".join(f"{k}={v}" for k, v in attrs.items())
|
ultralytics/utils/autodevice.py
CHANGED
@@ -116,13 +116,13 @@ class GPUInfo:
|
|
116
116
|
|
117
117
|
LOGGER.info(f"{'-' * len(hdr)}\n")
|
118
118
|
|
119
|
-
def select_idle_gpu(self, count=1,
|
119
|
+
def select_idle_gpu(self, count=1, min_memory_fraction=0):
|
120
120
|
"""
|
121
121
|
Selects the 'count' most idle GPUs based on utilization and free memory.
|
122
122
|
|
123
123
|
Args:
|
124
124
|
count (int): The number of idle GPUs to select. Defaults to 1.
|
125
|
-
|
125
|
+
min_memory_fraction (float): Minimum free memory required (fraction). Defaults to 0.
|
126
126
|
|
127
127
|
Returns:
|
128
128
|
(list[int]): Indices of the selected GPUs, sorted by idleness.
|
@@ -131,7 +131,8 @@ class GPUInfo:
|
|
131
131
|
Returns fewer than 'count' if not enough qualify or exist.
|
132
132
|
Returns basic CUDA indices if NVML fails. Empty list if no GPUs found.
|
133
133
|
"""
|
134
|
-
|
134
|
+
assert min_memory_fraction <= 1.0, f"min_memory_fraction must be <= 1.0, got {min_memory_fraction}"
|
135
|
+
LOGGER.info(f"Searching for {count} idle GPUs with >= {min_memory_fraction * 100:.1f}% free memory...")
|
135
136
|
|
136
137
|
if count <= 0:
|
137
138
|
return []
|
@@ -145,7 +146,8 @@ class GPUInfo:
|
|
145
146
|
eligible_gpus = [
|
146
147
|
gpu
|
147
148
|
for gpu in self.gpu_stats
|
148
|
-
if gpu.get("memory_free",
|
149
|
+
if gpu.get("memory_free", 0) / gpu.get("memory_total", 1) >= min_memory_fraction
|
150
|
+
and gpu.get("utilization", -1) != -1
|
149
151
|
]
|
150
152
|
eligible_gpus.sort(key=lambda x: (x.get("utilization", 101), -x.get("memory_free", 0)))
|
151
153
|
|
@@ -155,19 +157,19 @@ class GPUInfo:
|
|
155
157
|
if selected:
|
156
158
|
LOGGER.info(f"Selected idle CUDA devices {selected}")
|
157
159
|
else:
|
158
|
-
LOGGER.warning(f"No GPUs met criteria (Util != -1, Free Mem >= {
|
160
|
+
LOGGER.warning(f"No GPUs met criteria (Util != -1, Free Mem >= {min_memory_fraction * 100:.1f}%).")
|
159
161
|
|
160
162
|
return selected
|
161
163
|
|
162
164
|
|
163
165
|
if __name__ == "__main__":
|
164
|
-
|
166
|
+
required_free_mem_fraction = 0.2 # Require 20% free VRAM
|
165
167
|
num_gpus_to_select = 1
|
166
168
|
|
167
169
|
gpu_info = GPUInfo()
|
168
170
|
gpu_info.print_status()
|
169
171
|
|
170
|
-
selected = gpu_info.select_idle_gpu(count=num_gpus_to_select,
|
172
|
+
selected = gpu_info.select_idle_gpu(count=num_gpus_to_select, min_memory_fraction=required_free_mem_fraction)
|
171
173
|
if selected:
|
172
174
|
print(f"\n==> Using selected GPU indices: {selected}")
|
173
175
|
devices = [f"cuda:{idx}" for idx in selected]
|
ultralytics/utils/loss.py
CHANGED
@@ -613,8 +613,7 @@ class v8ClassificationLoss:
|
|
613
613
|
"""Compute the classification loss between predictions and true labels."""
|
614
614
|
preds = preds[1] if isinstance(preds, (list, tuple)) else preds
|
615
615
|
loss = F.cross_entropy(preds, batch["cls"], reduction="mean")
|
616
|
-
|
617
|
-
return loss, loss_items
|
616
|
+
return loss, loss.detach()
|
618
617
|
|
619
618
|
|
620
619
|
class v8OBBLoss(v8DetectionLoss):
|
ultralytics/utils/plotting.py
CHANGED
@@ -278,7 +278,7 @@ class Annotator:
|
|
278
278
|
else:
|
279
279
|
return txt_color
|
280
280
|
|
281
|
-
def box_label(self, box, label="", color=(128, 128, 128), txt_color=(255, 255, 255)
|
281
|
+
def box_label(self, box, label="", color=(128, 128, 128), txt_color=(255, 255, 255)):
|
282
282
|
"""
|
283
283
|
Draw a bounding box on an image with a given label.
|
284
284
|
|
@@ -287,7 +287,6 @@ class Annotator:
|
|
287
287
|
label (str, optional): The text label to be displayed.
|
288
288
|
color (tuple, optional): The background color of the rectangle (B, G, R).
|
289
289
|
txt_color (tuple, optional): The color of the text (R, G, B).
|
290
|
-
rotated (bool, optional): Whether the task is oriented bounding box detection.
|
291
290
|
|
292
291
|
Examples:
|
293
292
|
>>> from ultralytics.utils.plotting import Annotator
|
@@ -298,13 +297,13 @@ class Annotator:
|
|
298
297
|
txt_color = self.get_txt_color(color, txt_color)
|
299
298
|
if isinstance(box, torch.Tensor):
|
300
299
|
box = box.tolist()
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
300
|
+
|
301
|
+
multi_points = isinstance(box[0], list) # multiple points with shape (n, 2)
|
302
|
+
p1 = [int(b) for b in box[0]] if multi_points else (int(box[0]), int(box[1]))
|
303
|
+
if self.pil:
|
304
|
+
self.draw.polygon(
|
305
|
+
[tuple(b) for b in box], width=self.lw, outline=color
|
306
|
+
) if multi_points else self.draw.rectangle(box, width=self.lw, outline=color)
|
308
307
|
if label:
|
309
308
|
w, h = self.font.getsize(label) # text width, height
|
310
309
|
outside = p1[1] >= h # label fits outside box
|
@@ -317,12 +316,11 @@ class Annotator:
|
|
317
316
|
# self.draw.text([box[0], box[1]], label, fill=txt_color, font=self.font, anchor='ls') # for PIL>8.0
|
318
317
|
self.draw.text((p1[0], p1[1] - h if outside else p1[1]), label, fill=txt_color, font=self.font)
|
319
318
|
else: # cv2
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
cv2.rectangle(self.im, p1, p2, color, thickness=self.lw, lineType=cv2.LINE_AA)
|
319
|
+
cv2.polylines(
|
320
|
+
self.im, [np.asarray(box, dtype=int)], True, color, self.lw
|
321
|
+
) if multi_points else cv2.rectangle(
|
322
|
+
self.im, p1, (int(box[2]), int(box[3])), color, thickness=self.lw, lineType=cv2.LINE_AA
|
323
|
+
)
|
326
324
|
if label:
|
327
325
|
w, h = cv2.getTextSize(label, 0, fontScale=self.sf, thickness=self.tf)[0] # text width, height
|
328
326
|
h += 3 # add pixels to pad text
|
@@ -750,7 +748,7 @@ def plot_images(
|
|
750
748
|
c = names.get(c, c) if names else c
|
751
749
|
if labels or conf[j] > conf_thres:
|
752
750
|
label = f"{c}" if labels else f"{c} {conf[j]:.1f}"
|
753
|
-
annotator.box_label(box, label, color=color
|
751
|
+
annotator.box_label(box, label, color=color)
|
754
752
|
|
755
753
|
elif len(classes):
|
756
754
|
for c in classes:
|
ultralytics/utils/tal.py
CHANGED
@@ -21,7 +21,6 @@ class TaskAlignedAssigner(nn.Module):
|
|
21
21
|
Attributes:
|
22
22
|
topk (int): The number of top candidates to consider.
|
23
23
|
num_classes (int): The number of object classes.
|
24
|
-
bg_idx (int): Background class index.
|
25
24
|
alpha (float): The alpha parameter for the classification component of the task-aligned metric.
|
26
25
|
beta (float): The beta parameter for the localization component of the task-aligned metric.
|
27
26
|
eps (float): A small value to prevent division by zero.
|
@@ -32,7 +31,6 @@ class TaskAlignedAssigner(nn.Module):
|
|
32
31
|
super().__init__()
|
33
32
|
self.topk = topk
|
34
33
|
self.num_classes = num_classes
|
35
|
-
self.bg_idx = num_classes
|
36
34
|
self.alpha = alpha
|
37
35
|
self.beta = beta
|
38
36
|
self.eps = eps
|
@@ -66,7 +64,7 @@ class TaskAlignedAssigner(nn.Module):
|
|
66
64
|
|
67
65
|
if self.n_max_boxes == 0:
|
68
66
|
return (
|
69
|
-
torch.full_like(pd_scores[..., 0], self.
|
67
|
+
torch.full_like(pd_scores[..., 0], self.num_classes),
|
70
68
|
torch.zeros_like(pd_bboxes),
|
71
69
|
torch.zeros_like(pd_scores),
|
72
70
|
torch.zeros_like(pd_scores[..., 0]),
|
@@ -193,7 +191,7 @@ class TaskAlignedAssigner(nn.Module):
|
|
193
191
|
"""
|
194
192
|
return bbox_iou(gt_bboxes, pd_bboxes, xywh=False, CIoU=True).squeeze(-1).clamp_(0)
|
195
193
|
|
196
|
-
def select_topk_candidates(self, metrics,
|
194
|
+
def select_topk_candidates(self, metrics, topk_mask=None):
|
197
195
|
"""
|
198
196
|
Select the top-k candidates based on the given metrics.
|
199
197
|
|
@@ -201,7 +199,6 @@ class TaskAlignedAssigner(nn.Module):
|
|
201
199
|
metrics (torch.Tensor): A tensor of shape (b, max_num_obj, h*w), where b is the batch size,
|
202
200
|
max_num_obj is the maximum number of objects, and h*w represents the
|
203
201
|
total number of anchor points.
|
204
|
-
largest (bool): If True, select the largest values; otherwise, select the smallest values.
|
205
202
|
topk_mask (torch.Tensor): An optional boolean tensor of shape (b, max_num_obj, topk), where
|
206
203
|
topk is the number of top candidates to consider. If not provided,
|
207
204
|
the top-k values are automatically computed based on the given metrics.
|
@@ -210,7 +207,7 @@ class TaskAlignedAssigner(nn.Module):
|
|
210
207
|
(torch.Tensor): A tensor of shape (b, max_num_obj, h*w) containing the selected top-k candidates.
|
211
208
|
"""
|
212
209
|
# (b, max_num_obj, topk)
|
213
|
-
topk_metrics, topk_idxs = torch.topk(metrics, self.topk, dim=-1, largest=
|
210
|
+
topk_metrics, topk_idxs = torch.topk(metrics, self.topk, dim=-1, largest=True)
|
214
211
|
if topk_mask is None:
|
215
212
|
topk_mask = (topk_metrics.max(-1, keepdim=True)[0] > self.eps).expand_as(topk_idxs)
|
216
213
|
# (b, max_num_obj, topk)
|
ultralytics/utils/torch_utils.py
CHANGED
@@ -174,7 +174,7 @@ def select_device(device="", batch=0, newline=False, verbose=True):
|
|
174
174
|
|
175
175
|
# Replace each -1 with a selected GPU or remove it
|
176
176
|
parts = device.split(",")
|
177
|
-
selected = GPUInfo().select_idle_gpu(count=parts.count("-1"),
|
177
|
+
selected = GPUInfo().select_idle_gpu(count=parts.count("-1"), min_memory_fraction=0.2)
|
178
178
|
for i in range(len(parts)):
|
179
179
|
if parts[i] == "-1":
|
180
180
|
parts[i] = str(selected.pop(0)) if selected else ""
|
File without changes
|
File without changes
|
File without changes
|