dgenerate-ultralytics-headless 8.3.248__py3-none-any.whl → 8.4.7__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.248.dist-info → dgenerate_ultralytics_headless-8.4.7.dist-info}/METADATA +52 -61
- {dgenerate_ultralytics_headless-8.3.248.dist-info → dgenerate_ultralytics_headless-8.4.7.dist-info}/RECORD +97 -84
- {dgenerate_ultralytics_headless-8.3.248.dist-info → dgenerate_ultralytics_headless-8.4.7.dist-info}/WHEEL +1 -1
- tests/__init__.py +2 -2
- tests/conftest.py +1 -1
- tests/test_cuda.py +8 -2
- tests/test_engine.py +8 -8
- tests/test_exports.py +11 -4
- tests/test_integrations.py +9 -9
- tests/test_python.py +41 -16
- tests/test_solutions.py +3 -3
- ultralytics/__init__.py +1 -1
- ultralytics/cfg/__init__.py +31 -31
- ultralytics/cfg/datasets/TT100K.yaml +346 -0
- ultralytics/cfg/datasets/coco12-formats.yaml +101 -0
- ultralytics/cfg/default.yaml +3 -1
- ultralytics/cfg/models/26/yolo26-cls.yaml +33 -0
- ultralytics/cfg/models/26/yolo26-obb.yaml +52 -0
- ultralytics/cfg/models/26/yolo26-p2.yaml +60 -0
- ultralytics/cfg/models/26/yolo26-p6.yaml +62 -0
- ultralytics/cfg/models/26/yolo26-pose.yaml +53 -0
- ultralytics/cfg/models/26/yolo26-seg.yaml +52 -0
- ultralytics/cfg/models/26/yolo26.yaml +52 -0
- ultralytics/cfg/models/26/yoloe-26-seg.yaml +53 -0
- ultralytics/cfg/models/26/yoloe-26.yaml +53 -0
- ultralytics/data/annotator.py +2 -2
- ultralytics/data/augment.py +15 -0
- ultralytics/data/converter.py +76 -45
- ultralytics/data/dataset.py +1 -1
- ultralytics/data/utils.py +2 -2
- ultralytics/engine/exporter.py +34 -28
- ultralytics/engine/model.py +38 -37
- ultralytics/engine/predictor.py +17 -17
- ultralytics/engine/results.py +22 -15
- ultralytics/engine/trainer.py +83 -48
- ultralytics/engine/tuner.py +20 -11
- ultralytics/engine/validator.py +16 -16
- ultralytics/models/fastsam/predict.py +1 -1
- 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 +6 -3
- ultralytics/models/yolo/detect/val.py +7 -1
- ultralytics/models/yolo/model.py +8 -8
- ultralytics/models/yolo/obb/predict.py +2 -2
- ultralytics/models/yolo/obb/train.py +3 -3
- ultralytics/models/yolo/obb/val.py +1 -1
- ultralytics/models/yolo/pose/predict.py +1 -1
- ultralytics/models/yolo/pose/train.py +3 -1
- ultralytics/models/yolo/pose/val.py +1 -1
- ultralytics/models/yolo/segment/predict.py +3 -3
- ultralytics/models/yolo/segment/train.py +4 -4
- ultralytics/models/yolo/segment/val.py +2 -2
- ultralytics/models/yolo/yoloe/train.py +6 -1
- ultralytics/models/yolo/yoloe/train_seg.py +6 -1
- ultralytics/nn/autobackend.py +14 -8
- ultralytics/nn/modules/__init__.py +8 -0
- ultralytics/nn/modules/block.py +128 -8
- ultralytics/nn/modules/head.py +788 -203
- ultralytics/nn/tasks.py +86 -41
- ultralytics/nn/text_model.py +5 -2
- ultralytics/optim/__init__.py +5 -0
- ultralytics/optim/muon.py +338 -0
- 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/object_counter.py +1 -1
- ultralytics/solutions/parking_management.py +1 -1
- ultralytics/solutions/solutions.py +2 -2
- ultralytics/trackers/byte_tracker.py +7 -7
- ultralytics/trackers/track.py +1 -1
- ultralytics/utils/__init__.py +8 -8
- ultralytics/utils/benchmarks.py +26 -26
- ultralytics/utils/callbacks/platform.py +173 -64
- ultralytics/utils/callbacks/tensorboard.py +2 -0
- ultralytics/utils/callbacks/wb.py +6 -1
- ultralytics/utils/checks.py +28 -9
- ultralytics/utils/dist.py +1 -0
- ultralytics/utils/downloads.py +5 -3
- ultralytics/utils/export/engine.py +19 -10
- ultralytics/utils/export/imx.py +38 -20
- ultralytics/utils/export/tensorflow.py +21 -21
- ultralytics/utils/files.py +2 -2
- ultralytics/utils/loss.py +597 -203
- ultralytics/utils/metrics.py +2 -1
- ultralytics/utils/ops.py +11 -2
- ultralytics/utils/patches.py +42 -0
- ultralytics/utils/plotting.py +3 -0
- ultralytics/utils/tal.py +100 -20
- ultralytics/utils/torch_utils.py +1 -1
- ultralytics/utils/tqdm.py +4 -1
- ultralytics/utils/tuner.py +2 -5
- {dgenerate_ultralytics_headless-8.3.248.dist-info → dgenerate_ultralytics_headless-8.4.7.dist-info}/entry_points.txt +0 -0
- {dgenerate_ultralytics_headless-8.3.248.dist-info → dgenerate_ultralytics_headless-8.4.7.dist-info}/licenses/LICENSE +0 -0
- {dgenerate_ultralytics_headless-8.3.248.dist-info → dgenerate_ultralytics_headless-8.4.7.dist-info}/top_level.txt +0 -0
ultralytics/utils/export/imx.py
CHANGED
|
@@ -21,27 +21,39 @@ from ultralytics.utils.torch_utils import copy_attr
|
|
|
21
21
|
MCT_CONFIG = {
|
|
22
22
|
"YOLO11": {
|
|
23
23
|
"detect": {
|
|
24
|
-
"layer_names": ["sub", "mul_2", "add_14", "
|
|
24
|
+
"layer_names": ["sub", "mul_2", "add_14", "cat_19"],
|
|
25
25
|
"weights_memory": 2585350.2439,
|
|
26
|
-
"n_layers": 238,
|
|
26
|
+
"n_layers": {238, 239},
|
|
27
27
|
},
|
|
28
28
|
"pose": {
|
|
29
|
-
"layer_names": ["sub", "mul_2", "add_14", "
|
|
29
|
+
"layer_names": ["sub", "mul_2", "add_14", "cat_21", "cat_22", "mul_4", "add_15"],
|
|
30
30
|
"weights_memory": 2437771.67,
|
|
31
|
-
"n_layers": 257,
|
|
31
|
+
"n_layers": {257, 258},
|
|
32
|
+
},
|
|
33
|
+
"classify": {"layer_names": [], "weights_memory": np.inf, "n_layers": {112}},
|
|
34
|
+
"segment": {
|
|
35
|
+
"layer_names": ["sub", "mul_2", "add_14", "cat_21"],
|
|
36
|
+
"weights_memory": 2466604.8,
|
|
37
|
+
"n_layers": {265, 266},
|
|
32
38
|
},
|
|
33
|
-
"classify": {"layer_names": [], "weights_memory": np.inf, "n_layers": 112},
|
|
34
|
-
"segment": {"layer_names": ["sub", "mul_2", "add_14", "cat_22"], "weights_memory": 2466604.8, "n_layers": 265},
|
|
35
39
|
},
|
|
36
40
|
"YOLOv8": {
|
|
37
|
-
"detect": {
|
|
41
|
+
"detect": {
|
|
42
|
+
"layer_names": ["sub", "mul", "add_6", "cat_15"],
|
|
43
|
+
"weights_memory": 2550540.8,
|
|
44
|
+
"n_layers": {168, 169},
|
|
45
|
+
},
|
|
38
46
|
"pose": {
|
|
39
|
-
"layer_names": ["add_7", "mul_2", "
|
|
47
|
+
"layer_names": ["add_7", "mul_2", "cat_17", "mul", "sub", "add_6", "cat_18"],
|
|
40
48
|
"weights_memory": 2482451.85,
|
|
41
|
-
"n_layers": 187,
|
|
49
|
+
"n_layers": {187, 188},
|
|
50
|
+
},
|
|
51
|
+
"classify": {"layer_names": [], "weights_memory": np.inf, "n_layers": {73}},
|
|
52
|
+
"segment": {
|
|
53
|
+
"layer_names": ["sub", "mul", "add_6", "cat_17"],
|
|
54
|
+
"weights_memory": 2580060.0,
|
|
55
|
+
"n_layers": {195, 196},
|
|
42
56
|
},
|
|
43
|
-
"classify": {"layer_names": [], "weights_memory": np.inf, "n_layers": 73},
|
|
44
|
-
"segment": {"layer_names": ["sub", "mul", "add_6", "cat_18"], "weights_memory": 2580060.0, "n_layers": 195},
|
|
45
57
|
},
|
|
46
58
|
}
|
|
47
59
|
|
|
@@ -104,20 +116,26 @@ class FXModel(torch.nn.Module):
|
|
|
104
116
|
return x
|
|
105
117
|
|
|
106
118
|
|
|
107
|
-
def _inference(self, x:
|
|
119
|
+
def _inference(self, x: dict[str, torch.Tensor]) -> tuple[torch.Tensor]:
|
|
108
120
|
"""Decode boxes and cls scores for imx object detection."""
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
dbox = self.decode_bboxes(self.dfl(box), self.anchors.unsqueeze(0)) * self.strides
|
|
112
|
-
return dbox.transpose(1, 2), cls.sigmoid().permute(0, 2, 1)
|
|
121
|
+
dbox = self.decode_bboxes(self.dfl(x["boxes"]), self.anchors.unsqueeze(0)) * self.strides
|
|
122
|
+
return dbox.transpose(1, 2), x["scores"].sigmoid().permute(0, 2, 1)
|
|
113
123
|
|
|
114
124
|
|
|
115
125
|
def pose_forward(self, x: list[torch.Tensor]) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
|
116
126
|
"""Forward pass for imx pose estimation, including keypoint decoding."""
|
|
117
127
|
bs = x[0].shape[0] # batch size
|
|
118
|
-
|
|
128
|
+
nk_out = getattr(self, "nk_output", self.nk)
|
|
129
|
+
kpt = torch.cat([self.cv4[i](x[i]).view(bs, nk_out, -1) for i in range(self.nl)], -1)
|
|
130
|
+
|
|
131
|
+
# If using Pose26 with 5 dims, convert to 3 dims for export
|
|
132
|
+
if hasattr(self, "nk_output") and self.nk_output != self.nk:
|
|
133
|
+
spatial = kpt.shape[-1]
|
|
134
|
+
kpt = kpt.view(bs, self.kpt_shape[0], self.kpt_shape[1] + 2, spatial)
|
|
135
|
+
kpt = kpt[:, :, :-2, :] # Remove sigma_x, sigma_y
|
|
136
|
+
kpt = kpt.view(bs, self.nk, spatial)
|
|
119
137
|
x = Detect.forward(self, x)
|
|
120
|
-
pred_kpt = self.kpts_decode(
|
|
138
|
+
pred_kpt = self.kpts_decode(kpt)
|
|
121
139
|
return *x, pred_kpt.permute(0, 2, 1)
|
|
122
140
|
|
|
123
141
|
|
|
@@ -219,7 +237,7 @@ def torch2imx(
|
|
|
219
237
|
Examples:
|
|
220
238
|
>>> from ultralytics import YOLO
|
|
221
239
|
>>> model = YOLO("yolo11n.pt")
|
|
222
|
-
>>> path, _ = export_imx(model, "model.imx", conf=0.25, iou=0.
|
|
240
|
+
>>> path, _ = export_imx(model, "model.imx", conf=0.25, iou=0.7, max_det=300)
|
|
223
241
|
|
|
224
242
|
Notes:
|
|
225
243
|
- Requires model_compression_toolkit, onnx, edgemdt_tpc, and edge-mdt-cl packages
|
|
@@ -245,7 +263,7 @@ def torch2imx(
|
|
|
245
263
|
mct_config = MCT_CONFIG["YOLO11" if "C2PSA" in model.__str__() else "YOLOv8"][model.task]
|
|
246
264
|
|
|
247
265
|
# Check if the model has the expected number of layers
|
|
248
|
-
if len(list(model.modules()))
|
|
266
|
+
if len(list(model.modules())) not in mct_config["n_layers"]:
|
|
249
267
|
raise ValueError("IMX export only supported for YOLOv8n and YOLO11n models.")
|
|
250
268
|
|
|
251
269
|
for layer_name in mct_config["layer_names"]:
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
from functools import partial
|
|
5
6
|
from pathlib import Path
|
|
6
7
|
|
|
7
8
|
import numpy as np
|
|
8
9
|
import torch
|
|
9
10
|
|
|
10
|
-
from ultralytics.nn.modules import Detect, Pose
|
|
11
|
+
from ultralytics.nn.modules import Detect, Pose, Pose26
|
|
11
12
|
from ultralytics.utils import LOGGER
|
|
12
13
|
from ultralytics.utils.downloads import attempt_download_asset
|
|
13
14
|
from ultralytics.utils.files import spaces_in_path
|
|
@@ -15,43 +16,42 @@ from ultralytics.utils.tal import make_anchors
|
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
def tf_wrapper(model: torch.nn.Module) -> torch.nn.Module:
|
|
18
|
-
"""A wrapper
|
|
19
|
+
"""A wrapper for TensorFlow export compatibility (TF-specific handling is now in head modules)."""
|
|
19
20
|
for m in model.modules():
|
|
20
21
|
if not isinstance(m, Detect):
|
|
21
22
|
continue
|
|
22
23
|
import types
|
|
23
24
|
|
|
24
|
-
m.
|
|
25
|
-
if
|
|
26
|
-
m.kpts_decode = types.MethodType(
|
|
25
|
+
m._get_decode_boxes = types.MethodType(_tf_decode_boxes, m)
|
|
26
|
+
if isinstance(m, Pose):
|
|
27
|
+
m.kpts_decode = types.MethodType(partial(_tf_kpts_decode, is_pose26=type(m) is Pose26), m)
|
|
27
28
|
return model
|
|
28
29
|
|
|
29
30
|
|
|
30
|
-
def
|
|
31
|
-
"""Decode boxes
|
|
32
|
-
shape = x[0].shape # BCHW
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
self.anchors, self.strides = (x.transpose(0, 1) for x in make_anchors(x, self.stride, 0.5))
|
|
31
|
+
def _tf_decode_boxes(self, x: dict[str, torch.Tensor]) -> torch.Tensor:
|
|
32
|
+
"""Decode bounding boxes for TensorFlow export."""
|
|
33
|
+
shape = x["feats"][0].shape # BCHW
|
|
34
|
+
boxes = x["boxes"]
|
|
35
|
+
if self.format != "imx" and (self.dynamic or self.shape != shape):
|
|
36
|
+
self.anchors, self.strides = (a.transpose(0, 1) for a in make_anchors(x["feats"], self.stride, 0.5))
|
|
37
37
|
self.shape = shape
|
|
38
|
-
grid_h, grid_w = shape[2]
|
|
39
|
-
grid_size = torch.tensor([grid_w, grid_h, grid_w, grid_h], device=
|
|
38
|
+
grid_h, grid_w = shape[2:4]
|
|
39
|
+
grid_size = torch.tensor([grid_w, grid_h, grid_w, grid_h], device=boxes.device).reshape(1, 4, 1)
|
|
40
40
|
norm = self.strides / (self.stride[0] * grid_size)
|
|
41
|
-
dbox = self.decode_bboxes(self.dfl(
|
|
42
|
-
return
|
|
41
|
+
dbox = self.decode_bboxes(self.dfl(boxes) * norm, self.anchors.unsqueeze(0) * norm[:, :2])
|
|
42
|
+
return dbox
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
def
|
|
46
|
-
"""Decode keypoints for
|
|
45
|
+
def _tf_kpts_decode(self, kpts: torch.Tensor, is_pose26: bool = False) -> torch.Tensor:
|
|
46
|
+
"""Decode keypoints for TensorFlow export."""
|
|
47
47
|
ndim = self.kpt_shape[1]
|
|
48
|
-
|
|
48
|
+
bs = kpts.shape[0]
|
|
49
49
|
# Precompute normalization factor to increase numerical stability
|
|
50
50
|
y = kpts.view(bs, *self.kpt_shape, -1)
|
|
51
|
-
grid_h, grid_w = self.shape[2]
|
|
51
|
+
grid_h, grid_w = self.shape[2:4]
|
|
52
52
|
grid_size = torch.tensor([grid_w, grid_h], device=y.device).reshape(1, 2, 1)
|
|
53
53
|
norm = self.strides / (self.stride[0] * grid_size)
|
|
54
|
-
a = (y[:, :, :2] * 2.0 + (self.anchors - 0.5)) * norm
|
|
54
|
+
a = ((y[:, :, :2] + self.anchors) if is_pose26 else (y[:, :, :2] * 2.0 + (self.anchors - 0.5))) * norm
|
|
55
55
|
if ndim == 3:
|
|
56
56
|
a = torch.cat((a, y[:, :, 2:3].sigmoid()), 2)
|
|
57
57
|
return a.view(bs, self.nk, -1)
|
ultralytics/utils/files.py
CHANGED
|
@@ -180,7 +180,7 @@ def get_latest_run(search_dir: str = ".") -> str:
|
|
|
180
180
|
return max(last_list, key=os.path.getctime) if last_list else ""
|
|
181
181
|
|
|
182
182
|
|
|
183
|
-
def update_models(model_names: tuple = ("
|
|
183
|
+
def update_models(model_names: tuple = ("yolo26n.pt",), source_dir: Path = Path("."), update_names: bool = False):
|
|
184
184
|
"""Update and re-save specified YOLO models in an 'updated_models' subdirectory.
|
|
185
185
|
|
|
186
186
|
Args:
|
|
@@ -191,7 +191,7 @@ def update_models(model_names: tuple = ("yolo11n.pt",), source_dir: Path = Path(
|
|
|
191
191
|
Examples:
|
|
192
192
|
Update specified YOLO models and save them in 'updated_models' subdirectory:
|
|
193
193
|
>>> from ultralytics.utils.files import update_models
|
|
194
|
-
>>> model_names = ("
|
|
194
|
+
>>> model_names = ("yolo26n.pt", "yolo11s.pt")
|
|
195
195
|
>>> update_models(model_names, source_dir=Path("/models"), update_names=True)
|
|
196
196
|
"""
|
|
197
197
|
from ultralytics import YOLO
|