dgenerate-ultralytics-headless 8.3.214__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.214.dist-info → dgenerate_ultralytics_headless-8.4.7.dist-info}/METADATA +64 -74
- dgenerate_ultralytics_headless-8.4.7.dist-info/RECORD +311 -0
- {dgenerate_ultralytics_headless-8.3.214.dist-info → dgenerate_ultralytics_headless-8.4.7.dist-info}/WHEEL +1 -1
- tests/__init__.py +7 -9
- tests/conftest.py +8 -15
- tests/test_cli.py +1 -1
- tests/test_cuda.py +13 -10
- tests/test_engine.py +9 -9
- tests/test_exports.py +65 -13
- tests/test_integrations.py +13 -13
- tests/test_python.py +125 -69
- tests/test_solutions.py +161 -152
- ultralytics/__init__.py +1 -1
- ultralytics/cfg/__init__.py +86 -92
- ultralytics/cfg/datasets/Argoverse.yaml +7 -6
- ultralytics/cfg/datasets/DOTAv1.5.yaml +1 -1
- ultralytics/cfg/datasets/DOTAv1.yaml +1 -1
- ultralytics/cfg/datasets/ImageNet.yaml +1 -1
- ultralytics/cfg/datasets/TT100K.yaml +346 -0
- ultralytics/cfg/datasets/VOC.yaml +15 -16
- ultralytics/cfg/datasets/african-wildlife.yaml +1 -1
- ultralytics/cfg/datasets/coco-pose.yaml +21 -0
- ultralytics/cfg/datasets/coco12-formats.yaml +101 -0
- ultralytics/cfg/datasets/coco128-seg.yaml +1 -1
- ultralytics/cfg/datasets/coco8-pose.yaml +21 -0
- ultralytics/cfg/datasets/dog-pose.yaml +28 -0
- ultralytics/cfg/datasets/dota8-multispectral.yaml +1 -1
- ultralytics/cfg/datasets/dota8.yaml +2 -2
- ultralytics/cfg/datasets/hand-keypoints.yaml +26 -2
- ultralytics/cfg/datasets/kitti.yaml +27 -0
- ultralytics/cfg/datasets/lvis.yaml +5 -5
- ultralytics/cfg/datasets/open-images-v7.yaml +1 -1
- ultralytics/cfg/datasets/tiger-pose.yaml +16 -0
- ultralytics/cfg/datasets/xView.yaml +16 -16
- ultralytics/cfg/default.yaml +4 -2
- ultralytics/cfg/models/11/yolo11-pose.yaml +1 -1
- ultralytics/cfg/models/11/yoloe-11-seg.yaml +2 -2
- ultralytics/cfg/models/11/yoloe-11.yaml +2 -2
- 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/cfg/models/rt-detr/rtdetr-l.yaml +1 -1
- ultralytics/cfg/models/rt-detr/rtdetr-resnet101.yaml +1 -1
- ultralytics/cfg/models/rt-detr/rtdetr-resnet50.yaml +1 -1
- ultralytics/cfg/models/rt-detr/rtdetr-x.yaml +1 -1
- ultralytics/cfg/models/v10/yolov10b.yaml +2 -2
- ultralytics/cfg/models/v10/yolov10l.yaml +2 -2
- ultralytics/cfg/models/v10/yolov10m.yaml +2 -2
- ultralytics/cfg/models/v10/yolov10n.yaml +2 -2
- ultralytics/cfg/models/v10/yolov10s.yaml +2 -2
- ultralytics/cfg/models/v10/yolov10x.yaml +2 -2
- ultralytics/cfg/models/v3/yolov3-tiny.yaml +1 -1
- ultralytics/cfg/models/v6/yolov6.yaml +1 -1
- ultralytics/cfg/models/v8/yoloe-v8-seg.yaml +9 -6
- ultralytics/cfg/models/v8/yoloe-v8.yaml +9 -6
- ultralytics/cfg/models/v8/yolov8-cls-resnet101.yaml +1 -1
- ultralytics/cfg/models/v8/yolov8-cls-resnet50.yaml +1 -1
- ultralytics/cfg/models/v8/yolov8-ghost-p2.yaml +2 -2
- ultralytics/cfg/models/v8/yolov8-ghost-p6.yaml +2 -2
- ultralytics/cfg/models/v8/yolov8-ghost.yaml +2 -2
- ultralytics/cfg/models/v8/yolov8-obb.yaml +1 -1
- ultralytics/cfg/models/v8/yolov8-p2.yaml +1 -1
- ultralytics/cfg/models/v8/yolov8-pose-p6.yaml +1 -1
- ultralytics/cfg/models/v8/yolov8-rtdetr.yaml +1 -1
- ultralytics/cfg/models/v8/yolov8-seg-p6.yaml +1 -1
- ultralytics/cfg/models/v8/yolov8-world.yaml +1 -1
- ultralytics/cfg/models/v8/yolov8-worldv2.yaml +6 -6
- ultralytics/cfg/models/v9/yolov9s.yaml +1 -1
- ultralytics/data/__init__.py +4 -4
- ultralytics/data/annotator.py +5 -6
- ultralytics/data/augment.py +300 -475
- ultralytics/data/base.py +18 -26
- ultralytics/data/build.py +147 -25
- ultralytics/data/converter.py +108 -87
- ultralytics/data/dataset.py +47 -75
- ultralytics/data/loaders.py +42 -49
- ultralytics/data/split.py +5 -6
- ultralytics/data/split_dota.py +8 -15
- ultralytics/data/utils.py +36 -45
- ultralytics/engine/exporter.py +351 -263
- ultralytics/engine/model.py +186 -225
- ultralytics/engine/predictor.py +45 -54
- ultralytics/engine/results.py +198 -325
- ultralytics/engine/trainer.py +165 -106
- ultralytics/engine/tuner.py +41 -43
- ultralytics/engine/validator.py +55 -38
- ultralytics/hub/__init__.py +16 -19
- ultralytics/hub/auth.py +6 -12
- ultralytics/hub/google/__init__.py +7 -10
- ultralytics/hub/session.py +15 -25
- ultralytics/hub/utils.py +5 -8
- ultralytics/models/__init__.py +1 -1
- ultralytics/models/fastsam/__init__.py +1 -1
- ultralytics/models/fastsam/model.py +8 -10
- ultralytics/models/fastsam/predict.py +18 -30
- ultralytics/models/fastsam/utils.py +1 -2
- ultralytics/models/fastsam/val.py +5 -7
- ultralytics/models/nas/__init__.py +1 -1
- ultralytics/models/nas/model.py +5 -8
- ultralytics/models/nas/predict.py +7 -9
- ultralytics/models/nas/val.py +1 -2
- ultralytics/models/rtdetr/__init__.py +1 -1
- ultralytics/models/rtdetr/model.py +5 -8
- ultralytics/models/rtdetr/predict.py +15 -19
- ultralytics/models/rtdetr/train.py +10 -13
- ultralytics/models/rtdetr/val.py +21 -23
- ultralytics/models/sam/__init__.py +15 -2
- ultralytics/models/sam/amg.py +14 -20
- ultralytics/models/sam/build.py +26 -19
- ultralytics/models/sam/build_sam3.py +377 -0
- ultralytics/models/sam/model.py +29 -32
- ultralytics/models/sam/modules/blocks.py +83 -144
- ultralytics/models/sam/modules/decoders.py +19 -37
- ultralytics/models/sam/modules/encoders.py +44 -101
- ultralytics/models/sam/modules/memory_attention.py +16 -30
- ultralytics/models/sam/modules/sam.py +200 -73
- ultralytics/models/sam/modules/tiny_encoder.py +64 -83
- ultralytics/models/sam/modules/transformer.py +18 -28
- ultralytics/models/sam/modules/utils.py +174 -50
- ultralytics/models/sam/predict.py +2248 -350
- 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/loss.py +14 -26
- ultralytics/models/utils/ops.py +13 -17
- ultralytics/models/yolo/__init__.py +1 -1
- ultralytics/models/yolo/classify/predict.py +10 -13
- ultralytics/models/yolo/classify/train.py +12 -33
- ultralytics/models/yolo/classify/val.py +30 -29
- ultralytics/models/yolo/detect/predict.py +9 -12
- ultralytics/models/yolo/detect/train.py +17 -23
- ultralytics/models/yolo/detect/val.py +77 -59
- ultralytics/models/yolo/model.py +43 -60
- ultralytics/models/yolo/obb/predict.py +7 -16
- ultralytics/models/yolo/obb/train.py +14 -17
- ultralytics/models/yolo/obb/val.py +40 -37
- ultralytics/models/yolo/pose/__init__.py +1 -1
- ultralytics/models/yolo/pose/predict.py +7 -22
- ultralytics/models/yolo/pose/train.py +13 -16
- ultralytics/models/yolo/pose/val.py +39 -58
- ultralytics/models/yolo/segment/predict.py +17 -21
- ultralytics/models/yolo/segment/train.py +7 -10
- ultralytics/models/yolo/segment/val.py +95 -47
- ultralytics/models/yolo/world/train.py +8 -14
- ultralytics/models/yolo/world/train_world.py +11 -34
- ultralytics/models/yolo/yoloe/__init__.py +7 -7
- ultralytics/models/yolo/yoloe/predict.py +16 -23
- ultralytics/models/yolo/yoloe/train.py +36 -44
- ultralytics/models/yolo/yoloe/train_seg.py +11 -11
- ultralytics/models/yolo/yoloe/val.py +15 -20
- ultralytics/nn/__init__.py +7 -7
- ultralytics/nn/autobackend.py +159 -85
- ultralytics/nn/modules/__init__.py +68 -60
- ultralytics/nn/modules/activation.py +4 -6
- ultralytics/nn/modules/block.py +260 -224
- ultralytics/nn/modules/conv.py +52 -97
- ultralytics/nn/modules/head.py +831 -299
- ultralytics/nn/modules/transformer.py +76 -88
- ultralytics/nn/modules/utils.py +16 -21
- ultralytics/nn/tasks.py +180 -195
- ultralytics/nn/text_model.py +45 -69
- ultralytics/optim/__init__.py +5 -0
- ultralytics/optim/muon.py +338 -0
- ultralytics/solutions/__init__.py +12 -12
- ultralytics/solutions/ai_gym.py +13 -19
- ultralytics/solutions/analytics.py +15 -16
- ultralytics/solutions/config.py +6 -7
- ultralytics/solutions/distance_calculation.py +10 -13
- ultralytics/solutions/heatmap.py +8 -14
- ultralytics/solutions/instance_segmentation.py +6 -9
- ultralytics/solutions/object_blurrer.py +7 -10
- ultralytics/solutions/object_counter.py +12 -19
- ultralytics/solutions/object_cropper.py +8 -14
- ultralytics/solutions/parking_management.py +34 -32
- ultralytics/solutions/queue_management.py +10 -12
- ultralytics/solutions/region_counter.py +9 -12
- ultralytics/solutions/security_alarm.py +15 -20
- ultralytics/solutions/similarity_search.py +10 -15
- ultralytics/solutions/solutions.py +77 -76
- ultralytics/solutions/speed_estimation.py +7 -10
- ultralytics/solutions/streamlit_inference.py +2 -4
- ultralytics/solutions/templates/similarity-search.html +7 -18
- ultralytics/solutions/trackzone.py +7 -10
- ultralytics/solutions/vision_eye.py +5 -8
- ultralytics/trackers/__init__.py +1 -1
- ultralytics/trackers/basetrack.py +3 -5
- ultralytics/trackers/bot_sort.py +10 -27
- ultralytics/trackers/byte_tracker.py +21 -37
- ultralytics/trackers/track.py +4 -7
- ultralytics/trackers/utils/gmc.py +11 -22
- ultralytics/trackers/utils/kalman_filter.py +37 -48
- ultralytics/trackers/utils/matching.py +12 -15
- ultralytics/utils/__init__.py +124 -124
- ultralytics/utils/autobatch.py +2 -4
- ultralytics/utils/autodevice.py +17 -18
- ultralytics/utils/benchmarks.py +57 -71
- ultralytics/utils/callbacks/base.py +8 -10
- ultralytics/utils/callbacks/clearml.py +5 -13
- ultralytics/utils/callbacks/comet.py +32 -46
- ultralytics/utils/callbacks/dvc.py +13 -18
- ultralytics/utils/callbacks/mlflow.py +4 -5
- ultralytics/utils/callbacks/neptune.py +7 -15
- ultralytics/utils/callbacks/platform.py +423 -38
- ultralytics/utils/callbacks/raytune.py +3 -4
- ultralytics/utils/callbacks/tensorboard.py +25 -31
- ultralytics/utils/callbacks/wb.py +16 -14
- ultralytics/utils/checks.py +127 -85
- ultralytics/utils/cpu.py +3 -8
- ultralytics/utils/dist.py +9 -12
- ultralytics/utils/downloads.py +25 -33
- ultralytics/utils/errors.py +6 -14
- ultralytics/utils/events.py +2 -4
- ultralytics/utils/export/__init__.py +4 -236
- ultralytics/utils/export/engine.py +246 -0
- ultralytics/utils/export/imx.py +117 -63
- ultralytics/utils/export/tensorflow.py +231 -0
- ultralytics/utils/files.py +26 -30
- ultralytics/utils/git.py +9 -11
- ultralytics/utils/instance.py +30 -51
- ultralytics/utils/logger.py +212 -114
- ultralytics/utils/loss.py +601 -215
- ultralytics/utils/metrics.py +128 -156
- ultralytics/utils/nms.py +13 -16
- ultralytics/utils/ops.py +117 -166
- ultralytics/utils/patches.py +75 -21
- ultralytics/utils/plotting.py +75 -80
- ultralytics/utils/tal.py +125 -59
- ultralytics/utils/torch_utils.py +53 -79
- ultralytics/utils/tqdm.py +24 -21
- ultralytics/utils/triton.py +13 -19
- ultralytics/utils/tuner.py +19 -10
- dgenerate_ultralytics_headless-8.3.214.dist-info/RECORD +0 -283
- {dgenerate_ultralytics_headless-8.3.214.dist-info → dgenerate_ultralytics_headless-8.4.7.dist-info}/entry_points.txt +0 -0
- {dgenerate_ultralytics_headless-8.3.214.dist-info → dgenerate_ultralytics_headless-8.4.7.dist-info}/licenses/LICENSE +0 -0
- {dgenerate_ultralytics_headless-8.3.214.dist-info → dgenerate_ultralytics_headless-8.4.7.dist-info}/top_level.txt +0 -0
|
@@ -19,11 +19,10 @@ from .val import YOLOEDetectValidator
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class YOLOETrainer(DetectionTrainer):
|
|
22
|
-
"""
|
|
23
|
-
A trainer class for YOLOE object detection models.
|
|
22
|
+
"""A trainer class for YOLOE object detection models.
|
|
24
23
|
|
|
25
|
-
This class extends DetectionTrainer to provide specialized training functionality for YOLOE models,
|
|
26
|
-
|
|
24
|
+
This class extends DetectionTrainer to provide specialized training functionality for YOLOE models, including custom
|
|
25
|
+
model initialization, validation, and dataset building with multi-modal support.
|
|
27
26
|
|
|
28
27
|
Attributes:
|
|
29
28
|
loss_names (tuple): Names of loss components used during training.
|
|
@@ -35,8 +34,7 @@ class YOLOETrainer(DetectionTrainer):
|
|
|
35
34
|
"""
|
|
36
35
|
|
|
37
36
|
def __init__(self, cfg=DEFAULT_CFG, overrides: dict | None = None, _callbacks=None):
|
|
38
|
-
"""
|
|
39
|
-
Initialize the YOLOE Trainer with specified configurations.
|
|
37
|
+
"""Initialize the YOLOE Trainer with specified configurations.
|
|
40
38
|
|
|
41
39
|
Args:
|
|
42
40
|
cfg (dict): Configuration dictionary with default training settings from DEFAULT_CFG.
|
|
@@ -50,12 +48,11 @@ class YOLOETrainer(DetectionTrainer):
|
|
|
50
48
|
super().__init__(cfg, overrides, _callbacks)
|
|
51
49
|
|
|
52
50
|
def get_model(self, cfg=None, weights=None, verbose: bool = True):
|
|
53
|
-
"""
|
|
54
|
-
Return a YOLOEModel initialized with the specified configuration and weights.
|
|
51
|
+
"""Return a YOLOEModel initialized with the specified configuration and weights.
|
|
55
52
|
|
|
56
53
|
Args:
|
|
57
|
-
cfg (dict | str, optional): Model configuration. Can be a dictionary containing a 'yaml_file' key,
|
|
58
|
-
|
|
54
|
+
cfg (dict | str, optional): Model configuration. Can be a dictionary containing a 'yaml_file' key, a direct
|
|
55
|
+
path to a YAML file, or None to use default configuration.
|
|
59
56
|
weights (str | Path, optional): Path to pretrained weights file to load into the model.
|
|
60
57
|
verbose (bool): Whether to display model information during initialization.
|
|
61
58
|
|
|
@@ -88,8 +85,7 @@ class YOLOETrainer(DetectionTrainer):
|
|
|
88
85
|
)
|
|
89
86
|
|
|
90
87
|
def build_dataset(self, img_path: str, mode: str = "train", batch: int | None = None):
|
|
91
|
-
"""
|
|
92
|
-
Build YOLO Dataset.
|
|
88
|
+
"""Build YOLO Dataset.
|
|
93
89
|
|
|
94
90
|
Args:
|
|
95
91
|
img_path (str): Path to the folder containing images.
|
|
@@ -106,19 +102,17 @@ class YOLOETrainer(DetectionTrainer):
|
|
|
106
102
|
|
|
107
103
|
|
|
108
104
|
class YOLOEPETrainer(DetectionTrainer):
|
|
109
|
-
"""
|
|
110
|
-
Fine-tune YOLOE model using linear probing approach.
|
|
105
|
+
"""Fine-tune YOLOE model using linear probing approach.
|
|
111
106
|
|
|
112
|
-
This trainer freezes most model layers and only trains specific projection layers for efficient
|
|
113
|
-
|
|
107
|
+
This trainer freezes most model layers and only trains specific projection layers for efficient fine-tuning on new
|
|
108
|
+
datasets while preserving pretrained features.
|
|
114
109
|
|
|
115
110
|
Methods:
|
|
116
111
|
get_model: Initialize YOLOEModel with frozen layers except projection layers.
|
|
117
112
|
"""
|
|
118
113
|
|
|
119
114
|
def get_model(self, cfg=None, weights=None, verbose: bool = True):
|
|
120
|
-
"""
|
|
121
|
-
Return YOLOEModel initialized with specified config and weights.
|
|
115
|
+
"""Return YOLOEModel initialized with specified config and weights.
|
|
122
116
|
|
|
123
117
|
Args:
|
|
124
118
|
cfg (dict | str, optional): Model configuration.
|
|
@@ -153,18 +147,22 @@ class YOLOEPETrainer(DetectionTrainer):
|
|
|
153
147
|
model.model[-1].cv3[0][2] = deepcopy(model.model[-1].cv3[0][2]).requires_grad_(True)
|
|
154
148
|
model.model[-1].cv3[1][2] = deepcopy(model.model[-1].cv3[1][2]).requires_grad_(True)
|
|
155
149
|
model.model[-1].cv3[2][2] = deepcopy(model.model[-1].cv3[2][2]).requires_grad_(True)
|
|
156
|
-
|
|
150
|
+
|
|
151
|
+
if getattr(model.model[-1], "one2one_cv3", None) is not None:
|
|
152
|
+
model.model[-1].one2one_cv3[0][2] = deepcopy(model.model[-1].cv3[0][2]).requires_grad_(True)
|
|
153
|
+
model.model[-1].one2one_cv3[1][2] = deepcopy(model.model[-1].cv3[1][2]).requires_grad_(True)
|
|
154
|
+
model.model[-1].one2one_cv3[2][2] = deepcopy(model.model[-1].cv3[2][2]).requires_grad_(True)
|
|
155
|
+
|
|
157
156
|
model.train()
|
|
158
157
|
|
|
159
158
|
return model
|
|
160
159
|
|
|
161
160
|
|
|
162
161
|
class YOLOETrainerFromScratch(YOLOETrainer, WorldTrainerFromScratch):
|
|
163
|
-
"""
|
|
164
|
-
Train YOLOE models from scratch with text embedding support.
|
|
162
|
+
"""Train YOLOE models from scratch with text embedding support.
|
|
165
163
|
|
|
166
|
-
This trainer combines YOLOE training capabilities with world training features, enabling
|
|
167
|
-
|
|
164
|
+
This trainer combines YOLOE training capabilities with world training features, enabling training from scratch with
|
|
165
|
+
text embeddings and grounding datasets.
|
|
168
166
|
|
|
169
167
|
Methods:
|
|
170
168
|
build_dataset: Build datasets for training with grounding support.
|
|
@@ -172,11 +170,10 @@ class YOLOETrainerFromScratch(YOLOETrainer, WorldTrainerFromScratch):
|
|
|
172
170
|
"""
|
|
173
171
|
|
|
174
172
|
def build_dataset(self, img_path: list[str] | str, mode: str = "train", batch: int | None = None):
|
|
175
|
-
"""
|
|
176
|
-
Build YOLO Dataset for training or validation.
|
|
173
|
+
"""Build YOLO Dataset for training or validation.
|
|
177
174
|
|
|
178
|
-
This method constructs appropriate datasets based on the mode and input paths, handling both
|
|
179
|
-
|
|
175
|
+
This method constructs appropriate datasets based on the mode and input paths, handling both standard YOLO
|
|
176
|
+
datasets and grounding datasets with different formats.
|
|
180
177
|
|
|
181
178
|
Args:
|
|
182
179
|
img_path (list[str] | str): Path to the folder containing images or list of paths.
|
|
@@ -189,8 +186,7 @@ class YOLOETrainerFromScratch(YOLOETrainer, WorldTrainerFromScratch):
|
|
|
189
186
|
return WorldTrainerFromScratch.build_dataset(self, img_path, mode, batch)
|
|
190
187
|
|
|
191
188
|
def generate_text_embeddings(self, texts: list[str], batch: int, cache_dir: Path):
|
|
192
|
-
"""
|
|
193
|
-
Generate text embeddings for a list of text samples.
|
|
189
|
+
"""Generate text embeddings for a list of text samples.
|
|
194
190
|
|
|
195
191
|
Args:
|
|
196
192
|
texts (list[str]): List of text samples to encode.
|
|
@@ -216,11 +212,10 @@ class YOLOETrainerFromScratch(YOLOETrainer, WorldTrainerFromScratch):
|
|
|
216
212
|
|
|
217
213
|
|
|
218
214
|
class YOLOEPEFreeTrainer(YOLOEPETrainer, YOLOETrainerFromScratch):
|
|
219
|
-
"""
|
|
220
|
-
Train prompt-free YOLOE model.
|
|
215
|
+
"""Train prompt-free YOLOE model.
|
|
221
216
|
|
|
222
|
-
This trainer combines linear probing capabilities with from-scratch training for prompt-free
|
|
223
|
-
|
|
217
|
+
This trainer combines linear probing capabilities with from-scratch training for prompt-free YOLOE models that don't
|
|
218
|
+
require text prompts during inference.
|
|
224
219
|
|
|
225
220
|
Methods:
|
|
226
221
|
get_validator: Return standard DetectionValidator for validation.
|
|
@@ -240,12 +235,11 @@ class YOLOEPEFreeTrainer(YOLOEPETrainer, YOLOETrainerFromScratch):
|
|
|
240
235
|
return DetectionTrainer.preprocess_batch(self, batch)
|
|
241
236
|
|
|
242
237
|
def set_text_embeddings(self, datasets, batch: int):
|
|
243
|
-
"""
|
|
244
|
-
Set text embeddings for datasets to accelerate training by caching category names.
|
|
238
|
+
"""Set text embeddings for datasets to accelerate training by caching category names.
|
|
245
239
|
|
|
246
|
-
This method collects unique category names from all datasets, generates text embeddings for them,
|
|
247
|
-
|
|
248
|
-
|
|
240
|
+
This method collects unique category names from all datasets, generates text embeddings for them, and caches
|
|
241
|
+
these embeddings to improve training efficiency. The embeddings are stored in a file in the parent directory of
|
|
242
|
+
the first dataset's image path.
|
|
249
243
|
|
|
250
244
|
Args:
|
|
251
245
|
datasets (list[Dataset]): List of datasets containing category names to process.
|
|
@@ -260,19 +254,17 @@ class YOLOEPEFreeTrainer(YOLOEPETrainer, YOLOETrainerFromScratch):
|
|
|
260
254
|
|
|
261
255
|
|
|
262
256
|
class YOLOEVPTrainer(YOLOETrainerFromScratch):
|
|
263
|
-
"""
|
|
264
|
-
Train YOLOE model with visual prompts.
|
|
257
|
+
"""Train YOLOE model with visual prompts.
|
|
265
258
|
|
|
266
|
-
This trainer extends YOLOETrainerFromScratch to support visual prompt-based training,
|
|
267
|
-
|
|
259
|
+
This trainer extends YOLOETrainerFromScratch to support visual prompt-based training, where visual cues are provided
|
|
260
|
+
alongside images to guide the detection process.
|
|
268
261
|
|
|
269
262
|
Methods:
|
|
270
263
|
build_dataset: Build dataset with visual prompt loading transforms.
|
|
271
264
|
"""
|
|
272
265
|
|
|
273
266
|
def build_dataset(self, img_path: list[str] | str, mode: str = "train", batch: int | None = None):
|
|
274
|
-
"""
|
|
275
|
-
Build YOLO Dataset for training or validation with visual prompts.
|
|
267
|
+
"""Build YOLO Dataset for training or validation with visual prompts.
|
|
276
268
|
|
|
277
269
|
Args:
|
|
278
270
|
img_path (list[str] | str): Path to the folder containing images or list of paths.
|
|
@@ -11,8 +11,7 @@ from .val import YOLOESegValidator
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class YOLOESegTrainer(YOLOETrainer, SegmentationTrainer):
|
|
14
|
-
"""
|
|
15
|
-
Trainer class for YOLOE segmentation models.
|
|
14
|
+
"""Trainer class for YOLOE segmentation models.
|
|
16
15
|
|
|
17
16
|
This class combines YOLOETrainer and SegmentationTrainer to provide training functionality specifically for YOLOE
|
|
18
17
|
segmentation models, enabling both object detection and instance segmentation capabilities.
|
|
@@ -24,8 +23,7 @@ class YOLOESegTrainer(YOLOETrainer, SegmentationTrainer):
|
|
|
24
23
|
"""
|
|
25
24
|
|
|
26
25
|
def get_model(self, cfg=None, weights=None, verbose=True):
|
|
27
|
-
"""
|
|
28
|
-
Return YOLOESegModel initialized with specified config and weights.
|
|
26
|
+
"""Return YOLOESegModel initialized with specified config and weights.
|
|
29
27
|
|
|
30
28
|
Args:
|
|
31
29
|
cfg (dict | str, optional): Model configuration dictionary or YAML file path.
|
|
@@ -49,8 +47,7 @@ class YOLOESegTrainer(YOLOETrainer, SegmentationTrainer):
|
|
|
49
47
|
return model
|
|
50
48
|
|
|
51
49
|
def get_validator(self):
|
|
52
|
-
"""
|
|
53
|
-
Create and return a validator for YOLOE segmentation model evaluation.
|
|
50
|
+
"""Create and return a validator for YOLOE segmentation model evaluation.
|
|
54
51
|
|
|
55
52
|
Returns:
|
|
56
53
|
(YOLOESegValidator): Validator for YOLOE segmentation models.
|
|
@@ -62,8 +59,7 @@ class YOLOESegTrainer(YOLOETrainer, SegmentationTrainer):
|
|
|
62
59
|
|
|
63
60
|
|
|
64
61
|
class YOLOEPESegTrainer(SegmentationTrainer):
|
|
65
|
-
"""
|
|
66
|
-
Fine-tune YOLOESeg model in linear probing way.
|
|
62
|
+
"""Fine-tune YOLOESeg model in linear probing way.
|
|
67
63
|
|
|
68
64
|
This trainer specializes in fine-tuning YOLOESeg models using a linear probing approach, which involves freezing
|
|
69
65
|
most of the model and only training specific layers for efficient adaptation to new tasks.
|
|
@@ -73,8 +69,7 @@ class YOLOEPESegTrainer(SegmentationTrainer):
|
|
|
73
69
|
"""
|
|
74
70
|
|
|
75
71
|
def get_model(self, cfg=None, weights=None, verbose=True):
|
|
76
|
-
"""
|
|
77
|
-
Return YOLOESegModel initialized with specified config and weights for linear probing.
|
|
72
|
+
"""Return YOLOESegModel initialized with specified config and weights for linear probing.
|
|
78
73
|
|
|
79
74
|
Args:
|
|
80
75
|
cfg (dict | str, optional): Model configuration dictionary or YAML file path.
|
|
@@ -109,7 +104,12 @@ class YOLOEPESegTrainer(SegmentationTrainer):
|
|
|
109
104
|
model.model[-1].cv3[0][2] = deepcopy(model.model[-1].cv3[0][2]).requires_grad_(True)
|
|
110
105
|
model.model[-1].cv3[1][2] = deepcopy(model.model[-1].cv3[1][2]).requires_grad_(True)
|
|
111
106
|
model.model[-1].cv3[2][2] = deepcopy(model.model[-1].cv3[2][2]).requires_grad_(True)
|
|
112
|
-
|
|
107
|
+
|
|
108
|
+
if getattr(model.model[-1], "one2one_cv3", None) is not None:
|
|
109
|
+
model.model[-1].one2one_cv3[0][2] = deepcopy(model.model[-1].cv3[0][2]).requires_grad_(True)
|
|
110
|
+
model.model[-1].one2one_cv3[1][2] = deepcopy(model.model[-1].cv3[1][2]).requires_grad_(True)
|
|
111
|
+
model.model[-1].one2one_cv3[2][2] = deepcopy(model.model[-1].cv3[2][2]).requires_grad_(True)
|
|
112
|
+
|
|
113
113
|
model.train()
|
|
114
114
|
|
|
115
115
|
return model
|
|
@@ -21,12 +21,11 @@ from ultralytics.utils.torch_utils import select_device, smart_inference_mode
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class YOLOEDetectValidator(DetectionValidator):
|
|
24
|
-
"""
|
|
25
|
-
A validator class for YOLOE detection models that handles both text and visual prompt embeddings.
|
|
24
|
+
"""A validator class for YOLOE detection models that handles both text and visual prompt embeddings.
|
|
26
25
|
|
|
27
|
-
This class extends DetectionValidator to provide specialized validation functionality for YOLOE models.
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
This class extends DetectionValidator to provide specialized validation functionality for YOLOE models. It supports
|
|
27
|
+
validation using either text prompts or visual prompt embeddings extracted from training samples, enabling flexible
|
|
28
|
+
evaluation strategies for prompt-based object detection.
|
|
30
29
|
|
|
31
30
|
Attributes:
|
|
32
31
|
device (torch.device): The device on which validation is performed.
|
|
@@ -50,12 +49,11 @@ class YOLOEDetectValidator(DetectionValidator):
|
|
|
50
49
|
|
|
51
50
|
@smart_inference_mode()
|
|
52
51
|
def get_visual_pe(self, dataloader: torch.utils.data.DataLoader, model: YOLOEModel) -> torch.Tensor:
|
|
53
|
-
"""
|
|
54
|
-
Extract visual prompt embeddings from training samples.
|
|
52
|
+
"""Extract visual prompt embeddings from training samples.
|
|
55
53
|
|
|
56
|
-
This method processes a dataloader to compute visual prompt embeddings for each class using a YOLOE model.
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
This method processes a dataloader to compute visual prompt embeddings for each class using a YOLOE model. It
|
|
55
|
+
normalizes the embeddings and handles cases where no samples exist for a class by setting their embeddings to
|
|
56
|
+
zero.
|
|
59
57
|
|
|
60
58
|
Args:
|
|
61
59
|
dataloader (torch.utils.data.DataLoader): The dataloader providing training samples.
|
|
@@ -99,12 +97,10 @@ class YOLOEDetectValidator(DetectionValidator):
|
|
|
99
97
|
return visual_pe.unsqueeze(0)
|
|
100
98
|
|
|
101
99
|
def get_vpe_dataloader(self, data: dict[str, Any]) -> torch.utils.data.DataLoader:
|
|
102
|
-
"""
|
|
103
|
-
Create a dataloader for LVIS training visual prompt samples.
|
|
100
|
+
"""Create a dataloader for LVIS training visual prompt samples.
|
|
104
101
|
|
|
105
|
-
This method prepares a dataloader for visual prompt embeddings (VPE) using the specified dataset.
|
|
106
|
-
|
|
107
|
-
for validation purposes.
|
|
102
|
+
This method prepares a dataloader for visual prompt embeddings (VPE) using the specified dataset. It applies
|
|
103
|
+
necessary transformations including LoadVisualPrompt and configurations to the dataset for validation purposes.
|
|
108
104
|
|
|
109
105
|
Args:
|
|
110
106
|
data (dict): Dataset configuration dictionary containing paths and settings.
|
|
@@ -141,12 +137,11 @@ class YOLOEDetectValidator(DetectionValidator):
|
|
|
141
137
|
refer_data: str | None = None,
|
|
142
138
|
load_vp: bool = False,
|
|
143
139
|
) -> dict[str, Any]:
|
|
144
|
-
"""
|
|
145
|
-
Run validation on the model using either text or visual prompt embeddings.
|
|
140
|
+
"""Run validation on the model using either text or visual prompt embeddings.
|
|
146
141
|
|
|
147
|
-
This method validates the model using either text prompts or visual prompts, depending on the load_vp flag.
|
|
148
|
-
|
|
149
|
-
|
|
142
|
+
This method validates the model using either text prompts or visual prompts, depending on the load_vp flag. It
|
|
143
|
+
supports validation during training (using a trainer object) or standalone validation with a provided model. For
|
|
144
|
+
visual prompts, reference data can be specified to extract embeddings from a different dataset.
|
|
150
145
|
|
|
151
146
|
Args:
|
|
152
147
|
trainer (object, optional): Trainer object containing the model and device.
|
ultralytics/nn/__init__.py
CHANGED
|
@@ -14,14 +14,14 @@ from .tasks import (
|
|
|
14
14
|
)
|
|
15
15
|
|
|
16
16
|
__all__ = (
|
|
17
|
+
"BaseModel",
|
|
18
|
+
"ClassificationModel",
|
|
19
|
+
"DetectionModel",
|
|
20
|
+
"SegmentationModel",
|
|
21
|
+
"guess_model_scale",
|
|
22
|
+
"guess_model_task",
|
|
17
23
|
"load_checkpoint",
|
|
18
24
|
"parse_model",
|
|
19
|
-
"yaml_model_load",
|
|
20
|
-
"guess_model_task",
|
|
21
|
-
"guess_model_scale",
|
|
22
25
|
"torch_safe_load",
|
|
23
|
-
"
|
|
24
|
-
"SegmentationModel",
|
|
25
|
-
"ClassificationModel",
|
|
26
|
-
"BaseModel",
|
|
26
|
+
"yaml_model_load",
|
|
27
27
|
)
|