ultralytics-opencv-headless 8.4.2__py3-none-any.whl → 8.4.4__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.
- ultralytics/__init__.py +1 -1
- ultralytics/cfg/__init__.py +19 -19
- ultralytics/data/annotator.py +2 -2
- ultralytics/data/converter.py +9 -9
- ultralytics/engine/exporter.py +23 -24
- ultralytics/engine/model.py +33 -33
- ultralytics/engine/predictor.py +17 -17
- ultralytics/engine/results.py +2 -9
- ultralytics/engine/trainer.py +19 -12
- ultralytics/engine/tuner.py +4 -4
- ultralytics/engine/validator.py +16 -16
- ultralytics/models/yolo/classify/predict.py +1 -1
- ultralytics/models/yolo/classify/train.py +1 -1
- ultralytics/models/yolo/classify/val.py +1 -1
- ultralytics/models/yolo/detect/predict.py +2 -2
- ultralytics/models/yolo/detect/train.py +1 -1
- ultralytics/models/yolo/detect/val.py +1 -1
- ultralytics/models/yolo/model.py +7 -7
- ultralytics/models/yolo/obb/predict.py +1 -1
- ultralytics/models/yolo/obb/train.py +2 -2
- ultralytics/models/yolo/obb/val.py +1 -1
- ultralytics/models/yolo/pose/predict.py +1 -1
- ultralytics/models/yolo/pose/train.py +4 -2
- ultralytics/models/yolo/pose/val.py +1 -1
- ultralytics/models/yolo/segment/predict.py +3 -3
- ultralytics/models/yolo/segment/train.py +3 -3
- ultralytics/models/yolo/segment/val.py +2 -4
- ultralytics/nn/autobackend.py +3 -3
- ultralytics/nn/modules/head.py +1 -1
- ultralytics/nn/tasks.py +12 -12
- ultralytics/solutions/ai_gym.py +3 -3
- ultralytics/solutions/config.py +1 -1
- ultralytics/solutions/heatmap.py +1 -1
- ultralytics/solutions/instance_segmentation.py +2 -2
- ultralytics/solutions/parking_management.py +1 -1
- ultralytics/solutions/solutions.py +2 -2
- ultralytics/trackers/track.py +1 -1
- ultralytics/utils/__init__.py +8 -8
- ultralytics/utils/benchmarks.py +25 -25
- ultralytics/utils/callbacks/platform.py +11 -9
- ultralytics/utils/callbacks/tensorboard.py +2 -0
- ultralytics/utils/checks.py +6 -6
- ultralytics/utils/downloads.py +2 -2
- ultralytics/utils/export/imx.py +24 -17
- ultralytics/utils/files.py +2 -2
- ultralytics/utils/loss.py +3 -3
- ultralytics/utils/tuner.py +2 -2
- {ultralytics_opencv_headless-8.4.2.dist-info → ultralytics_opencv_headless-8.4.4.dist-info}/METADATA +44 -44
- {ultralytics_opencv_headless-8.4.2.dist-info → ultralytics_opencv_headless-8.4.4.dist-info}/RECORD +53 -53
- {ultralytics_opencv_headless-8.4.2.dist-info → ultralytics_opencv_headless-8.4.4.dist-info}/WHEEL +0 -0
- {ultralytics_opencv_headless-8.4.2.dist-info → ultralytics_opencv_headless-8.4.4.dist-info}/entry_points.txt +0 -0
- {ultralytics_opencv_headless-8.4.2.dist-info → ultralytics_opencv_headless-8.4.4.dist-info}/licenses/LICENSE +0 -0
- {ultralytics_opencv_headless-8.4.2.dist-info → ultralytics_opencv_headless-8.4.4.dist-info}/top_level.txt +0 -0
ultralytics/__init__.py
CHANGED
ultralytics/cfg/__init__.py
CHANGED
|
@@ -90,13 +90,13 @@ SOLUTIONS_HELP_MSG = f"""
|
|
|
90
90
|
yolo solutions count source="path/to/video.mp4" region="[(20, 400), (1080, 400), (1080, 360), (20, 360)]"
|
|
91
91
|
|
|
92
92
|
2. Call heatmap solution
|
|
93
|
-
yolo solutions heatmap colormap=cv2.COLORMAP_PARULA model=
|
|
93
|
+
yolo solutions heatmap colormap=cv2.COLORMAP_PARULA model=yolo26n.pt
|
|
94
94
|
|
|
95
95
|
3. Call queue management solution
|
|
96
|
-
yolo solutions queue region="[(20, 400), (1080, 400), (1080, 360), (20, 360)]" model=
|
|
96
|
+
yolo solutions queue region="[(20, 400), (1080, 400), (1080, 360), (20, 360)]" model=yolo26n.pt
|
|
97
97
|
|
|
98
98
|
4. Call workout monitoring solution for push-ups
|
|
99
|
-
yolo solutions workout model=
|
|
99
|
+
yolo solutions workout model=yolo26n-pose.pt kpts=[6, 8, 10]
|
|
100
100
|
|
|
101
101
|
5. Generate analytical graphs
|
|
102
102
|
yolo solutions analytics analytics_type="pie"
|
|
@@ -118,16 +118,16 @@ CLI_HELP_MSG = f"""
|
|
|
118
118
|
See all ARGS at https://docs.ultralytics.com/usage/cfg or with 'yolo cfg'
|
|
119
119
|
|
|
120
120
|
1. Train a detection model for 10 epochs with an initial learning_rate of 0.01
|
|
121
|
-
yolo train data=coco8.yaml model=
|
|
121
|
+
yolo train data=coco8.yaml model=yolo26n.pt epochs=10 lr0=0.01
|
|
122
122
|
|
|
123
123
|
2. Predict a YouTube video using a pretrained segmentation model at image size 320:
|
|
124
|
-
yolo predict model=
|
|
124
|
+
yolo predict model=yolo26n-seg.pt source='https://youtu.be/LNwODJXcvt4' imgsz=320
|
|
125
125
|
|
|
126
126
|
3. Validate a pretrained detection model at batch-size 1 and image size 640:
|
|
127
|
-
yolo val model=
|
|
127
|
+
yolo val model=yolo26n.pt data=coco8.yaml batch=1 imgsz=640
|
|
128
128
|
|
|
129
|
-
4. Export a
|
|
130
|
-
yolo export model=
|
|
129
|
+
4. Export a YOLO26n classification model to ONNX format at image size 224 by 128 (no TASK required)
|
|
130
|
+
yolo export model=yolo26n-cls.pt format=onnx imgsz=224,128
|
|
131
131
|
|
|
132
132
|
5. Ultralytics solutions usage
|
|
133
133
|
yolo solutions count or any of {list(SOLUTION_MAP.keys())[1:-1]} source="path/to/video.mp4"
|
|
@@ -412,7 +412,7 @@ def get_save_dir(args: SimpleNamespace, name: str | None = None) -> Path:
|
|
|
412
412
|
nested = args.project and len(Path(args.project).parts) > 1 # e.g. "user/project" or "org\repo"
|
|
413
413
|
project = runs / args.project if nested else args.project or runs
|
|
414
414
|
name = name or args.name or f"{args.mode}"
|
|
415
|
-
save_dir = increment_path(Path(project) / name, exist_ok=args.exist_ok if RANK in {-1, 0} else True
|
|
415
|
+
save_dir = increment_path(Path(project) / name, exist_ok=args.exist_ok if RANK in {-1, 0} else True)
|
|
416
416
|
|
|
417
417
|
return Path(save_dir).resolve() # resolve to display full path in console
|
|
418
418
|
|
|
@@ -604,7 +604,7 @@ def handle_yolo_settings(args: list[str]) -> None:
|
|
|
604
604
|
|
|
605
605
|
Examples:
|
|
606
606
|
>>> handle_yolo_settings(["reset"]) # Reset YOLO settings
|
|
607
|
-
>>> handle_yolo_settings(["default_cfg_path=
|
|
607
|
+
>>> handle_yolo_settings(["default_cfg_path=yolo26n.yaml"]) # Update a specific setting
|
|
608
608
|
|
|
609
609
|
Notes:
|
|
610
610
|
- If no arguments are provided, the function will display the current settings.
|
|
@@ -649,7 +649,7 @@ def handle_yolo_solutions(args: list[str]) -> None:
|
|
|
649
649
|
>>> handle_yolo_solutions(["analytics", "conf=0.25", "source=path/to/video.mp4"])
|
|
650
650
|
|
|
651
651
|
Run inference with custom configuration, requires Streamlit version 1.29.0 or higher.
|
|
652
|
-
>>> handle_yolo_solutions(["inference", "model=
|
|
652
|
+
>>> handle_yolo_solutions(["inference", "model=yolo26n.pt"])
|
|
653
653
|
|
|
654
654
|
Notes:
|
|
655
655
|
- Arguments can be provided in the format 'key=value' or as boolean flags
|
|
@@ -707,7 +707,7 @@ def handle_yolo_solutions(args: list[str]) -> None:
|
|
|
707
707
|
str(ROOT / "solutions/streamlit_inference.py"),
|
|
708
708
|
"--server.headless",
|
|
709
709
|
"true",
|
|
710
|
-
overrides.pop("model", "
|
|
710
|
+
overrides.pop("model", "yolo26n.pt"),
|
|
711
711
|
]
|
|
712
712
|
)
|
|
713
713
|
else:
|
|
@@ -758,9 +758,9 @@ def parse_key_value_pair(pair: str = "key=value") -> tuple:
|
|
|
758
758
|
AssertionError: If the value is missing or empty.
|
|
759
759
|
|
|
760
760
|
Examples:
|
|
761
|
-
>>> key, value = parse_key_value_pair("model=
|
|
761
|
+
>>> key, value = parse_key_value_pair("model=yolo26n.pt")
|
|
762
762
|
>>> print(f"Key: {key}, Value: {value}")
|
|
763
|
-
Key: model, Value:
|
|
763
|
+
Key: model, Value: yolo26n.pt
|
|
764
764
|
|
|
765
765
|
>>> key, value = parse_key_value_pair("epochs=100")
|
|
766
766
|
>>> print(f"Key: {key}, Value: {value}")
|
|
@@ -832,13 +832,13 @@ def entrypoint(debug: str = "") -> None:
|
|
|
832
832
|
|
|
833
833
|
Examples:
|
|
834
834
|
Train a detection model for 10 epochs with an initial learning_rate of 0.01:
|
|
835
|
-
>>> entrypoint("train data=coco8.yaml model=
|
|
835
|
+
>>> entrypoint("train data=coco8.yaml model=yolo26n.pt epochs=10 lr0=0.01")
|
|
836
836
|
|
|
837
837
|
Predict a YouTube video using a pretrained segmentation model at image size 320:
|
|
838
|
-
>>> entrypoint("predict model=
|
|
838
|
+
>>> entrypoint("predict model=yolo26n-seg.pt source='https://youtu.be/LNwODJXcvt4' imgsz=320")
|
|
839
839
|
|
|
840
840
|
Validate a pretrained detection model at batch-size 1 and image size 640:
|
|
841
|
-
>>> entrypoint("val model=
|
|
841
|
+
>>> entrypoint("val model=yolo26n.pt data=coco8.yaml batch=1 imgsz=640")
|
|
842
842
|
|
|
843
843
|
Notes:
|
|
844
844
|
- If no arguments are passed, the function will display the usage help message.
|
|
@@ -933,7 +933,7 @@ def entrypoint(debug: str = "") -> None:
|
|
|
933
933
|
# Model
|
|
934
934
|
model = overrides.pop("model", DEFAULT_CFG.model)
|
|
935
935
|
if model is None:
|
|
936
|
-
model = "
|
|
936
|
+
model = "yolo26n.pt"
|
|
937
937
|
LOGGER.warning(f"'model' argument is missing. Using default 'model={model}'.")
|
|
938
938
|
overrides["model"] = model
|
|
939
939
|
stem = Path(model).stem.lower()
|
|
@@ -1022,5 +1022,5 @@ def copy_default_cfg() -> None:
|
|
|
1022
1022
|
|
|
1023
1023
|
|
|
1024
1024
|
if __name__ == "__main__":
|
|
1025
|
-
# Example: entrypoint(debug='yolo predict model=
|
|
1025
|
+
# Example: entrypoint(debug='yolo predict model=yolo26n.pt')
|
|
1026
1026
|
entrypoint(debug="")
|
ultralytics/data/annotator.py
CHANGED
|
@@ -9,7 +9,7 @@ from ultralytics import SAM, YOLO
|
|
|
9
9
|
|
|
10
10
|
def auto_annotate(
|
|
11
11
|
data: str | Path,
|
|
12
|
-
det_model: str = "
|
|
12
|
+
det_model: str = "yolo26x.pt",
|
|
13
13
|
sam_model: str = "sam_b.pt",
|
|
14
14
|
device: str = "",
|
|
15
15
|
conf: float = 0.25,
|
|
@@ -39,7 +39,7 @@ def auto_annotate(
|
|
|
39
39
|
|
|
40
40
|
Examples:
|
|
41
41
|
>>> from ultralytics.data.annotator import auto_annotate
|
|
42
|
-
>>> auto_annotate(data="ultralytics/assets", det_model="
|
|
42
|
+
>>> auto_annotate(data="ultralytics/assets", det_model="yolo26n.pt", sam_model="mobile_sam.pt")
|
|
43
43
|
"""
|
|
44
44
|
det_model = YOLO(det_model)
|
|
45
45
|
sam_model = SAM(sam_model)
|
ultralytics/data/converter.py
CHANGED
|
@@ -15,7 +15,7 @@ import numpy as np
|
|
|
15
15
|
from PIL import Image
|
|
16
16
|
|
|
17
17
|
from ultralytics.utils import ASSETS_URL, DATASETS_DIR, LOGGER, NUM_THREADS, TQDM, YAML
|
|
18
|
-
from ultralytics.utils.checks import check_file
|
|
18
|
+
from ultralytics.utils.checks import check_file
|
|
19
19
|
from ultralytics.utils.downloads import download, zip_directory
|
|
20
20
|
from ultralytics.utils.files import increment_path
|
|
21
21
|
|
|
@@ -747,7 +747,7 @@ def convert_to_multispectral(path: str | Path, n_channels: int = 10, replace: bo
|
|
|
747
747
|
|
|
748
748
|
|
|
749
749
|
async def convert_ndjson_to_yolo(ndjson_path: str | Path, output_path: str | Path | None = None) -> Path:
|
|
750
|
-
"""Convert NDJSON dataset format to Ultralytics
|
|
750
|
+
"""Convert NDJSON dataset format to Ultralytics YOLO dataset structure.
|
|
751
751
|
|
|
752
752
|
This function converts datasets stored in NDJSON (Newline Delimited JSON) format to the standard YOLO format. For
|
|
753
753
|
detection/segmentation/pose/obb tasks, it creates separate directories for images and labels. For classification
|
|
@@ -776,9 +776,11 @@ async def convert_ndjson_to_yolo(ndjson_path: str | Path, output_path: str | Pat
|
|
|
776
776
|
|
|
777
777
|
Use with YOLO training
|
|
778
778
|
>>> from ultralytics import YOLO
|
|
779
|
-
>>> model = YOLO("
|
|
779
|
+
>>> model = YOLO("yolo26n.pt")
|
|
780
780
|
>>> model.train(data="https://github.com/ultralytics/assets/releases/download/v0.0.0/coco8-ndjson.ndjson")
|
|
781
781
|
"""
|
|
782
|
+
from ultralytics.utils.checks import check_requirements
|
|
783
|
+
|
|
782
784
|
check_requirements("aiohttp")
|
|
783
785
|
import aiohttp
|
|
784
786
|
|
|
@@ -835,21 +837,19 @@ async def convert_ndjson_to_yolo(ndjson_path: str | Path, output_path: str | Pat
|
|
|
835
837
|
# Download image if URL provided and file doesn't exist
|
|
836
838
|
if http_url := record.get("url"):
|
|
837
839
|
if not image_path.exists():
|
|
838
|
-
image_path.parent.mkdir(parents=True, exist_ok=True)
|
|
840
|
+
image_path.parent.mkdir(parents=True, exist_ok=True)
|
|
839
841
|
try:
|
|
840
842
|
async with session.get(http_url, timeout=aiohttp.ClientTimeout(total=30)) as response:
|
|
841
843
|
response.raise_for_status()
|
|
842
|
-
|
|
843
|
-
async for chunk in response.content.iter_chunked(8192):
|
|
844
|
-
f.write(chunk)
|
|
844
|
+
image_path.write_bytes(await response.read())
|
|
845
845
|
return True
|
|
846
846
|
except Exception as e:
|
|
847
847
|
LOGGER.warning(f"Failed to download {http_url}: {e}")
|
|
848
848
|
return False
|
|
849
849
|
return True
|
|
850
850
|
|
|
851
|
-
# Process all images with async downloads
|
|
852
|
-
semaphore = asyncio.Semaphore(
|
|
851
|
+
# Process all images with async downloads (limit connections for small datasets)
|
|
852
|
+
semaphore = asyncio.Semaphore(min(128, len(image_records)))
|
|
853
853
|
async with aiohttp.ClientSession() as session:
|
|
854
854
|
pbar = TQDM(
|
|
855
855
|
total=len(image_records),
|
ultralytics/engine/exporter.py
CHANGED
|
@@ -4,38 +4,38 @@ Export a YOLO PyTorch model to other formats. TensorFlow exports authored by htt
|
|
|
4
4
|
|
|
5
5
|
Format | `format=argument` | Model
|
|
6
6
|
--- | --- | ---
|
|
7
|
-
PyTorch | - |
|
|
8
|
-
TorchScript | `torchscript` |
|
|
9
|
-
ONNX | `onnx` |
|
|
10
|
-
OpenVINO | `openvino` |
|
|
11
|
-
TensorRT | `engine` |
|
|
12
|
-
CoreML | `coreml` |
|
|
13
|
-
TensorFlow SavedModel | `saved_model` |
|
|
14
|
-
TensorFlow GraphDef | `pb` |
|
|
15
|
-
TensorFlow Lite | `tflite` |
|
|
16
|
-
TensorFlow Edge TPU | `edgetpu` |
|
|
17
|
-
TensorFlow.js | `tfjs` |
|
|
18
|
-
PaddlePaddle | `paddle` |
|
|
19
|
-
MNN | `mnn` |
|
|
20
|
-
NCNN | `ncnn` |
|
|
21
|
-
IMX | `imx` |
|
|
22
|
-
RKNN | `rknn` |
|
|
23
|
-
ExecuTorch | `executorch` |
|
|
24
|
-
Axelera | `axelera` |
|
|
7
|
+
PyTorch | - | yolo26n.pt
|
|
8
|
+
TorchScript | `torchscript` | yolo26n.torchscript
|
|
9
|
+
ONNX | `onnx` | yolo26n.onnx
|
|
10
|
+
OpenVINO | `openvino` | yolo26n_openvino_model/
|
|
11
|
+
TensorRT | `engine` | yolo26n.engine
|
|
12
|
+
CoreML | `coreml` | yolo26n.mlpackage
|
|
13
|
+
TensorFlow SavedModel | `saved_model` | yolo26n_saved_model/
|
|
14
|
+
TensorFlow GraphDef | `pb` | yolo26n.pb
|
|
15
|
+
TensorFlow Lite | `tflite` | yolo26n.tflite
|
|
16
|
+
TensorFlow Edge TPU | `edgetpu` | yolo26n_edgetpu.tflite
|
|
17
|
+
TensorFlow.js | `tfjs` | yolo26n_web_model/
|
|
18
|
+
PaddlePaddle | `paddle` | yolo26n_paddle_model/
|
|
19
|
+
MNN | `mnn` | yolo26n.mnn
|
|
20
|
+
NCNN | `ncnn` | yolo26n_ncnn_model/
|
|
21
|
+
IMX | `imx` | yolo26n_imx_model/
|
|
22
|
+
RKNN | `rknn` | yolo26n_rknn_model/
|
|
23
|
+
ExecuTorch | `executorch` | yolo26n_executorch_model/
|
|
24
|
+
Axelera | `axelera` | yolo26n_axelera_model/
|
|
25
25
|
|
|
26
26
|
Requirements:
|
|
27
27
|
$ pip install "ultralytics[export]"
|
|
28
28
|
|
|
29
29
|
Python:
|
|
30
30
|
from ultralytics import YOLO
|
|
31
|
-
model = YOLO('
|
|
31
|
+
model = YOLO('yolo26n.pt')
|
|
32
32
|
results = model.export(format='onnx')
|
|
33
33
|
|
|
34
34
|
CLI:
|
|
35
|
-
$ yolo mode=export model=
|
|
35
|
+
$ yolo mode=export model=yolo26n.pt format=onnx
|
|
36
36
|
|
|
37
37
|
Inference:
|
|
38
|
-
$ yolo predict model=
|
|
38
|
+
$ yolo predict model=yolo26n.pt # PyTorch
|
|
39
39
|
yolo11n.torchscript # TorchScript
|
|
40
40
|
yolo11n.onnx # ONNX Runtime or OpenCV DNN with dnn=True
|
|
41
41
|
yolo11n_openvino_model # OpenVINO
|
|
@@ -614,12 +614,11 @@ class Exporter:
|
|
|
614
614
|
f"work. Use export 'imgsz={max(self.imgsz)}' if val is required."
|
|
615
615
|
)
|
|
616
616
|
imgsz = self.imgsz[0] if square else str(self.imgsz)[1:-1].replace(" ", "")
|
|
617
|
-
predict_data = f"data={data}" if model.task == "segment" and pb else ""
|
|
618
617
|
q = "int8" if self.args.int8 else "half" if self.args.half else "" # quantization
|
|
619
618
|
LOGGER.info(
|
|
620
619
|
f"\nExport complete ({time.time() - t:.1f}s)"
|
|
621
620
|
f"\nResults saved to {colorstr('bold', file.parent.resolve())}"
|
|
622
|
-
f"\nPredict: yolo predict task={model.task} model={f} imgsz={imgsz} {q}
|
|
621
|
+
f"\nPredict: yolo predict task={model.task} model={f} imgsz={imgsz} {q}"
|
|
623
622
|
f"\nValidate: yolo val task={model.task} model={f} imgsz={imgsz} data={data} {q} {s}"
|
|
624
623
|
f"\nVisualize: https://netron.app"
|
|
625
624
|
)
|
|
@@ -930,7 +929,7 @@ class Exporter:
|
|
|
930
929
|
model = IOSDetectModel(self.model, self.im, mlprogram=not mlmodel) if self.args.nms else self.model
|
|
931
930
|
else:
|
|
932
931
|
if self.args.nms:
|
|
933
|
-
LOGGER.warning(f"{prefix} 'nms=True' is only available for Detect models like '
|
|
932
|
+
LOGGER.warning(f"{prefix} 'nms=True' is only available for Detect models like 'yolo26n.pt'.")
|
|
934
933
|
# TODO CoreML Segment and Pose model pipelining
|
|
935
934
|
model = self.model
|
|
936
935
|
ts = torch.jit.trace(model.eval(), self.im, strict=False) # TorchScript model
|
ultralytics/engine/model.py
CHANGED
|
@@ -71,7 +71,7 @@ class Model(torch.nn.Module):
|
|
|
71
71
|
|
|
72
72
|
Examples:
|
|
73
73
|
>>> from ultralytics import YOLO
|
|
74
|
-
>>> model = YOLO("
|
|
74
|
+
>>> model = YOLO("yolo26n.pt")
|
|
75
75
|
>>> results = model.predict("image.jpg")
|
|
76
76
|
>>> model.train(data="coco8.yaml", epochs=3)
|
|
77
77
|
>>> metrics = model.val()
|
|
@@ -80,7 +80,7 @@ class Model(torch.nn.Module):
|
|
|
80
80
|
|
|
81
81
|
def __init__(
|
|
82
82
|
self,
|
|
83
|
-
model: str | Path | Model = "
|
|
83
|
+
model: str | Path | Model = "yolo26n.pt",
|
|
84
84
|
task: str | None = None,
|
|
85
85
|
verbose: bool = False,
|
|
86
86
|
) -> None:
|
|
@@ -169,7 +169,7 @@ class Model(torch.nn.Module):
|
|
|
169
169
|
object.
|
|
170
170
|
|
|
171
171
|
Examples:
|
|
172
|
-
>>> model = YOLO("
|
|
172
|
+
>>> model = YOLO("yolo26n.pt")
|
|
173
173
|
>>> results = model("https://ultralytics.com/images/bus.jpg")
|
|
174
174
|
>>> for r in results:
|
|
175
175
|
... print(f"Detected {len(r)} objects in image")
|
|
@@ -192,7 +192,7 @@ class Model(torch.nn.Module):
|
|
|
192
192
|
Examples:
|
|
193
193
|
>>> Model.is_triton_model("http://localhost:8000/v2/models/yolo11n")
|
|
194
194
|
True
|
|
195
|
-
>>> Model.is_triton_model("
|
|
195
|
+
>>> Model.is_triton_model("yolo26n.pt")
|
|
196
196
|
False
|
|
197
197
|
"""
|
|
198
198
|
from urllib.parse import urlsplit
|
|
@@ -216,7 +216,7 @@ class Model(torch.nn.Module):
|
|
|
216
216
|
Examples:
|
|
217
217
|
>>> Model.is_hub_model("https://hub.ultralytics.com/models/MODEL")
|
|
218
218
|
True
|
|
219
|
-
>>> Model.is_hub_model("
|
|
219
|
+
>>> Model.is_hub_model("yolo26n.pt")
|
|
220
220
|
False
|
|
221
221
|
"""
|
|
222
222
|
from ultralytics.hub import HUB_WEB_ROOT
|
|
@@ -242,7 +242,7 @@ class Model(torch.nn.Module):
|
|
|
242
242
|
|
|
243
243
|
Examples:
|
|
244
244
|
>>> model = Model()
|
|
245
|
-
>>> model._new("
|
|
245
|
+
>>> model._new("yolo26n.yaml", task="detect", verbose=True)
|
|
246
246
|
"""
|
|
247
247
|
cfg_dict = yaml_model_load(cfg)
|
|
248
248
|
self.cfg = cfg
|
|
@@ -272,12 +272,12 @@ class Model(torch.nn.Module):
|
|
|
272
272
|
|
|
273
273
|
Examples:
|
|
274
274
|
>>> model = Model()
|
|
275
|
-
>>> model._load("
|
|
275
|
+
>>> model._load("yolo26n.pt")
|
|
276
276
|
>>> model._load("path/to/weights.pth", task="detect")
|
|
277
277
|
"""
|
|
278
278
|
if weights.lower().startswith(("https://", "http://", "rtsp://", "rtmp://", "tcp://", "ul://")):
|
|
279
279
|
weights = checks.check_file(weights, download_dir=SETTINGS["weights_dir"]) # download and return local file
|
|
280
|
-
weights = checks.check_model_file_from_stem(weights) # add suffix, i.e.
|
|
280
|
+
weights = checks.check_model_file_from_stem(weights) # add suffix, i.e. yolo26 -> yolo26n.pt
|
|
281
281
|
|
|
282
282
|
if str(weights).rpartition(".")[-1] == "pt":
|
|
283
283
|
self.model, self.ckpt = load_checkpoint(weights)
|
|
@@ -304,7 +304,7 @@ class Model(torch.nn.Module):
|
|
|
304
304
|
information about supported model formats and operations.
|
|
305
305
|
|
|
306
306
|
Examples:
|
|
307
|
-
>>> model = Model("
|
|
307
|
+
>>> model = Model("yolo26n.pt")
|
|
308
308
|
>>> model._check_is_pytorch_model() # No error raised
|
|
309
309
|
>>> model = Model("yolo11n.onnx")
|
|
310
310
|
>>> model._check_is_pytorch_model() # Raises TypeError
|
|
@@ -334,7 +334,7 @@ class Model(torch.nn.Module):
|
|
|
334
334
|
AssertionError: If the model is not a PyTorch model.
|
|
335
335
|
|
|
336
336
|
Examples:
|
|
337
|
-
>>> model = Model("
|
|
337
|
+
>>> model = Model("yolo26n.pt")
|
|
338
338
|
>>> model.reset_weights()
|
|
339
339
|
"""
|
|
340
340
|
self._check_is_pytorch_model()
|
|
@@ -345,7 +345,7 @@ class Model(torch.nn.Module):
|
|
|
345
345
|
p.requires_grad = True
|
|
346
346
|
return self
|
|
347
347
|
|
|
348
|
-
def load(self, weights: str | Path = "
|
|
348
|
+
def load(self, weights: str | Path = "yolo26n.pt") -> Model:
|
|
349
349
|
"""Load parameters from the specified weights file into the model.
|
|
350
350
|
|
|
351
351
|
This method supports loading weights from a file or directly from a weights object. It matches parameters by
|
|
@@ -362,7 +362,7 @@ class Model(torch.nn.Module):
|
|
|
362
362
|
|
|
363
363
|
Examples:
|
|
364
364
|
>>> model = Model()
|
|
365
|
-
>>> model.load("
|
|
365
|
+
>>> model.load("yolo26n.pt")
|
|
366
366
|
>>> model.load(Path("path/to/weights.pt"))
|
|
367
367
|
"""
|
|
368
368
|
self._check_is_pytorch_model()
|
|
@@ -385,7 +385,7 @@ class Model(torch.nn.Module):
|
|
|
385
385
|
AssertionError: If the model is not a PyTorch model.
|
|
386
386
|
|
|
387
387
|
Examples:
|
|
388
|
-
>>> model = Model("
|
|
388
|
+
>>> model = Model("yolo26n.pt")
|
|
389
389
|
>>> model.save("my_model.pt")
|
|
390
390
|
"""
|
|
391
391
|
self._check_is_pytorch_model()
|
|
@@ -419,7 +419,7 @@ class Model(torch.nn.Module):
|
|
|
419
419
|
summary, layer details, and parameter counts. Empty if verbose is True.
|
|
420
420
|
|
|
421
421
|
Examples:
|
|
422
|
-
>>> model = Model("
|
|
422
|
+
>>> model = Model("yolo26n.pt")
|
|
423
423
|
>>> model.info() # Prints model summary
|
|
424
424
|
>>> info_list = model.info(detailed=True, verbose=False) # Returns detailed info as a list
|
|
425
425
|
"""
|
|
@@ -438,7 +438,7 @@ class Model(torch.nn.Module):
|
|
|
438
438
|
performs both convolution and normalization in one step.
|
|
439
439
|
|
|
440
440
|
Examples:
|
|
441
|
-
>>> model = Model("
|
|
441
|
+
>>> model = Model("yolo26n.pt")
|
|
442
442
|
>>> model.fuse()
|
|
443
443
|
>>> # Model is now fused and ready for optimized inference
|
|
444
444
|
"""
|
|
@@ -466,7 +466,7 @@ class Model(torch.nn.Module):
|
|
|
466
466
|
(list[torch.Tensor]): A list containing the image embeddings.
|
|
467
467
|
|
|
468
468
|
Examples:
|
|
469
|
-
>>> model = YOLO("
|
|
469
|
+
>>> model = YOLO("yolo26n.pt")
|
|
470
470
|
>>> image = "https://ultralytics.com/images/bus.jpg"
|
|
471
471
|
>>> embeddings = model.embed(image)
|
|
472
472
|
>>> print(embeddings[0].shape)
|
|
@@ -502,7 +502,7 @@ class Model(torch.nn.Module):
|
|
|
502
502
|
object.
|
|
503
503
|
|
|
504
504
|
Examples:
|
|
505
|
-
>>> model = YOLO("
|
|
505
|
+
>>> model = YOLO("yolo26n.pt")
|
|
506
506
|
>>> results = model.predict(source="path/to/image.jpg", conf=0.25)
|
|
507
507
|
>>> for r in results:
|
|
508
508
|
... print(r.boxes.data) # print detection bounding boxes
|
|
@@ -559,7 +559,7 @@ class Model(torch.nn.Module):
|
|
|
559
559
|
(list[ultralytics.engine.results.Results]): A list of tracking results, each a Results object.
|
|
560
560
|
|
|
561
561
|
Examples:
|
|
562
|
-
>>> model = YOLO("
|
|
562
|
+
>>> model = YOLO("yolo26n.pt")
|
|
563
563
|
>>> results = model.track(source="path/to/video.mp4", show=True)
|
|
564
564
|
>>> for r in results:
|
|
565
565
|
... print(r.boxes.id) # print tracking IDs
|
|
@@ -601,7 +601,7 @@ class Model(torch.nn.Module):
|
|
|
601
601
|
AssertionError: If the model is not a PyTorch model.
|
|
602
602
|
|
|
603
603
|
Examples:
|
|
604
|
-
>>> model = YOLO("
|
|
604
|
+
>>> model = YOLO("yolo26n.pt")
|
|
605
605
|
>>> results = model.val(data="coco8.yaml", imgsz=640)
|
|
606
606
|
>>> print(results.box.map) # Print mAP50-95
|
|
607
607
|
"""
|
|
@@ -639,7 +639,7 @@ class Model(torch.nn.Module):
|
|
|
639
639
|
AssertionError: If the model is not a PyTorch model.
|
|
640
640
|
|
|
641
641
|
Examples:
|
|
642
|
-
>>> model = YOLO("
|
|
642
|
+
>>> model = YOLO("yolo26n.pt")
|
|
643
643
|
>>> results = model.benchmark(data="coco8.yaml", imgsz=640, half=True)
|
|
644
644
|
>>> print(results)
|
|
645
645
|
"""
|
|
@@ -692,7 +692,7 @@ class Model(torch.nn.Module):
|
|
|
692
692
|
RuntimeError: If the export process fails due to errors.
|
|
693
693
|
|
|
694
694
|
Examples:
|
|
695
|
-
>>> model = YOLO("
|
|
695
|
+
>>> model = YOLO("yolo26n.pt")
|
|
696
696
|
>>> model.export(format="onnx", dynamic=True, simplify=True)
|
|
697
697
|
'path/to/exported/model.onnx'
|
|
698
698
|
"""
|
|
@@ -742,7 +742,7 @@ class Model(torch.nn.Module):
|
|
|
742
742
|
(dict | None): Training metrics if available and training is successful; otherwise, None.
|
|
743
743
|
|
|
744
744
|
Examples:
|
|
745
|
-
>>> model = YOLO("
|
|
745
|
+
>>> model = YOLO("yolo26n.pt")
|
|
746
746
|
>>> results = model.train(data="coco8.yaml", epochs=3)
|
|
747
747
|
"""
|
|
748
748
|
self._check_is_pytorch_model()
|
|
@@ -808,7 +808,7 @@ class Model(torch.nn.Module):
|
|
|
808
808
|
TypeError: If the model is not a PyTorch model.
|
|
809
809
|
|
|
810
810
|
Examples:
|
|
811
|
-
>>> model = YOLO("
|
|
811
|
+
>>> model = YOLO("yolo26n.pt")
|
|
812
812
|
>>> results = model.tune(data="coco8.yaml", iterations=5)
|
|
813
813
|
>>> print(results)
|
|
814
814
|
|
|
@@ -845,7 +845,7 @@ class Model(torch.nn.Module):
|
|
|
845
845
|
AssertionError: If the model is not a PyTorch model.
|
|
846
846
|
|
|
847
847
|
Examples:
|
|
848
|
-
>>> model = Model("
|
|
848
|
+
>>> model = Model("yolo26n.pt")
|
|
849
849
|
>>> model = model._apply(lambda t: t.cuda()) # Move model to GPU
|
|
850
850
|
"""
|
|
851
851
|
self._check_is_pytorch_model()
|
|
@@ -870,7 +870,7 @@ class Model(torch.nn.Module):
|
|
|
870
870
|
AttributeError: If the model or predictor does not have a 'names' attribute.
|
|
871
871
|
|
|
872
872
|
Examples:
|
|
873
|
-
>>> model = YOLO("
|
|
873
|
+
>>> model = YOLO("yolo26n.pt")
|
|
874
874
|
>>> print(model.names)
|
|
875
875
|
{0: 'person', 1: 'bicycle', 2: 'car', ...}
|
|
876
876
|
"""
|
|
@@ -898,7 +898,7 @@ class Model(torch.nn.Module):
|
|
|
898
898
|
AttributeError: If the model is not a torch.nn.Module instance.
|
|
899
899
|
|
|
900
900
|
Examples:
|
|
901
|
-
>>> model = YOLO("
|
|
901
|
+
>>> model = YOLO("yolo26n.pt")
|
|
902
902
|
>>> print(model.device)
|
|
903
903
|
device(type='cuda', index=0) # if CUDA is available
|
|
904
904
|
>>> model = model.to("cpu")
|
|
@@ -919,7 +919,7 @@ class Model(torch.nn.Module):
|
|
|
919
919
|
(object | None): The transform object of the model if available, otherwise None.
|
|
920
920
|
|
|
921
921
|
Examples:
|
|
922
|
-
>>> model = YOLO("
|
|
922
|
+
>>> model = YOLO("yolo26n.pt")
|
|
923
923
|
>>> transforms = model.transforms
|
|
924
924
|
>>> if transforms:
|
|
925
925
|
... print(f"Model transforms: {transforms}")
|
|
@@ -947,7 +947,7 @@ class Model(torch.nn.Module):
|
|
|
947
947
|
Examples:
|
|
948
948
|
>>> def on_train_start(trainer):
|
|
949
949
|
... print("Training is starting!")
|
|
950
|
-
>>> model = YOLO("
|
|
950
|
+
>>> model = YOLO("yolo26n.pt")
|
|
951
951
|
>>> model.add_callback("on_train_start", on_train_start)
|
|
952
952
|
>>> model.train(data="coco8.yaml", epochs=1)
|
|
953
953
|
"""
|
|
@@ -965,7 +965,7 @@ class Model(torch.nn.Module):
|
|
|
965
965
|
recognized by the Ultralytics callback system.
|
|
966
966
|
|
|
967
967
|
Examples:
|
|
968
|
-
>>> model = YOLO("
|
|
968
|
+
>>> model = YOLO("yolo26n.pt")
|
|
969
969
|
>>> model.add_callback("on_train_start", lambda: print("Training started"))
|
|
970
970
|
>>> model.clear_callback("on_train_start")
|
|
971
971
|
>>> # All callbacks for 'on_train_start' are now removed
|
|
@@ -994,7 +994,7 @@ class Model(torch.nn.Module):
|
|
|
994
994
|
modifications, ensuring consistent behavior across different runs or experiments.
|
|
995
995
|
|
|
996
996
|
Examples:
|
|
997
|
-
>>> model = YOLO("
|
|
997
|
+
>>> model = YOLO("yolo26n.pt")
|
|
998
998
|
>>> model.add_callback("on_train_start", custom_function)
|
|
999
999
|
>>> model.reset_callbacks()
|
|
1000
1000
|
# All callbacks are now reset to their default functions
|
|
@@ -1076,7 +1076,7 @@ class Model(torch.nn.Module):
|
|
|
1076
1076
|
implementations for that task.
|
|
1077
1077
|
|
|
1078
1078
|
Examples:
|
|
1079
|
-
>>> model = Model("
|
|
1079
|
+
>>> model = Model("yolo26n.pt")
|
|
1080
1080
|
>>> task_map = model.task_map
|
|
1081
1081
|
>>> detect_predictor = task_map["detect"]["predictor"]
|
|
1082
1082
|
>>> segment_trainer = task_map["segment"]["trainer"]
|
|
@@ -1094,7 +1094,7 @@ class Model(torch.nn.Module):
|
|
|
1094
1094
|
(Model): The model instance with evaluation mode set.
|
|
1095
1095
|
|
|
1096
1096
|
Examples:
|
|
1097
|
-
>>> model = YOLO("
|
|
1097
|
+
>>> model = YOLO("yolo26n.pt")
|
|
1098
1098
|
>>> model.eval()
|
|
1099
1099
|
>>> # Model is now in evaluation mode for inference
|
|
1100
1100
|
"""
|
|
@@ -1118,7 +1118,7 @@ class Model(torch.nn.Module):
|
|
|
1118
1118
|
AttributeError: If the requested attribute does not exist in the model.
|
|
1119
1119
|
|
|
1120
1120
|
Examples:
|
|
1121
|
-
>>> model = YOLO("
|
|
1121
|
+
>>> model = YOLO("yolo26n.pt")
|
|
1122
1122
|
>>> print(model.stride) # Access model.stride attribute
|
|
1123
1123
|
>>> print(model.names) # Access model.names attribute
|
|
1124
1124
|
"""
|
ultralytics/engine/predictor.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Run prediction on images, videos, directories, globs, YouTube, webcam, streams, etc.
|
|
4
4
|
|
|
5
5
|
Usage - sources:
|
|
6
|
-
$ yolo mode=predict model=
|
|
6
|
+
$ yolo mode=predict model=yolo26n.pt source=0 # webcam
|
|
7
7
|
img.jpg # image
|
|
8
8
|
vid.mp4 # video
|
|
9
9
|
screen # screenshot
|
|
@@ -15,22 +15,22 @@ Usage - sources:
|
|
|
15
15
|
'rtsp://example.com/media.mp4' # RTSP, RTMP, HTTP, TCP stream
|
|
16
16
|
|
|
17
17
|
Usage - formats:
|
|
18
|
-
$ yolo mode=predict model=
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
18
|
+
$ yolo mode=predict model=yolo26n.pt # PyTorch
|
|
19
|
+
yolo26n.torchscript # TorchScript
|
|
20
|
+
yolo26n.onnx # ONNX Runtime or OpenCV DNN with dnn=True
|
|
21
|
+
yolo26n_openvino_model # OpenVINO
|
|
22
|
+
yolo26n.engine # TensorRT
|
|
23
|
+
yolo26n.mlpackage # CoreML (macOS-only)
|
|
24
|
+
yolo26n_saved_model # TensorFlow SavedModel
|
|
25
|
+
yolo26n.pb # TensorFlow GraphDef
|
|
26
|
+
yolo26n.tflite # TensorFlow Lite
|
|
27
|
+
yolo26n_edgetpu.tflite # TensorFlow Edge TPU
|
|
28
|
+
yolo26n_paddle_model # PaddlePaddle
|
|
29
|
+
yolo26n.mnn # MNN
|
|
30
|
+
yolo26n_ncnn_model # NCNN
|
|
31
|
+
yolo26n_imx_model # Sony IMX
|
|
32
|
+
yolo26n_rknn_model # Rockchip RKNN
|
|
33
|
+
yolo26n.pte # PyTorch Executorch
|
|
34
34
|
"""
|
|
35
35
|
|
|
36
36
|
from __future__ import annotations
|
ultralytics/engine/results.py
CHANGED
|
@@ -667,7 +667,7 @@ class Results(SimpleClass, DataExportMixin):
|
|
|
667
667
|
|
|
668
668
|
Examples:
|
|
669
669
|
>>> from ultralytics import YOLO
|
|
670
|
-
>>> model = YOLO("
|
|
670
|
+
>>> model = YOLO("yolo26n.pt")
|
|
671
671
|
>>> results = model("path/to/image.jpg")
|
|
672
672
|
>>> for result in results:
|
|
673
673
|
>>> result.save_txt("output.txt")
|
|
@@ -782,13 +782,6 @@ class Results(SimpleClass, DataExportMixin):
|
|
|
782
782
|
"confidence": round(conf, decimals),
|
|
783
783
|
}
|
|
784
784
|
)
|
|
785
|
-
results.append(
|
|
786
|
-
{
|
|
787
|
-
"name": self.names[class_id],
|
|
788
|
-
"class": class_id,
|
|
789
|
-
"confidence": round(conf, decimals),
|
|
790
|
-
}
|
|
791
|
-
)
|
|
792
785
|
return results
|
|
793
786
|
|
|
794
787
|
is_obb = self.obb is not None
|
|
@@ -1509,7 +1502,7 @@ class OBB(BaseTensor):
|
|
|
1509
1502
|
Examples:
|
|
1510
1503
|
>>> import torch
|
|
1511
1504
|
>>> from ultralytics import YOLO
|
|
1512
|
-
>>> model = YOLO("
|
|
1505
|
+
>>> model = YOLO("yolo26n-obb.pt")
|
|
1513
1506
|
>>> results = model("path/to/image.jpg")
|
|
1514
1507
|
>>> for result in results:
|
|
1515
1508
|
... obb = result.obb
|