ultralytics-opencv-headless 8.3.242__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.
- tests/__init__.py +23 -0
- tests/conftest.py +59 -0
- tests/test_cli.py +131 -0
- tests/test_cuda.py +216 -0
- tests/test_engine.py +157 -0
- tests/test_exports.py +309 -0
- tests/test_integrations.py +151 -0
- tests/test_python.py +777 -0
- tests/test_solutions.py +371 -0
- ultralytics/__init__.py +48 -0
- ultralytics/assets/bus.jpg +0 -0
- ultralytics/assets/zidane.jpg +0 -0
- ultralytics/cfg/__init__.py +1026 -0
- ultralytics/cfg/datasets/Argoverse.yaml +78 -0
- ultralytics/cfg/datasets/DOTAv1.5.yaml +37 -0
- ultralytics/cfg/datasets/DOTAv1.yaml +36 -0
- ultralytics/cfg/datasets/GlobalWheat2020.yaml +68 -0
- ultralytics/cfg/datasets/HomeObjects-3K.yaml +32 -0
- ultralytics/cfg/datasets/ImageNet.yaml +2025 -0
- ultralytics/cfg/datasets/Objects365.yaml +447 -0
- ultralytics/cfg/datasets/SKU-110K.yaml +58 -0
- ultralytics/cfg/datasets/VOC.yaml +102 -0
- ultralytics/cfg/datasets/VisDrone.yaml +87 -0
- ultralytics/cfg/datasets/african-wildlife.yaml +25 -0
- ultralytics/cfg/datasets/brain-tumor.yaml +22 -0
- ultralytics/cfg/datasets/carparts-seg.yaml +44 -0
- ultralytics/cfg/datasets/coco-pose.yaml +64 -0
- ultralytics/cfg/datasets/coco.yaml +118 -0
- ultralytics/cfg/datasets/coco128-seg.yaml +101 -0
- ultralytics/cfg/datasets/coco128.yaml +101 -0
- ultralytics/cfg/datasets/coco8-grayscale.yaml +103 -0
- ultralytics/cfg/datasets/coco8-multispectral.yaml +104 -0
- ultralytics/cfg/datasets/coco8-pose.yaml +47 -0
- ultralytics/cfg/datasets/coco8-seg.yaml +101 -0
- ultralytics/cfg/datasets/coco8.yaml +101 -0
- ultralytics/cfg/datasets/construction-ppe.yaml +32 -0
- ultralytics/cfg/datasets/crack-seg.yaml +22 -0
- ultralytics/cfg/datasets/dog-pose.yaml +52 -0
- ultralytics/cfg/datasets/dota8-multispectral.yaml +38 -0
- ultralytics/cfg/datasets/dota8.yaml +35 -0
- ultralytics/cfg/datasets/hand-keypoints.yaml +50 -0
- ultralytics/cfg/datasets/kitti.yaml +27 -0
- ultralytics/cfg/datasets/lvis.yaml +1240 -0
- ultralytics/cfg/datasets/medical-pills.yaml +21 -0
- ultralytics/cfg/datasets/open-images-v7.yaml +663 -0
- ultralytics/cfg/datasets/package-seg.yaml +22 -0
- ultralytics/cfg/datasets/signature.yaml +21 -0
- ultralytics/cfg/datasets/tiger-pose.yaml +41 -0
- ultralytics/cfg/datasets/xView.yaml +155 -0
- ultralytics/cfg/default.yaml +130 -0
- ultralytics/cfg/models/11/yolo11-cls-resnet18.yaml +17 -0
- ultralytics/cfg/models/11/yolo11-cls.yaml +33 -0
- ultralytics/cfg/models/11/yolo11-obb.yaml +50 -0
- ultralytics/cfg/models/11/yolo11-pose.yaml +51 -0
- ultralytics/cfg/models/11/yolo11-seg.yaml +50 -0
- ultralytics/cfg/models/11/yolo11.yaml +50 -0
- ultralytics/cfg/models/11/yoloe-11-seg.yaml +48 -0
- ultralytics/cfg/models/11/yoloe-11.yaml +48 -0
- ultralytics/cfg/models/12/yolo12-cls.yaml +32 -0
- ultralytics/cfg/models/12/yolo12-obb.yaml +48 -0
- ultralytics/cfg/models/12/yolo12-pose.yaml +49 -0
- ultralytics/cfg/models/12/yolo12-seg.yaml +48 -0
- ultralytics/cfg/models/12/yolo12.yaml +48 -0
- ultralytics/cfg/models/rt-detr/rtdetr-l.yaml +53 -0
- ultralytics/cfg/models/rt-detr/rtdetr-resnet101.yaml +45 -0
- ultralytics/cfg/models/rt-detr/rtdetr-resnet50.yaml +45 -0
- ultralytics/cfg/models/rt-detr/rtdetr-x.yaml +57 -0
- ultralytics/cfg/models/v10/yolov10b.yaml +45 -0
- ultralytics/cfg/models/v10/yolov10l.yaml +45 -0
- ultralytics/cfg/models/v10/yolov10m.yaml +45 -0
- ultralytics/cfg/models/v10/yolov10n.yaml +45 -0
- ultralytics/cfg/models/v10/yolov10s.yaml +45 -0
- ultralytics/cfg/models/v10/yolov10x.yaml +45 -0
- ultralytics/cfg/models/v3/yolov3-spp.yaml +49 -0
- ultralytics/cfg/models/v3/yolov3-tiny.yaml +40 -0
- ultralytics/cfg/models/v3/yolov3.yaml +49 -0
- ultralytics/cfg/models/v5/yolov5-p6.yaml +62 -0
- ultralytics/cfg/models/v5/yolov5.yaml +51 -0
- ultralytics/cfg/models/v6/yolov6.yaml +56 -0
- ultralytics/cfg/models/v8/yoloe-v8-seg.yaml +48 -0
- ultralytics/cfg/models/v8/yoloe-v8.yaml +48 -0
- ultralytics/cfg/models/v8/yolov8-cls-resnet101.yaml +28 -0
- ultralytics/cfg/models/v8/yolov8-cls-resnet50.yaml +28 -0
- ultralytics/cfg/models/v8/yolov8-cls.yaml +32 -0
- ultralytics/cfg/models/v8/yolov8-ghost-p2.yaml +58 -0
- ultralytics/cfg/models/v8/yolov8-ghost-p6.yaml +60 -0
- ultralytics/cfg/models/v8/yolov8-ghost.yaml +50 -0
- ultralytics/cfg/models/v8/yolov8-obb.yaml +49 -0
- ultralytics/cfg/models/v8/yolov8-p2.yaml +57 -0
- ultralytics/cfg/models/v8/yolov8-p6.yaml +59 -0
- ultralytics/cfg/models/v8/yolov8-pose-p6.yaml +60 -0
- ultralytics/cfg/models/v8/yolov8-pose.yaml +50 -0
- ultralytics/cfg/models/v8/yolov8-rtdetr.yaml +49 -0
- ultralytics/cfg/models/v8/yolov8-seg-p6.yaml +59 -0
- ultralytics/cfg/models/v8/yolov8-seg.yaml +49 -0
- ultralytics/cfg/models/v8/yolov8-world.yaml +51 -0
- ultralytics/cfg/models/v8/yolov8-worldv2.yaml +49 -0
- ultralytics/cfg/models/v8/yolov8.yaml +49 -0
- ultralytics/cfg/models/v9/yolov9c-seg.yaml +41 -0
- ultralytics/cfg/models/v9/yolov9c.yaml +41 -0
- ultralytics/cfg/models/v9/yolov9e-seg.yaml +64 -0
- ultralytics/cfg/models/v9/yolov9e.yaml +64 -0
- ultralytics/cfg/models/v9/yolov9m.yaml +41 -0
- ultralytics/cfg/models/v9/yolov9s.yaml +41 -0
- ultralytics/cfg/models/v9/yolov9t.yaml +41 -0
- ultralytics/cfg/trackers/botsort.yaml +21 -0
- ultralytics/cfg/trackers/bytetrack.yaml +12 -0
- ultralytics/data/__init__.py +26 -0
- ultralytics/data/annotator.py +66 -0
- ultralytics/data/augment.py +2801 -0
- ultralytics/data/base.py +435 -0
- ultralytics/data/build.py +437 -0
- ultralytics/data/converter.py +855 -0
- ultralytics/data/dataset.py +834 -0
- ultralytics/data/loaders.py +704 -0
- ultralytics/data/scripts/download_weights.sh +18 -0
- ultralytics/data/scripts/get_coco.sh +61 -0
- ultralytics/data/scripts/get_coco128.sh +18 -0
- ultralytics/data/scripts/get_imagenet.sh +52 -0
- ultralytics/data/split.py +138 -0
- ultralytics/data/split_dota.py +344 -0
- ultralytics/data/utils.py +798 -0
- ultralytics/engine/__init__.py +1 -0
- ultralytics/engine/exporter.py +1574 -0
- ultralytics/engine/model.py +1124 -0
- ultralytics/engine/predictor.py +508 -0
- ultralytics/engine/results.py +1522 -0
- ultralytics/engine/trainer.py +974 -0
- ultralytics/engine/tuner.py +448 -0
- ultralytics/engine/validator.py +384 -0
- ultralytics/hub/__init__.py +166 -0
- ultralytics/hub/auth.py +151 -0
- ultralytics/hub/google/__init__.py +174 -0
- ultralytics/hub/session.py +422 -0
- ultralytics/hub/utils.py +162 -0
- ultralytics/models/__init__.py +9 -0
- ultralytics/models/fastsam/__init__.py +7 -0
- ultralytics/models/fastsam/model.py +79 -0
- ultralytics/models/fastsam/predict.py +169 -0
- ultralytics/models/fastsam/utils.py +23 -0
- ultralytics/models/fastsam/val.py +38 -0
- ultralytics/models/nas/__init__.py +7 -0
- ultralytics/models/nas/model.py +98 -0
- ultralytics/models/nas/predict.py +56 -0
- ultralytics/models/nas/val.py +38 -0
- ultralytics/models/rtdetr/__init__.py +7 -0
- ultralytics/models/rtdetr/model.py +63 -0
- ultralytics/models/rtdetr/predict.py +88 -0
- ultralytics/models/rtdetr/train.py +89 -0
- ultralytics/models/rtdetr/val.py +216 -0
- ultralytics/models/sam/__init__.py +25 -0
- ultralytics/models/sam/amg.py +275 -0
- ultralytics/models/sam/build.py +365 -0
- ultralytics/models/sam/build_sam3.py +377 -0
- ultralytics/models/sam/model.py +169 -0
- ultralytics/models/sam/modules/__init__.py +1 -0
- ultralytics/models/sam/modules/blocks.py +1067 -0
- ultralytics/models/sam/modules/decoders.py +495 -0
- ultralytics/models/sam/modules/encoders.py +794 -0
- ultralytics/models/sam/modules/memory_attention.py +298 -0
- ultralytics/models/sam/modules/sam.py +1160 -0
- ultralytics/models/sam/modules/tiny_encoder.py +979 -0
- ultralytics/models/sam/modules/transformer.py +344 -0
- ultralytics/models/sam/modules/utils.py +512 -0
- ultralytics/models/sam/predict.py +3940 -0
- ultralytics/models/sam/sam3/__init__.py +3 -0
- ultralytics/models/sam/sam3/decoder.py +546 -0
- ultralytics/models/sam/sam3/encoder.py +529 -0
- ultralytics/models/sam/sam3/geometry_encoders.py +415 -0
- ultralytics/models/sam/sam3/maskformer_segmentation.py +286 -0
- ultralytics/models/sam/sam3/model_misc.py +199 -0
- ultralytics/models/sam/sam3/necks.py +129 -0
- ultralytics/models/sam/sam3/sam3_image.py +339 -0
- ultralytics/models/sam/sam3/text_encoder_ve.py +307 -0
- ultralytics/models/sam/sam3/vitdet.py +547 -0
- ultralytics/models/sam/sam3/vl_combiner.py +160 -0
- ultralytics/models/utils/__init__.py +1 -0
- ultralytics/models/utils/loss.py +466 -0
- ultralytics/models/utils/ops.py +315 -0
- ultralytics/models/yolo/__init__.py +7 -0
- ultralytics/models/yolo/classify/__init__.py +7 -0
- ultralytics/models/yolo/classify/predict.py +90 -0
- ultralytics/models/yolo/classify/train.py +202 -0
- ultralytics/models/yolo/classify/val.py +216 -0
- ultralytics/models/yolo/detect/__init__.py +7 -0
- ultralytics/models/yolo/detect/predict.py +122 -0
- ultralytics/models/yolo/detect/train.py +227 -0
- ultralytics/models/yolo/detect/val.py +507 -0
- ultralytics/models/yolo/model.py +430 -0
- ultralytics/models/yolo/obb/__init__.py +7 -0
- ultralytics/models/yolo/obb/predict.py +56 -0
- ultralytics/models/yolo/obb/train.py +79 -0
- ultralytics/models/yolo/obb/val.py +302 -0
- ultralytics/models/yolo/pose/__init__.py +7 -0
- ultralytics/models/yolo/pose/predict.py +65 -0
- ultralytics/models/yolo/pose/train.py +110 -0
- ultralytics/models/yolo/pose/val.py +248 -0
- ultralytics/models/yolo/segment/__init__.py +7 -0
- ultralytics/models/yolo/segment/predict.py +109 -0
- ultralytics/models/yolo/segment/train.py +69 -0
- ultralytics/models/yolo/segment/val.py +307 -0
- ultralytics/models/yolo/world/__init__.py +5 -0
- ultralytics/models/yolo/world/train.py +173 -0
- ultralytics/models/yolo/world/train_world.py +178 -0
- ultralytics/models/yolo/yoloe/__init__.py +22 -0
- ultralytics/models/yolo/yoloe/predict.py +162 -0
- ultralytics/models/yolo/yoloe/train.py +287 -0
- ultralytics/models/yolo/yoloe/train_seg.py +122 -0
- ultralytics/models/yolo/yoloe/val.py +206 -0
- ultralytics/nn/__init__.py +27 -0
- ultralytics/nn/autobackend.py +958 -0
- ultralytics/nn/modules/__init__.py +182 -0
- ultralytics/nn/modules/activation.py +54 -0
- ultralytics/nn/modules/block.py +1947 -0
- ultralytics/nn/modules/conv.py +669 -0
- ultralytics/nn/modules/head.py +1183 -0
- ultralytics/nn/modules/transformer.py +793 -0
- ultralytics/nn/modules/utils.py +159 -0
- ultralytics/nn/tasks.py +1768 -0
- ultralytics/nn/text_model.py +356 -0
- ultralytics/py.typed +1 -0
- ultralytics/solutions/__init__.py +41 -0
- ultralytics/solutions/ai_gym.py +108 -0
- ultralytics/solutions/analytics.py +264 -0
- ultralytics/solutions/config.py +107 -0
- ultralytics/solutions/distance_calculation.py +123 -0
- ultralytics/solutions/heatmap.py +125 -0
- ultralytics/solutions/instance_segmentation.py +86 -0
- ultralytics/solutions/object_blurrer.py +89 -0
- ultralytics/solutions/object_counter.py +190 -0
- ultralytics/solutions/object_cropper.py +87 -0
- ultralytics/solutions/parking_management.py +280 -0
- ultralytics/solutions/queue_management.py +93 -0
- ultralytics/solutions/region_counter.py +133 -0
- ultralytics/solutions/security_alarm.py +151 -0
- ultralytics/solutions/similarity_search.py +219 -0
- ultralytics/solutions/solutions.py +828 -0
- ultralytics/solutions/speed_estimation.py +114 -0
- ultralytics/solutions/streamlit_inference.py +260 -0
- ultralytics/solutions/templates/similarity-search.html +156 -0
- ultralytics/solutions/trackzone.py +88 -0
- ultralytics/solutions/vision_eye.py +67 -0
- ultralytics/trackers/__init__.py +7 -0
- ultralytics/trackers/basetrack.py +115 -0
- ultralytics/trackers/bot_sort.py +257 -0
- ultralytics/trackers/byte_tracker.py +469 -0
- ultralytics/trackers/track.py +116 -0
- ultralytics/trackers/utils/__init__.py +1 -0
- ultralytics/trackers/utils/gmc.py +339 -0
- ultralytics/trackers/utils/kalman_filter.py +482 -0
- ultralytics/trackers/utils/matching.py +154 -0
- ultralytics/utils/__init__.py +1450 -0
- ultralytics/utils/autobatch.py +118 -0
- ultralytics/utils/autodevice.py +205 -0
- ultralytics/utils/benchmarks.py +728 -0
- ultralytics/utils/callbacks/__init__.py +5 -0
- ultralytics/utils/callbacks/base.py +233 -0
- ultralytics/utils/callbacks/clearml.py +146 -0
- ultralytics/utils/callbacks/comet.py +625 -0
- ultralytics/utils/callbacks/dvc.py +197 -0
- ultralytics/utils/callbacks/hub.py +110 -0
- ultralytics/utils/callbacks/mlflow.py +134 -0
- ultralytics/utils/callbacks/neptune.py +126 -0
- ultralytics/utils/callbacks/platform.py +73 -0
- ultralytics/utils/callbacks/raytune.py +42 -0
- ultralytics/utils/callbacks/tensorboard.py +123 -0
- ultralytics/utils/callbacks/wb.py +188 -0
- ultralytics/utils/checks.py +998 -0
- ultralytics/utils/cpu.py +85 -0
- ultralytics/utils/dist.py +123 -0
- ultralytics/utils/downloads.py +529 -0
- ultralytics/utils/errors.py +35 -0
- ultralytics/utils/events.py +113 -0
- ultralytics/utils/export/__init__.py +7 -0
- ultralytics/utils/export/engine.py +237 -0
- ultralytics/utils/export/imx.py +315 -0
- ultralytics/utils/export/tensorflow.py +231 -0
- ultralytics/utils/files.py +219 -0
- ultralytics/utils/git.py +137 -0
- ultralytics/utils/instance.py +484 -0
- ultralytics/utils/logger.py +444 -0
- ultralytics/utils/loss.py +849 -0
- ultralytics/utils/metrics.py +1560 -0
- ultralytics/utils/nms.py +337 -0
- ultralytics/utils/ops.py +664 -0
- ultralytics/utils/patches.py +201 -0
- ultralytics/utils/plotting.py +1045 -0
- ultralytics/utils/tal.py +403 -0
- ultralytics/utils/torch_utils.py +984 -0
- ultralytics/utils/tqdm.py +440 -0
- ultralytics/utils/triton.py +112 -0
- ultralytics/utils/tuner.py +160 -0
- ultralytics_opencv_headless-8.3.242.dist-info/METADATA +374 -0
- ultralytics_opencv_headless-8.3.242.dist-info/RECORD +298 -0
- ultralytics_opencv_headless-8.3.242.dist-info/WHEEL +5 -0
- ultralytics_opencv_headless-8.3.242.dist-info/entry_points.txt +3 -0
- ultralytics_opencv_headless-8.3.242.dist-info/licenses/LICENSE +661 -0
- ultralytics_opencv_headless-8.3.242.dist-info/top_level.txt +1 -0
tests/test_exports.py
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
|
2
|
+
|
|
3
|
+
import io
|
|
4
|
+
import shutil
|
|
5
|
+
import uuid
|
|
6
|
+
from contextlib import redirect_stderr, redirect_stdout
|
|
7
|
+
from itertools import product
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
|
|
12
|
+
from tests import MODEL, SOURCE
|
|
13
|
+
from ultralytics import YOLO
|
|
14
|
+
from ultralytics.cfg import TASK2DATA, TASK2MODEL, TASKS
|
|
15
|
+
from ultralytics.utils import ARM64, IS_RASPBERRYPI, LINUX, MACOS, WINDOWS, checks
|
|
16
|
+
from ultralytics.utils.torch_utils import TORCH_1_10, TORCH_1_11, TORCH_1_13, TORCH_2_1, TORCH_2_8, TORCH_2_9
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def test_export_torchscript():
|
|
20
|
+
"""Test YOLO model export to TorchScript format for compatibility and correctness."""
|
|
21
|
+
file = YOLO(MODEL).export(format="torchscript", optimize=False, imgsz=32)
|
|
22
|
+
YOLO(file)(SOURCE, imgsz=32) # exported model inference
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test_export_onnx():
|
|
26
|
+
"""Test YOLO model export to ONNX format with dynamic axes."""
|
|
27
|
+
file = YOLO(MODEL).export(format="onnx", dynamic=True, imgsz=32)
|
|
28
|
+
YOLO(file)(SOURCE, imgsz=32) # exported model inference
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@pytest.mark.skipif(not TORCH_2_1, reason="OpenVINO requires torch>=2.1")
|
|
32
|
+
def test_export_openvino():
|
|
33
|
+
"""Test YOLO export to OpenVINO format for model inference compatibility."""
|
|
34
|
+
file = YOLO(MODEL).export(format="openvino", imgsz=32)
|
|
35
|
+
YOLO(file)(SOURCE, imgsz=32) # exported model inference
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@pytest.mark.slow
|
|
39
|
+
@pytest.mark.skipif(not TORCH_2_1, reason="OpenVINO requires torch>=2.1")
|
|
40
|
+
@pytest.mark.parametrize(
|
|
41
|
+
"task, dynamic, int8, half, batch, nms",
|
|
42
|
+
[ # generate all combinations except for exclusion cases
|
|
43
|
+
(task, dynamic, int8, half, batch, nms)
|
|
44
|
+
for task, dynamic, int8, half, batch, nms in product(
|
|
45
|
+
TASKS, [True, False], [True, False], [True, False], [1, 2], [True, False]
|
|
46
|
+
)
|
|
47
|
+
if not ((int8 and half) or (task == "classify" and nms))
|
|
48
|
+
],
|
|
49
|
+
)
|
|
50
|
+
def test_export_openvino_matrix(task, dynamic, int8, half, batch, nms):
|
|
51
|
+
"""Test YOLO model export to OpenVINO under various configuration matrix conditions."""
|
|
52
|
+
file = YOLO(TASK2MODEL[task]).export(
|
|
53
|
+
format="openvino",
|
|
54
|
+
imgsz=32,
|
|
55
|
+
dynamic=dynamic,
|
|
56
|
+
int8=int8,
|
|
57
|
+
half=half,
|
|
58
|
+
batch=batch,
|
|
59
|
+
data=TASK2DATA[task],
|
|
60
|
+
nms=nms,
|
|
61
|
+
)
|
|
62
|
+
if WINDOWS:
|
|
63
|
+
# Use unique filenames due to Windows file permissions bug possibly due to latent threaded use
|
|
64
|
+
# See https://github.com/ultralytics/ultralytics/actions/runs/8957949304/job/24601616830?pr=10423
|
|
65
|
+
file = Path(file)
|
|
66
|
+
file = file.rename(file.with_stem(f"{file.stem}-{uuid.uuid4()}"))
|
|
67
|
+
YOLO(file)([SOURCE] * batch, imgsz=64 if dynamic else 32, batch=batch) # exported model inference
|
|
68
|
+
shutil.rmtree(file, ignore_errors=True) # retry in case of potential lingering multi-threaded file usage errors
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@pytest.mark.slow
|
|
72
|
+
@pytest.mark.parametrize(
|
|
73
|
+
"task, dynamic, int8, half, batch, simplify, nms",
|
|
74
|
+
[ # generate all combinations except for exclusion cases
|
|
75
|
+
(task, dynamic, int8, half, batch, simplify, nms)
|
|
76
|
+
for task, dynamic, int8, half, batch, simplify, nms in product(
|
|
77
|
+
TASKS, [True, False], [False], [False], [1, 2], [True, False], [True, False]
|
|
78
|
+
)
|
|
79
|
+
if not ((int8 and half) or (task == "classify" and nms) or (nms and not TORCH_1_13))
|
|
80
|
+
],
|
|
81
|
+
)
|
|
82
|
+
def test_export_onnx_matrix(task, dynamic, int8, half, batch, simplify, nms):
|
|
83
|
+
"""Test YOLO export to ONNX format with various configurations and parameters."""
|
|
84
|
+
file = YOLO(TASK2MODEL[task]).export(
|
|
85
|
+
format="onnx", imgsz=32, dynamic=dynamic, int8=int8, half=half, batch=batch, simplify=simplify, nms=nms
|
|
86
|
+
)
|
|
87
|
+
YOLO(file)([SOURCE] * batch, imgsz=64 if dynamic else 32) # exported model inference
|
|
88
|
+
Path(file).unlink() # cleanup
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@pytest.mark.slow
|
|
92
|
+
@pytest.mark.parametrize(
|
|
93
|
+
"task, dynamic, int8, half, batch, nms",
|
|
94
|
+
[ # generate all combinations except for exclusion cases
|
|
95
|
+
(task, dynamic, int8, half, batch, nms)
|
|
96
|
+
for task, dynamic, int8, half, batch, nms in product(
|
|
97
|
+
TASKS, [False, True], [False], [False, True], [1, 2], [True, False]
|
|
98
|
+
)
|
|
99
|
+
if not (task == "classify" and nms)
|
|
100
|
+
],
|
|
101
|
+
)
|
|
102
|
+
def test_export_torchscript_matrix(task, dynamic, int8, half, batch, nms):
|
|
103
|
+
"""Test YOLO model export to TorchScript format under varied configurations."""
|
|
104
|
+
file = YOLO(TASK2MODEL[task]).export(
|
|
105
|
+
format="torchscript", imgsz=32, dynamic=dynamic, int8=int8, half=half, batch=batch, nms=nms
|
|
106
|
+
)
|
|
107
|
+
YOLO(file)([SOURCE] * batch, imgsz=64 if dynamic else 32) # exported model inference
|
|
108
|
+
Path(file).unlink() # cleanup
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@pytest.mark.slow
|
|
112
|
+
@pytest.mark.skipif(not MACOS, reason="CoreML inference only supported on macOS")
|
|
113
|
+
@pytest.mark.skipif(not TORCH_1_11, reason="CoreML export requires torch>=1.11")
|
|
114
|
+
@pytest.mark.skipif(checks.IS_PYTHON_3_13, reason="CoreML not supported in Python 3.13")
|
|
115
|
+
@pytest.mark.parametrize(
|
|
116
|
+
"task, dynamic, int8, half, nms, batch",
|
|
117
|
+
[ # generate all combinations except for exclusion cases
|
|
118
|
+
(task, dynamic, int8, half, nms, batch)
|
|
119
|
+
for task, dynamic, int8, half, nms, batch in product(
|
|
120
|
+
TASKS, [True, False], [True, False], [True, False], [True, False], [1]
|
|
121
|
+
)
|
|
122
|
+
if not (int8 and half)
|
|
123
|
+
and not (task != "detect" and nms)
|
|
124
|
+
and not (dynamic and nms)
|
|
125
|
+
and not (task == "classify" and dynamic)
|
|
126
|
+
],
|
|
127
|
+
)
|
|
128
|
+
def test_export_coreml_matrix(task, dynamic, int8, half, nms, batch):
|
|
129
|
+
"""Test YOLO export to CoreML format with various parameter configurations."""
|
|
130
|
+
file = YOLO(TASK2MODEL[task]).export(
|
|
131
|
+
format="coreml",
|
|
132
|
+
imgsz=32,
|
|
133
|
+
dynamic=dynamic,
|
|
134
|
+
int8=int8,
|
|
135
|
+
half=half,
|
|
136
|
+
batch=batch,
|
|
137
|
+
nms=nms,
|
|
138
|
+
)
|
|
139
|
+
YOLO(file)([SOURCE] * batch, imgsz=32) # exported model inference
|
|
140
|
+
shutil.rmtree(file) # cleanup
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
@pytest.mark.slow
|
|
144
|
+
@pytest.mark.skipif(not checks.IS_PYTHON_MINIMUM_3_10, reason="TFLite export requires Python>=3.10")
|
|
145
|
+
@pytest.mark.skipif(
|
|
146
|
+
not LINUX or IS_RASPBERRYPI,
|
|
147
|
+
reason="Test disabled as TF suffers from install conflicts on Windows, macOS and Raspberry Pi",
|
|
148
|
+
)
|
|
149
|
+
@pytest.mark.parametrize(
|
|
150
|
+
"task, dynamic, int8, half, batch, nms",
|
|
151
|
+
[ # generate all combinations except for exclusion cases
|
|
152
|
+
(task, dynamic, int8, half, batch, nms)
|
|
153
|
+
for task, dynamic, int8, half, batch, nms in product(
|
|
154
|
+
TASKS, [False], [True, False], [True, False], [1], [True, False]
|
|
155
|
+
)
|
|
156
|
+
if not ((int8 and half) or (task == "classify" and nms) or (ARM64 and nms) or (nms and not TORCH_1_13))
|
|
157
|
+
],
|
|
158
|
+
)
|
|
159
|
+
def test_export_tflite_matrix(task, dynamic, int8, half, batch, nms):
|
|
160
|
+
"""Test YOLO export to TFLite format considering various export configurations."""
|
|
161
|
+
file = YOLO(TASK2MODEL[task]).export(
|
|
162
|
+
format="tflite", imgsz=32, dynamic=dynamic, int8=int8, half=half, batch=batch, nms=nms
|
|
163
|
+
)
|
|
164
|
+
YOLO(file)([SOURCE] * batch, imgsz=32) # exported model inference
|
|
165
|
+
Path(file).unlink() # cleanup
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
@pytest.mark.skipif(not TORCH_1_11, reason="CoreML export requires torch>=1.11")
|
|
169
|
+
@pytest.mark.skipif(WINDOWS, reason="CoreML not supported on Windows") # RuntimeError: BlobWriter not loaded
|
|
170
|
+
@pytest.mark.skipif(LINUX and ARM64, reason="CoreML not supported on aarch64 Linux")
|
|
171
|
+
@pytest.mark.skipif(checks.IS_PYTHON_3_13, reason="CoreML not supported in Python 3.13")
|
|
172
|
+
def test_export_coreml():
|
|
173
|
+
"""Test YOLO export to CoreML format and check for errors."""
|
|
174
|
+
# Capture stdout and stderr
|
|
175
|
+
stdout, stderr = io.StringIO(), io.StringIO()
|
|
176
|
+
with redirect_stdout(stdout), redirect_stderr(stderr):
|
|
177
|
+
YOLO(MODEL).export(format="coreml", nms=True, imgsz=32)
|
|
178
|
+
if MACOS:
|
|
179
|
+
file = YOLO(MODEL).export(format="coreml", imgsz=32)
|
|
180
|
+
YOLO(file)(SOURCE, imgsz=32) # model prediction only supported on macOS for nms=False models
|
|
181
|
+
|
|
182
|
+
# Check captured output for errors
|
|
183
|
+
output = stdout.getvalue() + stderr.getvalue()
|
|
184
|
+
assert "Error" not in output, f"CoreML export produced errors: {output}"
|
|
185
|
+
assert "You will not be able to run predict()" not in output, "CoreML export has predict() error"
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
@pytest.mark.skipif(not checks.IS_PYTHON_MINIMUM_3_10, reason="TFLite export requires Python>=3.10")
|
|
189
|
+
@pytest.mark.skipif(not LINUX, reason="Test disabled as TF suffers from install conflicts on Windows and macOS")
|
|
190
|
+
def test_export_tflite():
|
|
191
|
+
"""Test YOLO export to TFLite format under specific OS and Python version conditions."""
|
|
192
|
+
model = YOLO(MODEL)
|
|
193
|
+
file = model.export(format="tflite", imgsz=32)
|
|
194
|
+
YOLO(file)(SOURCE, imgsz=32)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
@pytest.mark.skipif(True, reason="Test disabled")
|
|
198
|
+
@pytest.mark.skipif(not LINUX, reason="TF suffers from install conflicts on Windows and macOS")
|
|
199
|
+
def test_export_pb():
|
|
200
|
+
"""Test YOLO export to TensorFlow's Protobuf (*.pb) format."""
|
|
201
|
+
model = YOLO(MODEL)
|
|
202
|
+
file = model.export(format="pb", imgsz=32)
|
|
203
|
+
YOLO(file)(SOURCE, imgsz=32)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
@pytest.mark.skipif(True, reason="Test disabled as Paddle protobuf and ONNX protobuf requirements conflict.")
|
|
207
|
+
def test_export_paddle():
|
|
208
|
+
"""Test YOLO export to Paddle format, noting protobuf conflicts with ONNX."""
|
|
209
|
+
YOLO(MODEL).export(format="paddle", imgsz=32)
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
@pytest.mark.slow
|
|
213
|
+
@pytest.mark.skipif(not TORCH_1_10, reason="MNN export requires torch>=1.10")
|
|
214
|
+
def test_export_mnn():
|
|
215
|
+
"""Test YOLO export to MNN format (WARNING: MNN test must precede NCNN test or CI error on Windows)."""
|
|
216
|
+
file = YOLO(MODEL).export(format="mnn", imgsz=32)
|
|
217
|
+
YOLO(file)(SOURCE, imgsz=32) # exported model inference
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
@pytest.mark.slow
|
|
221
|
+
@pytest.mark.skipif(not TORCH_1_10, reason="MNN export requires torch>=1.10")
|
|
222
|
+
@pytest.mark.parametrize(
|
|
223
|
+
"task, int8, half, batch",
|
|
224
|
+
[ # generate all combinations except for exclusion cases
|
|
225
|
+
(task, int8, half, batch)
|
|
226
|
+
for task, int8, half, batch in product(TASKS, [True, False], [True, False], [1, 2])
|
|
227
|
+
if not (int8 and half)
|
|
228
|
+
],
|
|
229
|
+
)
|
|
230
|
+
def test_export_mnn_matrix(task, int8, half, batch):
|
|
231
|
+
"""Test YOLO export to MNN format considering various export configurations."""
|
|
232
|
+
file = YOLO(TASK2MODEL[task]).export(format="mnn", imgsz=32, int8=int8, half=half, batch=batch)
|
|
233
|
+
YOLO(file)([SOURCE] * batch, imgsz=32) # exported model inference
|
|
234
|
+
Path(file).unlink() # cleanup
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
@pytest.mark.slow
|
|
238
|
+
def test_export_ncnn():
|
|
239
|
+
"""Test YOLO export to NCNN format."""
|
|
240
|
+
file = YOLO(MODEL).export(format="ncnn", imgsz=32)
|
|
241
|
+
YOLO(file)(SOURCE, imgsz=32) # exported model inference
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
@pytest.mark.slow
|
|
245
|
+
@pytest.mark.parametrize("task, half, batch", list(product(TASKS, [True, False], [1])))
|
|
246
|
+
def test_export_ncnn_matrix(task, half, batch):
|
|
247
|
+
"""Test YOLO export to NCNN format considering various export configurations."""
|
|
248
|
+
file = YOLO(TASK2MODEL[task]).export(format="ncnn", imgsz=32, half=half, batch=batch)
|
|
249
|
+
YOLO(file)([SOURCE] * batch, imgsz=32) # exported model inference
|
|
250
|
+
shutil.rmtree(file, ignore_errors=True) # retry in case of potential lingering multi-threaded file usage errors
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
@pytest.mark.skipif(not TORCH_2_9, reason="IMX export requires torch>=2.9.0")
|
|
254
|
+
@pytest.mark.skipif(not checks.IS_PYTHON_MINIMUM_3_9, reason="Requires Python>=3.9")
|
|
255
|
+
@pytest.mark.skipif(WINDOWS or MACOS, reason="Skipping test on Windows and Macos")
|
|
256
|
+
@pytest.mark.skipif(ARM64, reason="IMX export is not supported on ARM64 architectures.")
|
|
257
|
+
def test_export_imx():
|
|
258
|
+
"""Test YOLO export to IMX format."""
|
|
259
|
+
model = YOLO(MODEL)
|
|
260
|
+
file = model.export(format="imx", imgsz=32)
|
|
261
|
+
YOLO(file)(SOURCE, imgsz=32)
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
@pytest.mark.slow
|
|
265
|
+
@pytest.mark.skipif(not TORCH_2_8, reason="Axelera export requires torch>=2.8.0")
|
|
266
|
+
@pytest.mark.skipif(not LINUX, reason="Axelera export only supported on Linux")
|
|
267
|
+
@pytest.mark.skipif(not checks.IS_PYTHON_3_10, reason="Axelera export requires Python 3.10")
|
|
268
|
+
def test_export_axelera():
|
|
269
|
+
"""Test YOLO export to Axelera format."""
|
|
270
|
+
# For faster testing, use a smaller calibration dataset
|
|
271
|
+
# 32 image size crashes axelera export, so use 64
|
|
272
|
+
file = YOLO(MODEL).export(format="axelera", imgsz=64, data="coco8.yaml")
|
|
273
|
+
assert Path(file).exists(), f"Axelera export failed, directory not found: {file}"
|
|
274
|
+
shutil.rmtree(file, ignore_errors=True) # cleanup
|
|
275
|
+
|
|
276
|
+
|
|
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
|
+
def test_export_executorch():
|
|
280
|
+
"""Test YOLO model export to ExecuTorch format."""
|
|
281
|
+
file = YOLO(MODEL).export(format="executorch", imgsz=32)
|
|
282
|
+
assert Path(file).exists(), f"ExecuTorch export failed, directory not found: {file}"
|
|
283
|
+
# Check that .pte file exists in the exported directory
|
|
284
|
+
pte_file = Path(file) / Path(MODEL).with_suffix(".pte").name
|
|
285
|
+
assert pte_file.exists(), f"ExecuTorch .pte file not found: {pte_file}"
|
|
286
|
+
# Check that metadata.yaml exists
|
|
287
|
+
metadata_file = Path(file) / "metadata.yaml"
|
|
288
|
+
assert metadata_file.exists(), f"ExecuTorch metadata.yaml not found: {metadata_file}"
|
|
289
|
+
# Note: Inference testing skipped as ExecuTorch requires special runtime setup
|
|
290
|
+
shutil.rmtree(file, ignore_errors=True) # cleanup
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
@pytest.mark.slow
|
|
294
|
+
@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")
|
|
295
|
+
@pytest.mark.skipif(WINDOWS, reason="Skipping test on Windows")
|
|
296
|
+
@pytest.mark.parametrize("task", TASKS)
|
|
297
|
+
def test_export_executorch_matrix(task):
|
|
298
|
+
"""Test YOLO export to ExecuTorch format for various task types."""
|
|
299
|
+
file = YOLO(TASK2MODEL[task]).export(format="executorch", imgsz=32)
|
|
300
|
+
assert Path(file).exists(), f"ExecuTorch export failed for task '{task}', directory not found: {file}"
|
|
301
|
+
# Check that .pte file exists in the exported directory
|
|
302
|
+
model_name = Path(TASK2MODEL[task]).with_suffix(".pte").name
|
|
303
|
+
pte_file = Path(file) / model_name
|
|
304
|
+
assert pte_file.exists(), f"ExecuTorch .pte file not found for task '{task}': {pte_file}"
|
|
305
|
+
# Check that metadata.yaml exists
|
|
306
|
+
metadata_file = Path(file) / "metadata.yaml"
|
|
307
|
+
assert metadata_file.exists(), f"ExecuTorch metadata.yaml not found for task '{task}': {metadata_file}"
|
|
308
|
+
# Note: Inference testing skipped as ExecuTorch requires special runtime setup
|
|
309
|
+
shutil.rmtree(file, ignore_errors=True) # cleanup
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
|
2
|
+
|
|
3
|
+
import contextlib
|
|
4
|
+
import os
|
|
5
|
+
import subprocess
|
|
6
|
+
import time
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import pytest
|
|
10
|
+
|
|
11
|
+
from tests import MODEL, SOURCE
|
|
12
|
+
from ultralytics import YOLO, download
|
|
13
|
+
from ultralytics.utils import ASSETS_URL, DATASETS_DIR, SETTINGS
|
|
14
|
+
from ultralytics.utils.checks import check_requirements
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@pytest.mark.slow
|
|
18
|
+
def test_tensorboard():
|
|
19
|
+
"""Test training with TensorBoard logging enabled."""
|
|
20
|
+
SETTINGS["tensorboard"] = True
|
|
21
|
+
YOLO("yolo11n-cls.yaml").train(data="imagenet10", imgsz=32, epochs=3, plots=False, device="cpu")
|
|
22
|
+
SETTINGS["tensorboard"] = False
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@pytest.mark.skipif(not check_requirements("ray", install=False), reason="ray[tune] not installed")
|
|
26
|
+
def test_model_ray_tune():
|
|
27
|
+
"""Tune YOLO model using Ray for hyperparameter optimization."""
|
|
28
|
+
YOLO("yolo11n-cls.yaml").tune(
|
|
29
|
+
use_ray=True, data="imagenet10", grace_period=1, iterations=1, imgsz=32, epochs=1, plots=False, device="cpu"
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@pytest.mark.skipif(not check_requirements("mlflow", install=False), reason="mlflow not installed")
|
|
34
|
+
def test_mlflow():
|
|
35
|
+
"""Test training with MLflow tracking enabled."""
|
|
36
|
+
SETTINGS["mlflow"] = True
|
|
37
|
+
YOLO("yolo11n-cls.yaml").train(data="imagenet10", imgsz=32, epochs=3, plots=False, device="cpu")
|
|
38
|
+
SETTINGS["mlflow"] = False
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@pytest.mark.skipif(True, reason="Test failing in scheduled CI https://github.com/ultralytics/ultralytics/pull/8868")
|
|
42
|
+
@pytest.mark.skipif(not check_requirements("mlflow", install=False), reason="mlflow not installed")
|
|
43
|
+
def test_mlflow_keep_run_active():
|
|
44
|
+
"""Ensure MLflow run status matches MLFLOW_KEEP_RUN_ACTIVE environment variable settings."""
|
|
45
|
+
import mlflow
|
|
46
|
+
|
|
47
|
+
SETTINGS["mlflow"] = True
|
|
48
|
+
run_name = "Test Run"
|
|
49
|
+
os.environ["MLFLOW_RUN"] = run_name
|
|
50
|
+
|
|
51
|
+
# Test with MLFLOW_KEEP_RUN_ACTIVE=True
|
|
52
|
+
os.environ["MLFLOW_KEEP_RUN_ACTIVE"] = "True"
|
|
53
|
+
YOLO("yolo11n-cls.yaml").train(data="imagenet10", imgsz=32, epochs=1, plots=False, device="cpu")
|
|
54
|
+
status = mlflow.active_run().info.status
|
|
55
|
+
assert status == "RUNNING", "MLflow run should be active when MLFLOW_KEEP_RUN_ACTIVE=True"
|
|
56
|
+
|
|
57
|
+
run_id = mlflow.active_run().info.run_id
|
|
58
|
+
|
|
59
|
+
# Test with MLFLOW_KEEP_RUN_ACTIVE=False
|
|
60
|
+
os.environ["MLFLOW_KEEP_RUN_ACTIVE"] = "False"
|
|
61
|
+
YOLO("yolo11n-cls.yaml").train(data="imagenet10", imgsz=32, epochs=1, plots=False, device="cpu")
|
|
62
|
+
status = mlflow.get_run(run_id=run_id).info.status
|
|
63
|
+
assert status == "FINISHED", "MLflow run should be ended when MLFLOW_KEEP_RUN_ACTIVE=False"
|
|
64
|
+
|
|
65
|
+
# Test with MLFLOW_KEEP_RUN_ACTIVE not set
|
|
66
|
+
os.environ.pop("MLFLOW_KEEP_RUN_ACTIVE", None)
|
|
67
|
+
YOLO("yolo11n-cls.yaml").train(data="imagenet10", imgsz=32, epochs=1, plots=False, device="cpu")
|
|
68
|
+
status = mlflow.get_run(run_id=run_id).info.status
|
|
69
|
+
assert status == "FINISHED", "MLflow run should be ended by default when MLFLOW_KEEP_RUN_ACTIVE is not set"
|
|
70
|
+
SETTINGS["mlflow"] = False
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@pytest.mark.skipif(not check_requirements("tritonclient", install=False), reason="tritonclient[all] not installed")
|
|
74
|
+
def test_triton(tmp_path):
|
|
75
|
+
"""Test NVIDIA Triton Server functionalities with YOLO model."""
|
|
76
|
+
check_requirements("tritonclient[all]")
|
|
77
|
+
from tritonclient.http import InferenceServerClient
|
|
78
|
+
|
|
79
|
+
# Create variables
|
|
80
|
+
model_name = "yolo"
|
|
81
|
+
triton_repo = tmp_path / "triton_repo" # Triton repo path
|
|
82
|
+
triton_model = triton_repo / model_name # Triton model path
|
|
83
|
+
|
|
84
|
+
# Export model to ONNX
|
|
85
|
+
f = YOLO(MODEL).export(format="onnx", dynamic=True)
|
|
86
|
+
|
|
87
|
+
# Prepare Triton repo
|
|
88
|
+
(triton_model / "1").mkdir(parents=True, exist_ok=True)
|
|
89
|
+
Path(f).rename(triton_model / "1" / "model.onnx")
|
|
90
|
+
(triton_model / "config.pbtxt").touch()
|
|
91
|
+
|
|
92
|
+
# Define image https://catalog.ngc.nvidia.com/orgs/nvidia/containers/tritonserver
|
|
93
|
+
tag = "nvcr.io/nvidia/tritonserver:23.09-py3" # 6.4 GB
|
|
94
|
+
|
|
95
|
+
# Pull the image
|
|
96
|
+
subprocess.call(f"docker pull {tag}", shell=True)
|
|
97
|
+
|
|
98
|
+
# Run the Triton server and capture the container ID
|
|
99
|
+
container_id = (
|
|
100
|
+
subprocess.check_output(
|
|
101
|
+
f"docker run -d --rm -v {triton_repo}:/models -p 8000:8000 {tag} tritonserver --model-repository=/models",
|
|
102
|
+
shell=True,
|
|
103
|
+
)
|
|
104
|
+
.decode("utf-8")
|
|
105
|
+
.strip()
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
# Wait for the Triton server to start
|
|
109
|
+
triton_client = InferenceServerClient(url="localhost:8000", verbose=False, ssl=False)
|
|
110
|
+
|
|
111
|
+
# Wait until model is ready
|
|
112
|
+
for _ in range(10):
|
|
113
|
+
with contextlib.suppress(Exception):
|
|
114
|
+
assert triton_client.is_model_ready(model_name)
|
|
115
|
+
break
|
|
116
|
+
time.sleep(1)
|
|
117
|
+
|
|
118
|
+
# Check Triton inference
|
|
119
|
+
YOLO(f"http://localhost:8000/{model_name}", "detect")(SOURCE) # exported model inference
|
|
120
|
+
|
|
121
|
+
# Kill and remove the container at the end of the test
|
|
122
|
+
subprocess.call(f"docker kill {container_id}", shell=True)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@pytest.mark.skipif(not check_requirements("faster-coco-eval", install=False), reason="faster-coco-eval not installed")
|
|
126
|
+
def test_faster_coco_eval():
|
|
127
|
+
"""Validate YOLO model predictions on COCO dataset using faster-coco-eval."""
|
|
128
|
+
from ultralytics.models.yolo.detect import DetectionValidator
|
|
129
|
+
from ultralytics.models.yolo.pose import PoseValidator
|
|
130
|
+
from ultralytics.models.yolo.segment import SegmentationValidator
|
|
131
|
+
|
|
132
|
+
args = {"model": "yolo11n.pt", "data": "coco8.yaml", "save_json": True, "imgsz": 64}
|
|
133
|
+
validator = DetectionValidator(args=args)
|
|
134
|
+
validator()
|
|
135
|
+
validator.is_coco = True
|
|
136
|
+
download(f"{ASSETS_URL}/instances_val2017.json", dir=DATASETS_DIR / "coco8/annotations")
|
|
137
|
+
_ = validator.eval_json(validator.stats)
|
|
138
|
+
|
|
139
|
+
args = {"model": "yolo11n-seg.pt", "data": "coco8-seg.yaml", "save_json": True, "imgsz": 64}
|
|
140
|
+
validator = SegmentationValidator(args=args)
|
|
141
|
+
validator()
|
|
142
|
+
validator.is_coco = True
|
|
143
|
+
download(f"{ASSETS_URL}/instances_val2017.json", dir=DATASETS_DIR / "coco8-seg/annotations")
|
|
144
|
+
_ = validator.eval_json(validator.stats)
|
|
145
|
+
|
|
146
|
+
args = {"model": "yolo11n-pose.pt", "data": "coco8-pose.yaml", "save_json": True, "imgsz": 64}
|
|
147
|
+
validator = PoseValidator(args=args)
|
|
148
|
+
validator()
|
|
149
|
+
validator.is_coco = True
|
|
150
|
+
download(f"{ASSETS_URL}/person_keypoints_val2017.json", dir=DATASETS_DIR / "coco8-pose/annotations")
|
|
151
|
+
_ = validator.eval_json(validator.stats)
|