dgenerate-ultralytics-headless 8.3.218__py3-none-any.whl → 8.3.220__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.218.dist-info → dgenerate_ultralytics_headless-8.3.220.dist-info}/METADATA +1 -1
- {dgenerate_ultralytics_headless-8.3.218.dist-info → dgenerate_ultralytics_headless-8.3.220.dist-info}/RECORD +16 -16
- tests/test_cli.py +8 -1
- tests/test_exports.py +37 -9
- ultralytics/__init__.py +1 -1
- ultralytics/cfg/default.yaml +1 -1
- ultralytics/engine/exporter.py +57 -4
- ultralytics/engine/predictor.py +1 -0
- ultralytics/models/fastsam/predict.py +10 -16
- ultralytics/nn/autobackend.py +27 -0
- ultralytics/solutions/similarity_search.py +2 -2
- ultralytics/utils/torch_utils.py +1 -0
- {dgenerate_ultralytics_headless-8.3.218.dist-info → dgenerate_ultralytics_headless-8.3.220.dist-info}/WHEEL +0 -0
- {dgenerate_ultralytics_headless-8.3.218.dist-info → dgenerate_ultralytics_headless-8.3.220.dist-info}/entry_points.txt +0 -0
- {dgenerate_ultralytics_headless-8.3.218.dist-info → dgenerate_ultralytics_headless-8.3.220.dist-info}/licenses/LICENSE +0 -0
- {dgenerate_ultralytics_headless-8.3.218.dist-info → dgenerate_ultralytics_headless-8.3.220.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.220
|
|
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,19 +1,19 @@
|
|
|
1
|
-
dgenerate_ultralytics_headless-8.3.
|
|
1
|
+
dgenerate_ultralytics_headless-8.3.220.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
|
|
2
2
|
tests/__init__.py,sha256=b4KP5_q-2IO8Br8YHOSLYnn7IwZS81l_vfEF2YPa2lM,894
|
|
3
3
|
tests/conftest.py,sha256=LXtQJcFNWPGuzauTGkiXgsvVC3llJKfg22WcmhRzuQc,2593
|
|
4
|
-
tests/test_cli.py,sha256=
|
|
4
|
+
tests/test_cli.py,sha256=ubqV7OnMWRQwPPpXjuLB5CHM1jGnSxVUZnRTWrjU4XM,5843
|
|
5
5
|
tests/test_cuda.py,sha256=6zUSwu3xaYiO3RRNyDkNsuyeq47b1e9f6JNhPZVeDL4,8142
|
|
6
6
|
tests/test_engine.py,sha256=80S2SwcybVZUKNyAXQAR763rRIQUVly2lmP096azoz0,5730
|
|
7
|
-
tests/test_exports.py,sha256=
|
|
7
|
+
tests/test_exports.py,sha256=OMLio2uUhyqo8D8qB5xUwmk7Po2rMeAACRc8WYoxbj4,13147
|
|
8
8
|
tests/test_integrations.py,sha256=ehRcYMpGvUI3KvgsaT1pkN1rXkr7tDSlYYMqIcXyGbg,6220
|
|
9
9
|
tests/test_python.py,sha256=x2q5Wx3eOl32ymmr_4p6srz7ebO-O8zFttuerys_OWg,28083
|
|
10
10
|
tests/test_solutions.py,sha256=oaTz5BttPDIeHkQh9oEaw-O73L4iYDP3Lfe82V7DeKM,13416
|
|
11
|
-
ultralytics/__init__.py,sha256
|
|
11
|
+
ultralytics/__init__.py,sha256=g_DXetCe4xeG4X-3jr8k8TLL7RT7yMWRPPEPERc1Kck,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
|
|
15
15
|
ultralytics/cfg/__init__.py,sha256=WY1NG2sliRbhjkKkrp7Ps94My8kFe3CGDHMGGbSJtWM,39996
|
|
16
|
-
ultralytics/cfg/default.yaml,sha256=
|
|
16
|
+
ultralytics/cfg/default.yaml,sha256=KKENSHolDSto1HJVGjBvTXvz9ae-XMcYRzKrjU3QfZc,8912
|
|
17
17
|
ultralytics/cfg/datasets/Argoverse.yaml,sha256=J4ItoUlE_EiYTmp1DFKYHfbqHkj8j4wUtRJQhaMIlBM,3275
|
|
18
18
|
ultralytics/cfg/datasets/DOTAv1.5.yaml,sha256=VZ_KKFX0H2YvlFVJ8JHcLWYBZ2xiQ6Z-ROSTiKWpS7c,1211
|
|
19
19
|
ultralytics/cfg/datasets/DOTAv1.yaml,sha256=JrDuYcQ0JU9lJlCA-dCkMNko_jaj6MAVGHjsfjeZ_u0,1181
|
|
@@ -122,9 +122,9 @@ ultralytics/data/scripts/get_coco.sh,sha256=UuJpJeo3qQpTHVINeOpmP0NYmg8PhEFE3A8J
|
|
|
122
122
|
ultralytics/data/scripts/get_coco128.sh,sha256=qmRQl_hOKrsdHrTrnyQuFIH01oDz3lfaz138OgGfLt8,650
|
|
123
123
|
ultralytics/data/scripts/get_imagenet.sh,sha256=hr42H16bM47iT27rgS7MpEo-GeOZAYUQXgr0B2cwn48,1705
|
|
124
124
|
ultralytics/engine/__init__.py,sha256=lm6MckFYCPTbqIoX7w0s_daxdjNeBeKW6DXppv1-QUM,70
|
|
125
|
-
ultralytics/engine/exporter.py,sha256=
|
|
125
|
+
ultralytics/engine/exporter.py,sha256=IU5OjLwJcDQEUoWLGTo9gZJHj6KjKsvKCg0vhnwKi30,73662
|
|
126
126
|
ultralytics/engine/model.py,sha256=uX6cTFdlLllGRbz8Lr90IZGb4OrtMDIHQEg7DxUqwe8,53449
|
|
127
|
-
ultralytics/engine/predictor.py,sha256=
|
|
127
|
+
ultralytics/engine/predictor.py,sha256=ZQrx1Bz4X8aTgGjrOSdRSP7SCtQ05uqz6IitEan_Gyk,22813
|
|
128
128
|
ultralytics/engine/results.py,sha256=oHQdV_eIMvAU2qLCV7wG7iLifdfaLEgP80lDXB5ghkg,71490
|
|
129
129
|
ultralytics/engine/trainer.py,sha256=TCn_xzQG3r6XFZp3lCGhl9msLLASS2vK-T_O6DqdV8Y,44097
|
|
130
130
|
ultralytics/engine/tuner.py,sha256=8uiZ9DSYdjHmbhfiuzbMPw--1DLS3cpfZPeSzJ9dGEA,21664
|
|
@@ -137,7 +137,7 @@ ultralytics/hub/google/__init__.py,sha256=8o3RorFafO_DzlzImXnzNQXtyPM1k-CQ8tsWSf
|
|
|
137
137
|
ultralytics/models/__init__.py,sha256=DqQFFYJ4IQlqIDb61H1HzcnZU7SuHN-43bw94-l-YAQ,309
|
|
138
138
|
ultralytics/models/fastsam/__init__.py,sha256=HGJ8EKlBAsdF-e2aIwQLjSDAFI_r0yHR0A1gzrp4vqE,231
|
|
139
139
|
ultralytics/models/fastsam/model.py,sha256=vIdl536LUrefjqMFEJ-9UyK4Ta6p2ki2G_gn2DZ9X_Y,3438
|
|
140
|
-
ultralytics/models/fastsam/predict.py,sha256=
|
|
140
|
+
ultralytics/models/fastsam/predict.py,sha256=QoG9GnUKVNIDgxeVMIFSP3YbOOFcqVvaQiGaUiAoFzc,8664
|
|
141
141
|
ultralytics/models/fastsam/utils.py,sha256=yuCXB4CVjRx8lDf61DP8B6qMx7TVf7AynQvdWREeFco,884
|
|
142
142
|
ultralytics/models/fastsam/val.py,sha256=oLxB8vBKTfiT7eBbTzvpqq_xNSvDOjGdP1J7egHGsCA,2041
|
|
143
143
|
ultralytics/models/nas/__init__.py,sha256=wybeHZuAXMNeXMjKTbK55FZmXJkA4K9IozDeFM9OB-s,207
|
|
@@ -197,7 +197,7 @@ ultralytics/models/yolo/yoloe/train.py,sha256=qefvNNXDTOK1tO3va0kNHr8lE5QJkOlV8G
|
|
|
197
197
|
ultralytics/models/yolo/yoloe/train_seg.py,sha256=aCV7M8oQOvODFnU4piZdJh3tIrBJYAzZfRVRx1vRgxo,4956
|
|
198
198
|
ultralytics/models/yolo/yoloe/val.py,sha256=5Gd9EoFH0FmKKvWXBl4J7gBe9DVxIczN-s3ceHwdUDo,9458
|
|
199
199
|
ultralytics/nn/__init__.py,sha256=PJgOn2phQTTBR2P3s_JWvGeGXQpvw1znsumKow4tCuE,545
|
|
200
|
-
ultralytics/nn/autobackend.py,sha256=
|
|
200
|
+
ultralytics/nn/autobackend.py,sha256=M3UiPj6VMNF0E06q9KfIA2sbWL8ikbnclDDO6QWgOg4,42716
|
|
201
201
|
ultralytics/nn/tasks.py,sha256=r01JGRa9bgGdOHXycN6TSK30I_Ip4GHO9dZ8LtpkmYk,70846
|
|
202
202
|
ultralytics/nn/text_model.py,sha256=pHqnKe8UueR1MuwJcIE_IvrnYIlt68QL796xjcRJs2A,15275
|
|
203
203
|
ultralytics/nn/modules/__init__.py,sha256=BPMbEm1daI7Tuds3zph2_afAX7Gq1uAqK8BfiCfKTZs,3198
|
|
@@ -221,7 +221,7 @@ ultralytics/solutions/parking_management.py,sha256=DMPl1rd0TegTrUvrCM44_y-HZTx3D
|
|
|
221
221
|
ultralytics/solutions/queue_management.py,sha256=ks94mmPhuKHnkZcUPLEdEc462L0sfT1u9yOvObSYK3Y,4390
|
|
222
222
|
ultralytics/solutions/region_counter.py,sha256=KjU5nErQ_maNzchtS3Cu54PcGTf_yxaR8iBZwFRSPNI,6048
|
|
223
223
|
ultralytics/solutions/security_alarm.py,sha256=czEaMcy04q-iBkKqT_14d8H20CFB6zcKH_31nBGQnyw,6345
|
|
224
|
-
ultralytics/solutions/similarity_search.py,sha256=
|
|
224
|
+
ultralytics/solutions/similarity_search.py,sha256=K0jZt_2q9snaKk-adm8AvneFm5dBkMYxpkSNz0j9pr4,9674
|
|
225
225
|
ultralytics/solutions/solutions.py,sha256=syChH-uYq6YGspXflKJF96gNVnkxOLobkLM_ceMZI6Q,36042
|
|
226
226
|
ultralytics/solutions/speed_estimation.py,sha256=chg_tBuKFw3EnFiv_obNDaUXLAo-FypxC7gsDeB_VUI,5878
|
|
227
227
|
ultralytics/solutions/streamlit_inference.py,sha256=28p2fBTsCLtN7jOv4Q2Ppw3BHwhowsmWV5y82iXC8WU,13074
|
|
@@ -258,7 +258,7 @@ ultralytics/utils/ops.py,sha256=oJjEd1Ly9pYbQn0fO1V4OFRLr1BPJi3A7IXlXszEiVA,2705
|
|
|
258
258
|
ultralytics/utils/patches.py,sha256=0-2G4jXCIPnMonlft-cPcjfFcOXQS6ODwUDNUwanfg4,6541
|
|
259
259
|
ultralytics/utils/plotting.py,sha256=lWvjC_ojjWYca8atorCdJGlDCIph83NA7h7hlnfZx54,48342
|
|
260
260
|
ultralytics/utils/tal.py,sha256=7KQYNyetfx18CNc_bvNG7BDb44CIU3DEu4qziVVvNAE,20869
|
|
261
|
-
ultralytics/utils/torch_utils.py,sha256=
|
|
261
|
+
ultralytics/utils/torch_utils.py,sha256=P0eFWji98E_7JtIxLpgFXY4e81fzVJw0Xm4XeLl1g2M,40382
|
|
262
262
|
ultralytics/utils/tqdm.py,sha256=ny5RIg2OTkWQ7gdaXfYaoIgR0Xn2_hNGB6tUpO2Unns,16137
|
|
263
263
|
ultralytics/utils/triton.py,sha256=fbMfTAUyoGiyslWtySzLZw53XmZJa7rF31CYFot0Wjs,5422
|
|
264
264
|
ultralytics/utils/tuner.py,sha256=9D4dSIvwwxcNSJcH2QJ92qiIVi9zu-1L7_PBZ8okDyE,6816
|
|
@@ -276,8 +276,8 @@ ultralytics/utils/callbacks/tensorboard.py,sha256=_4nfGK1dDLn6ijpvphBDhc-AS8qhS3
|
|
|
276
276
|
ultralytics/utils/callbacks/wb.py,sha256=ngQO8EJ1kxJDF1YajScVtzBbm26jGuejA0uWeOyvf5A,7685
|
|
277
277
|
ultralytics/utils/export/__init__.py,sha256=eZg5z2I61k8H0ykQLc22HhKwFRsLxwuSlDVMuUlYXfU,10023
|
|
278
278
|
ultralytics/utils/export/imx.py,sha256=Jl5nuNxqaP_bY5yrV2NypmoJSrexHE71TxR72SDdjcg,11394
|
|
279
|
-
dgenerate_ultralytics_headless-8.3.
|
|
280
|
-
dgenerate_ultralytics_headless-8.3.
|
|
281
|
-
dgenerate_ultralytics_headless-8.3.
|
|
282
|
-
dgenerate_ultralytics_headless-8.3.
|
|
283
|
-
dgenerate_ultralytics_headless-8.3.
|
|
279
|
+
dgenerate_ultralytics_headless-8.3.220.dist-info/METADATA,sha256=4P-KimQ6qCNChCOYzhZ9tA_mogpDTpVNFmBmbQ1dXv8,38763
|
|
280
|
+
dgenerate_ultralytics_headless-8.3.220.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
281
|
+
dgenerate_ultralytics_headless-8.3.220.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
|
|
282
|
+
dgenerate_ultralytics_headless-8.3.220.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
|
|
283
|
+
dgenerate_ultralytics_headless-8.3.220.dist-info/RECORD,,
|
tests/test_cli.py
CHANGED
|
@@ -8,7 +8,7 @@ from PIL import Image
|
|
|
8
8
|
|
|
9
9
|
from tests import CUDA_DEVICE_COUNT, CUDA_IS_AVAILABLE, MODELS, TASK_MODEL_DATA
|
|
10
10
|
from ultralytics.utils import ARM64, ASSETS, LINUX, WEIGHTS_DIR, checks
|
|
11
|
-
from ultralytics.utils.torch_utils import TORCH_1_11
|
|
11
|
+
from ultralytics.utils.torch_utils import TORCH_1_11, TORCH_2_9, WINDOWS
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def run(cmd: str) -> None:
|
|
@@ -129,3 +129,10 @@ def test_train_gpu(task: str, model: str, data: str) -> None:
|
|
|
129
129
|
def test_solutions(solution: str) -> None:
|
|
130
130
|
"""Test yolo solutions command-line modes."""
|
|
131
131
|
run(f"yolo solutions {solution} verbose=False")
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
@pytest.mark.skipif(not checks.IS_PYTHON_MINIMUM_3_10 or not TORCH_2_9, reason="Requires Python>=3.10 and Torch>=2.9.0")
|
|
135
|
+
@pytest.mark.skipif(WINDOWS, reason="Skipping test on Windows")
|
|
136
|
+
def test_export_executorch() -> None:
|
|
137
|
+
"""Test exporting a YOLO model to ExecuTorch format via CLI."""
|
|
138
|
+
run("yolo export model=yolo11n.pt format=executorch imgsz=32")
|
tests/test_exports.py
CHANGED
|
@@ -12,15 +12,8 @@ import pytest
|
|
|
12
12
|
from tests import MODEL, SOURCE
|
|
13
13
|
from ultralytics import YOLO
|
|
14
14
|
from ultralytics.cfg import TASK2DATA, TASK2MODEL, TASKS
|
|
15
|
-
from ultralytics.utils import
|
|
16
|
-
|
|
17
|
-
IS_RASPBERRYPI,
|
|
18
|
-
LINUX,
|
|
19
|
-
MACOS,
|
|
20
|
-
WINDOWS,
|
|
21
|
-
checks,
|
|
22
|
-
)
|
|
23
|
-
from ultralytics.utils.torch_utils import TORCH_1_11, TORCH_1_13, TORCH_2_1
|
|
15
|
+
from ultralytics.utils import ARM64, IS_RASPBERRYPI, LINUX, MACOS, WINDOWS, checks
|
|
16
|
+
from ultralytics.utils.torch_utils import TORCH_1_11, TORCH_1_13, TORCH_2_1, TORCH_2_9
|
|
24
17
|
|
|
25
18
|
|
|
26
19
|
def test_export_torchscript():
|
|
@@ -262,3 +255,38 @@ def test_export_imx():
|
|
|
262
255
|
model = YOLO("yolov8n.pt")
|
|
263
256
|
file = model.export(format="imx", imgsz=32)
|
|
264
257
|
YOLO(file)(SOURCE, imgsz=32)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
@pytest.mark.skipif(not checks.IS_PYTHON_MINIMUM_3_10 or not TORCH_2_9, reason="Requires Python>=3.10 and Torch>=2.9.0")
|
|
261
|
+
@pytest.mark.skipif(WINDOWS, reason="Skipping test on Windows")
|
|
262
|
+
def test_export_executorch():
|
|
263
|
+
"""Test YOLO model export to ExecuTorch format."""
|
|
264
|
+
file = YOLO(MODEL).export(format="executorch", imgsz=32)
|
|
265
|
+
assert Path(file).exists(), f"ExecuTorch export failed, directory not found: {file}"
|
|
266
|
+
# Check that .pte file exists in the exported directory
|
|
267
|
+
pte_file = Path(file) / Path(MODEL).with_suffix(".pte").name
|
|
268
|
+
assert pte_file.exists(), f"ExecuTorch .pte file not found: {pte_file}"
|
|
269
|
+
# Check that metadata.yaml exists
|
|
270
|
+
metadata_file = Path(file) / "metadata.yaml"
|
|
271
|
+
assert metadata_file.exists(), f"ExecuTorch metadata.yaml not found: {metadata_file}"
|
|
272
|
+
# Note: Inference testing skipped as ExecuTorch requires special runtime setup
|
|
273
|
+
shutil.rmtree(file, ignore_errors=True) # cleanup
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
@pytest.mark.slow
|
|
277
|
+
@pytest.mark.skipif(not checks.IS_PYTHON_MINIMUM_3_10 or not TORCH_2_9, reason="Requires Python>=3.10 and Torch>=2.9.0")
|
|
278
|
+
@pytest.mark.skipif(WINDOWS, reason="Skipping test on Windows")
|
|
279
|
+
@pytest.mark.parametrize("task", TASKS)
|
|
280
|
+
def test_export_executorch_matrix(task):
|
|
281
|
+
"""Test YOLO export to ExecuTorch format for various task types."""
|
|
282
|
+
file = YOLO(TASK2MODEL[task]).export(format="executorch", imgsz=32)
|
|
283
|
+
assert Path(file).exists(), f"ExecuTorch export failed for task '{task}', directory not found: {file}"
|
|
284
|
+
# Check that .pte file exists in the exported directory
|
|
285
|
+
model_name = Path(TASK2MODEL[task]).with_suffix(".pte").name
|
|
286
|
+
pte_file = Path(file) / model_name
|
|
287
|
+
assert pte_file.exists(), f"ExecuTorch .pte file not found for task '{task}': {pte_file}"
|
|
288
|
+
# Check that metadata.yaml exists
|
|
289
|
+
metadata_file = Path(file) / "metadata.yaml"
|
|
290
|
+
assert metadata_file.exists(), f"ExecuTorch metadata.yaml not found for task '{task}': {metadata_file}"
|
|
291
|
+
# Note: Inference testing skipped as ExecuTorch requires special runtime setup
|
|
292
|
+
shutil.rmtree(file, ignore_errors=True) # cleanup
|
ultralytics/__init__.py
CHANGED
ultralytics/cfg/default.yaml
CHANGED
|
@@ -80,7 +80,7 @@ show_boxes: True # (bool) draw bounding boxes on images
|
|
|
80
80
|
line_width: # (int, optional) line width of boxes; auto-scales with image size if not set
|
|
81
81
|
|
|
82
82
|
# Export settings ------------------------------------------------------------------------------------------------------
|
|
83
|
-
format: torchscript # (str) target format, e.g. torchscript|onnx|openvino|engine|coreml|saved_model|pb|tflite|edgetpu|tfjs|paddle|mnn|ncnn|imx|rknn
|
|
83
|
+
format: torchscript # (str) target format, e.g. torchscript|onnx|openvino|engine|coreml|saved_model|pb|tflite|edgetpu|tfjs|paddle|mnn|ncnn|imx|rknn|executorch
|
|
84
84
|
keras: False # (bool) TF SavedModel only (format=saved_model); enable Keras layers during export
|
|
85
85
|
optimize: False # (bool) TorchScript only; apply mobile optimizations to the scripted model
|
|
86
86
|
int8: False # (bool) INT8/PTQ where supported (openvino, tflite, tfjs, engine, imx); needs calibration data/fraction
|
ultralytics/engine/exporter.py
CHANGED
|
@@ -20,6 +20,7 @@ MNN | `mnn` | yolo11n.mnn
|
|
|
20
20
|
NCNN | `ncnn` | yolo11n_ncnn_model/
|
|
21
21
|
IMX | `imx` | yolo11n_imx_model/
|
|
22
22
|
RKNN | `rknn` | yolo11n_rknn_model/
|
|
23
|
+
ExecuTorch | `executorch` | yolo11n_executorch_model/
|
|
23
24
|
|
|
24
25
|
Requirements:
|
|
25
26
|
$ pip install "ultralytics[export]"
|
|
@@ -48,6 +49,7 @@ Inference:
|
|
|
48
49
|
yolo11n_ncnn_model # NCNN
|
|
49
50
|
yolo11n_imx_model # IMX
|
|
50
51
|
yolo11n_rknn_model # RKNN
|
|
52
|
+
yolo11n_executorch_model # ExecuTorch
|
|
51
53
|
|
|
52
54
|
TensorFlow.js:
|
|
53
55
|
$ cd .. && git clone https://github.com/zldrobit/tfjs-yolov5-example.git && cd tfjs-yolov5-example
|
|
@@ -112,7 +114,7 @@ from ultralytics.utils.metrics import batch_probiou
|
|
|
112
114
|
from ultralytics.utils.nms import TorchNMS
|
|
113
115
|
from ultralytics.utils.ops import Profile
|
|
114
116
|
from ultralytics.utils.patches import arange_patch
|
|
115
|
-
from ultralytics.utils.torch_utils import TORCH_1_11, TORCH_1_13, TORCH_2_1, TORCH_2_4, select_device
|
|
117
|
+
from ultralytics.utils.torch_utils import TORCH_1_11, TORCH_1_13, TORCH_2_1, TORCH_2_4, TORCH_2_9, select_device
|
|
116
118
|
|
|
117
119
|
|
|
118
120
|
def export_formats():
|
|
@@ -148,6 +150,7 @@ def export_formats():
|
|
|
148
150
|
["NCNN", "ncnn", "_ncnn_model", True, True, ["batch", "half"]],
|
|
149
151
|
["IMX", "imx", "_imx_model", True, True, ["int8", "fraction", "nms"]],
|
|
150
152
|
["RKNN", "rknn", "_rknn_model", False, False, ["batch", "name"]],
|
|
153
|
+
["ExecuTorch", "executorch", "_executorch_model", False, False, ["batch"]],
|
|
151
154
|
]
|
|
152
155
|
return dict(zip(["Format", "Argument", "Suffix", "CPU", "GPU", "Arguments"], zip(*x)))
|
|
153
156
|
|
|
@@ -322,9 +325,24 @@ class Exporter:
|
|
|
322
325
|
flags = [x == fmt for x in fmts]
|
|
323
326
|
if sum(flags) != 1:
|
|
324
327
|
raise ValueError(f"Invalid export format='{fmt}'. Valid formats are {fmts}")
|
|
325
|
-
(
|
|
326
|
-
|
|
327
|
-
|
|
328
|
+
(
|
|
329
|
+
jit,
|
|
330
|
+
onnx,
|
|
331
|
+
xml,
|
|
332
|
+
engine,
|
|
333
|
+
coreml,
|
|
334
|
+
saved_model,
|
|
335
|
+
pb,
|
|
336
|
+
tflite,
|
|
337
|
+
edgetpu,
|
|
338
|
+
tfjs,
|
|
339
|
+
paddle,
|
|
340
|
+
mnn,
|
|
341
|
+
ncnn,
|
|
342
|
+
imx,
|
|
343
|
+
rknn,
|
|
344
|
+
executorch,
|
|
345
|
+
) = flags # export booleans
|
|
328
346
|
|
|
329
347
|
is_tf_format = any((saved_model, pb, tflite, edgetpu, tfjs))
|
|
330
348
|
|
|
@@ -543,6 +561,8 @@ class Exporter:
|
|
|
543
561
|
f[13] = self.export_imx()
|
|
544
562
|
if rknn:
|
|
545
563
|
f[14] = self.export_rknn()
|
|
564
|
+
if executorch:
|
|
565
|
+
f[15] = self.export_executorch()
|
|
546
566
|
|
|
547
567
|
# Finish
|
|
548
568
|
f = [str(x) for x in f if x] # filter out '' and None
|
|
@@ -1122,6 +1142,39 @@ class Exporter:
|
|
|
1122
1142
|
f = saved_model / f"{self.file.stem}_float32.tflite"
|
|
1123
1143
|
return str(f)
|
|
1124
1144
|
|
|
1145
|
+
@try_export
|
|
1146
|
+
def export_executorch(self, prefix=colorstr("ExecuTorch:")):
|
|
1147
|
+
"""Exports a model to ExecuTorch (.pte) format into a dedicated directory and saves the required metadata,
|
|
1148
|
+
following Ultralytics conventions.
|
|
1149
|
+
"""
|
|
1150
|
+
LOGGER.info(f"\n{prefix} starting export with ExecuTorch...")
|
|
1151
|
+
assert TORCH_2_9, f"ExecuTorch export requires torch>=2.9.0 but torch=={TORCH_VERSION} is installed"
|
|
1152
|
+
# TorchAO release compatibility table bug https://github.com/pytorch/ao/issues/2919
|
|
1153
|
+
# Setuptools bug: https://github.com/pypa/setuptools/issues/4483
|
|
1154
|
+
check_requirements("setuptools<71.0.0") # Setuptools bug: https://github.com/pypa/setuptools/issues/4483
|
|
1155
|
+
check_requirements(("executorch==1.0.0", "flatbuffers"))
|
|
1156
|
+
|
|
1157
|
+
import torch
|
|
1158
|
+
from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner
|
|
1159
|
+
from executorch.exir import to_edge_transform_and_lower
|
|
1160
|
+
|
|
1161
|
+
file_directory = Path(str(self.file).replace(self.file.suffix, "_executorch_model"))
|
|
1162
|
+
file_directory.mkdir(parents=True, exist_ok=True)
|
|
1163
|
+
|
|
1164
|
+
file_pte = file_directory / self.file.with_suffix(".pte").name
|
|
1165
|
+
sample_inputs = (self.im,)
|
|
1166
|
+
|
|
1167
|
+
et_program = to_edge_transform_and_lower(
|
|
1168
|
+
torch.export.export(self.model, sample_inputs), partitioner=[XnnpackPartitioner()]
|
|
1169
|
+
).to_executorch()
|
|
1170
|
+
|
|
1171
|
+
with open(file_pte, "wb") as file:
|
|
1172
|
+
file.write(et_program.buffer)
|
|
1173
|
+
|
|
1174
|
+
YAML.save(file_directory / "metadata.yaml", self.metadata)
|
|
1175
|
+
|
|
1176
|
+
return str(file_directory)
|
|
1177
|
+
|
|
1125
1178
|
@try_export
|
|
1126
1179
|
def export_edgetpu(self, tflite_model="", prefix=colorstr("Edge TPU:")):
|
|
1127
1180
|
"""Export YOLO model to Edge TPU format https://coral.ai/docs/edgetpu/models-intro/."""
|
ultralytics/engine/predictor.py
CHANGED
|
@@ -4,7 +4,7 @@ import torch
|
|
|
4
4
|
from PIL import Image
|
|
5
5
|
|
|
6
6
|
from ultralytics.models.yolo.segment import SegmentationPredictor
|
|
7
|
-
from ultralytics.utils import DEFAULT_CFG
|
|
7
|
+
from ultralytics.utils import DEFAULT_CFG
|
|
8
8
|
from ultralytics.utils.metrics import box_iou
|
|
9
9
|
from ultralytics.utils.ops import scale_masks
|
|
10
10
|
from ultralytics.utils.torch_utils import TORCH_1_10
|
|
@@ -101,7 +101,7 @@ class FastSAMPredictor(SegmentationPredictor):
|
|
|
101
101
|
continue
|
|
102
102
|
masks = result.masks.data
|
|
103
103
|
if masks.shape[1:] != result.orig_shape:
|
|
104
|
-
masks = scale_masks(masks[None], result.orig_shape)[0]
|
|
104
|
+
masks = (scale_masks(masks[None].float(), result.orig_shape)[0] > 0.5).byte()
|
|
105
105
|
# bboxes prompt
|
|
106
106
|
idx = torch.zeros(len(result), dtype=torch.bool, device=self.device)
|
|
107
107
|
if bboxes is not None:
|
|
@@ -161,20 +161,14 @@ class FastSAMPredictor(SegmentationPredictor):
|
|
|
161
161
|
Returns:
|
|
162
162
|
(torch.Tensor): Similarity matrix between given images and texts with shape (M, N).
|
|
163
163
|
"""
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
tokenized_text = clip.tokenize(texts).to(self.device)
|
|
173
|
-
image_features = self.clip_model.encode_image(images)
|
|
174
|
-
text_features = self.clip_model.encode_text(tokenized_text)
|
|
175
|
-
image_features /= image_features.norm(dim=-1, keepdim=True) # (N, 512)
|
|
176
|
-
text_features /= text_features.norm(dim=-1, keepdim=True) # (M, 512)
|
|
177
|
-
return (image_features * text_features[:, None]).sum(-1) # (M, N)
|
|
164
|
+
from ultralytics.nn.text_model import CLIP
|
|
165
|
+
|
|
166
|
+
if not hasattr(self, "clip"):
|
|
167
|
+
self.clip = CLIP("ViT-B/32", device=self.device)
|
|
168
|
+
images = torch.stack([self.clip.image_preprocess(image).to(self.device) for image in images])
|
|
169
|
+
image_features = self.clip.encode_image(images)
|
|
170
|
+
text_features = self.clip.encode_text(self.clip.tokenize(texts))
|
|
171
|
+
return text_features @ image_features.T # (M, N)
|
|
178
172
|
|
|
179
173
|
def set_prompts(self, prompts):
|
|
180
174
|
"""Set prompts to be used during inference."""
|
ultralytics/nn/autobackend.py
CHANGED
|
@@ -96,6 +96,8 @@ class AutoBackend(nn.Module):
|
|
|
96
96
|
| NCNN | *_ncnn_model/ |
|
|
97
97
|
| IMX | *_imx_model/ |
|
|
98
98
|
| RKNN | *_rknn_model/ |
|
|
99
|
+
| Triton Inference | triton://model |
|
|
100
|
+
| ExecuTorch | *.pte |
|
|
99
101
|
|
|
100
102
|
Attributes:
|
|
101
103
|
model (torch.nn.Module): The loaded YOLO model.
|
|
@@ -122,6 +124,7 @@ class AutoBackend(nn.Module):
|
|
|
122
124
|
imx (bool): Whether the model is an IMX model.
|
|
123
125
|
rknn (bool): Whether the model is an RKNN model.
|
|
124
126
|
triton (bool): Whether the model is a Triton Inference Server model.
|
|
127
|
+
pte (bool): Whether the model is a PyTorch ExecuTorch model.
|
|
125
128
|
|
|
126
129
|
Methods:
|
|
127
130
|
forward: Run inference on an input image.
|
|
@@ -176,6 +179,7 @@ class AutoBackend(nn.Module):
|
|
|
176
179
|
ncnn,
|
|
177
180
|
imx,
|
|
178
181
|
rknn,
|
|
182
|
+
pte,
|
|
179
183
|
triton,
|
|
180
184
|
) = self._model_type("" if nn_module else model)
|
|
181
185
|
fp16 &= pt or jit or onnx or xml or engine or nn_module or triton # FP16
|
|
@@ -570,6 +574,25 @@ class AutoBackend(nn.Module):
|
|
|
570
574
|
rknn_model.init_runtime()
|
|
571
575
|
metadata = w.parent / "metadata.yaml"
|
|
572
576
|
|
|
577
|
+
# ExecuTorch
|
|
578
|
+
elif pte:
|
|
579
|
+
LOGGER.info(f"Loading {w} for ExecuTorch inference...")
|
|
580
|
+
# TorchAO release compatibility table bug https://github.com/pytorch/ao/issues/2919
|
|
581
|
+
check_requirements("setuptools<71.0.0") # Setuptools bug: https://github.com/pypa/setuptools/issues/4483
|
|
582
|
+
check_requirements(("executorch==1.0.0", "flatbuffers"))
|
|
583
|
+
from executorch.runtime import Runtime
|
|
584
|
+
|
|
585
|
+
w = Path(w)
|
|
586
|
+
if w.is_dir():
|
|
587
|
+
model_file = next(w.rglob("*.pte"))
|
|
588
|
+
metadata = w / "metadata.yaml"
|
|
589
|
+
else:
|
|
590
|
+
model_file = w
|
|
591
|
+
metadata = w.parent / "metadata.yaml"
|
|
592
|
+
|
|
593
|
+
program = Runtime.get().load_program(str(model_file))
|
|
594
|
+
model = program.load_method("forward")
|
|
595
|
+
|
|
573
596
|
# Any other format (unsupported)
|
|
574
597
|
else:
|
|
575
598
|
from ultralytics.engine.exporter import export_formats
|
|
@@ -773,6 +796,10 @@ class AutoBackend(nn.Module):
|
|
|
773
796
|
im = im if isinstance(im, (list, tuple)) else [im]
|
|
774
797
|
y = self.rknn_model.inference(inputs=im)
|
|
775
798
|
|
|
799
|
+
# ExecuTorch
|
|
800
|
+
elif self.pte:
|
|
801
|
+
y = self.model.execute([im])
|
|
802
|
+
|
|
776
803
|
# TensorFlow (SavedModel, GraphDef, Lite, Edge TPU)
|
|
777
804
|
else:
|
|
778
805
|
im = im.cpu().numpy()
|
|
@@ -78,11 +78,11 @@ class VisualAISearch:
|
|
|
78
78
|
|
|
79
79
|
def extract_image_feature(self, path: Path) -> np.ndarray:
|
|
80
80
|
"""Extract CLIP image embedding from the given image path."""
|
|
81
|
-
return self.model.encode_image(Image.open(path)).cpu().numpy()
|
|
81
|
+
return self.model.encode_image(Image.open(path)).detach().cpu().numpy()
|
|
82
82
|
|
|
83
83
|
def extract_text_feature(self, text: str) -> np.ndarray:
|
|
84
84
|
"""Extract CLIP text embedding from the given text query."""
|
|
85
|
-
return self.model.encode_text(self.model.tokenize([text])).cpu().numpy()
|
|
85
|
+
return self.model.encode_text(self.model.tokenize([text])).detach().cpu().numpy()
|
|
86
86
|
|
|
87
87
|
def load_or_build_index(self) -> None:
|
|
88
88
|
"""
|
ultralytics/utils/torch_utils.py
CHANGED
|
@@ -44,6 +44,7 @@ TORCH_1_13 = check_version(TORCH_VERSION, "1.13.0")
|
|
|
44
44
|
TORCH_2_0 = check_version(TORCH_VERSION, "2.0.0")
|
|
45
45
|
TORCH_2_1 = check_version(TORCH_VERSION, "2.1.0")
|
|
46
46
|
TORCH_2_4 = check_version(TORCH_VERSION, "2.4.0")
|
|
47
|
+
TORCH_2_9 = check_version(TORCH_VERSION, "2.9.0")
|
|
47
48
|
TORCHVISION_0_10 = check_version(TORCHVISION_VERSION, "0.10.0")
|
|
48
49
|
TORCHVISION_0_11 = check_version(TORCHVISION_VERSION, "0.11.0")
|
|
49
50
|
TORCHVISION_0_13 = check_version(TORCHVISION_VERSION, "0.13.0")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|