dgenerate-ultralytics-headless 8.3.196__py3-none-any.whl → 8.3.248__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.196.dist-info → dgenerate_ultralytics_headless-8.3.248.dist-info}/METADATA +33 -34
- dgenerate_ultralytics_headless-8.3.248.dist-info/RECORD +298 -0
- tests/__init__.py +5 -7
- tests/conftest.py +8 -15
- tests/test_cli.py +8 -10
- tests/test_cuda.py +9 -10
- tests/test_engine.py +29 -2
- tests/test_exports.py +69 -21
- tests/test_integrations.py +8 -11
- tests/test_python.py +109 -71
- tests/test_solutions.py +170 -159
- ultralytics/__init__.py +27 -9
- ultralytics/cfg/__init__.py +57 -64
- 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/Objects365.yaml +19 -15
- ultralytics/cfg/datasets/SKU-110K.yaml +1 -1
- ultralytics/cfg/datasets/VOC.yaml +19 -21
- ultralytics/cfg/datasets/VisDrone.yaml +5 -5
- ultralytics/cfg/datasets/african-wildlife.yaml +1 -1
- ultralytics/cfg/datasets/coco-pose.yaml +24 -2
- ultralytics/cfg/datasets/coco.yaml +2 -2
- ultralytics/cfg/datasets/coco128-seg.yaml +1 -1
- ultralytics/cfg/datasets/coco8-pose.yaml +21 -0
- ultralytics/cfg/datasets/construction-ppe.yaml +32 -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 +7 -7
- 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 +96 -94
- 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/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/cfg/trackers/botsort.yaml +16 -17
- ultralytics/cfg/trackers/bytetrack.yaml +9 -11
- ultralytics/data/__init__.py +4 -4
- ultralytics/data/annotator.py +3 -4
- ultralytics/data/augment.py +286 -476
- ultralytics/data/base.py +18 -26
- ultralytics/data/build.py +151 -26
- ultralytics/data/converter.py +38 -50
- 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 +41 -45
- ultralytics/engine/exporter.py +462 -462
- ultralytics/engine/model.py +150 -191
- ultralytics/engine/predictor.py +30 -40
- ultralytics/engine/results.py +177 -311
- ultralytics/engine/trainer.py +193 -120
- ultralytics/engine/tuner.py +77 -63
- ultralytics/engine/validator.py +39 -22
- 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 +19 -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 +7 -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 +22 -40
- ultralytics/models/sam/modules/encoders.py +44 -101
- ultralytics/models/sam/modules/memory_attention.py +16 -30
- ultralytics/models/sam/modules/sam.py +206 -79
- 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 +2268 -366
- 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 +9 -12
- ultralytics/models/yolo/classify/train.py +15 -41
- ultralytics/models/yolo/classify/val.py +34 -32
- ultralytics/models/yolo/detect/predict.py +8 -11
- ultralytics/models/yolo/detect/train.py +13 -32
- ultralytics/models/yolo/detect/val.py +75 -63
- ultralytics/models/yolo/model.py +37 -53
- ultralytics/models/yolo/obb/predict.py +5 -14
- ultralytics/models/yolo/obb/train.py +11 -14
- ultralytics/models/yolo/obb/val.py +42 -39
- ultralytics/models/yolo/pose/__init__.py +1 -1
- ultralytics/models/yolo/pose/predict.py +7 -22
- ultralytics/models/yolo/pose/train.py +10 -22
- ultralytics/models/yolo/pose/val.py +40 -59
- ultralytics/models/yolo/segment/predict.py +16 -20
- ultralytics/models/yolo/segment/train.py +3 -12
- ultralytics/models/yolo/segment/val.py +106 -56
- ultralytics/models/yolo/world/train.py +12 -16
- 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 +31 -56
- ultralytics/models/yolo/yoloe/train_seg.py +5 -10
- ultralytics/models/yolo/yoloe/val.py +16 -21
- ultralytics/nn/__init__.py +7 -7
- ultralytics/nn/autobackend.py +152 -80
- ultralytics/nn/modules/__init__.py +60 -60
- ultralytics/nn/modules/activation.py +4 -6
- ultralytics/nn/modules/block.py +133 -217
- ultralytics/nn/modules/conv.py +52 -97
- ultralytics/nn/modules/head.py +64 -116
- ultralytics/nn/modules/transformer.py +79 -89
- ultralytics/nn/modules/utils.py +16 -21
- ultralytics/nn/tasks.py +111 -156
- ultralytics/nn/text_model.py +40 -67
- ultralytics/solutions/__init__.py +12 -12
- ultralytics/solutions/ai_gym.py +11 -17
- ultralytics/solutions/analytics.py +15 -16
- ultralytics/solutions/config.py +5 -6
- ultralytics/solutions/distance_calculation.py +10 -13
- ultralytics/solutions/heatmap.py +7 -13
- ultralytics/solutions/instance_segmentation.py +5 -8
- 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 +33 -31
- 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 +13 -17
- ultralytics/solutions/solutions.py +75 -74
- ultralytics/solutions/speed_estimation.py +7 -10
- ultralytics/solutions/streamlit_inference.py +4 -7
- 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 +14 -30
- ultralytics/trackers/track.py +3 -6
- 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 +116 -116
- ultralytics/utils/autobatch.py +2 -4
- ultralytics/utils/autodevice.py +17 -18
- ultralytics/utils/benchmarks.py +70 -70
- 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 +314 -38
- ultralytics/utils/callbacks/raytune.py +3 -4
- ultralytics/utils/callbacks/tensorboard.py +23 -31
- ultralytics/utils/callbacks/wb.py +10 -13
- ultralytics/utils/checks.py +151 -87
- ultralytics/utils/cpu.py +3 -8
- ultralytics/utils/dist.py +19 -15
- ultralytics/utils/downloads.py +29 -41
- ultralytics/utils/errors.py +6 -14
- ultralytics/utils/events.py +2 -4
- ultralytics/utils/export/__init__.py +7 -0
- ultralytics/utils/{export.py → export/engine.py} +16 -16
- ultralytics/utils/export/imx.py +325 -0
- ultralytics/utils/export/tensorflow.py +231 -0
- ultralytics/utils/files.py +24 -28
- ultralytics/utils/git.py +9 -11
- ultralytics/utils/instance.py +30 -51
- ultralytics/utils/logger.py +212 -114
- ultralytics/utils/loss.py +15 -24
- ultralytics/utils/metrics.py +131 -160
- ultralytics/utils/nms.py +21 -30
- ultralytics/utils/ops.py +107 -165
- ultralytics/utils/patches.py +33 -21
- ultralytics/utils/plotting.py +122 -119
- ultralytics/utils/tal.py +28 -44
- ultralytics/utils/torch_utils.py +70 -187
- ultralytics/utils/tqdm.py +20 -20
- ultralytics/utils/triton.py +13 -19
- ultralytics/utils/tuner.py +17 -5
- dgenerate_ultralytics_headless-8.3.196.dist-info/RECORD +0 -281
- {dgenerate_ultralytics_headless-8.3.196.dist-info → dgenerate_ultralytics_headless-8.3.248.dist-info}/WHEEL +0 -0
- {dgenerate_ultralytics_headless-8.3.196.dist-info → dgenerate_ultralytics_headless-8.3.248.dist-info}/entry_points.txt +0 -0
- {dgenerate_ultralytics_headless-8.3.196.dist-info → dgenerate_ultralytics_headless-8.3.248.dist-info}/licenses/LICENSE +0 -0
- {dgenerate_ultralytics_headless-8.3.196.dist-info → dgenerate_ultralytics_headless-8.3.248.dist-info}/top_level.txt +0 -0
ultralytics/utils/__init__.py
CHANGED
|
@@ -14,6 +14,7 @@ import socket
|
|
|
14
14
|
import sys
|
|
15
15
|
import threading
|
|
16
16
|
import time
|
|
17
|
+
import warnings
|
|
17
18
|
from functools import lru_cache
|
|
18
19
|
from pathlib import Path
|
|
19
20
|
from threading import Lock
|
|
@@ -64,6 +65,7 @@ RKNN_CHIPS = frozenset(
|
|
|
64
65
|
"rv1103b",
|
|
65
66
|
"rv1106b",
|
|
66
67
|
"rk2118",
|
|
68
|
+
"rv1126b",
|
|
67
69
|
}
|
|
68
70
|
) # Rockchip processors available for export
|
|
69
71
|
HELP_MSG = """
|
|
@@ -132,18 +134,25 @@ os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3" # suppress verbose TF compiler warning
|
|
|
132
134
|
os.environ["TORCH_CPP_LOG_LEVEL"] = "ERROR" # suppress "NNPACK.cpp could not initialize NNPACK" warnings
|
|
133
135
|
os.environ["KINETO_LOG_LEVEL"] = "5" # suppress verbose PyTorch profiler output when computing FLOPs
|
|
134
136
|
|
|
137
|
+
# Centralized warning suppression
|
|
138
|
+
warnings.filterwarnings("ignore", message="torch.distributed.reduce_op is deprecated") # PyTorch deprecation
|
|
139
|
+
warnings.filterwarnings("ignore", message="The figure layout has changed to tight") # matplotlib>=3.7.2
|
|
140
|
+
warnings.filterwarnings("ignore", category=FutureWarning, module="timm") # mobileclip timm.layers deprecation
|
|
141
|
+
warnings.filterwarnings("ignore", category=torch.jit.TracerWarning) # ONNX/TorchScript export tracer warnings
|
|
142
|
+
warnings.filterwarnings("ignore", category=UserWarning, message=".*prim::Constant.*") # ONNX shape warning
|
|
143
|
+
warnings.filterwarnings("ignore", category=DeprecationWarning, module="coremltools") # CoreML np.bool deprecation
|
|
144
|
+
|
|
135
145
|
# Precompiled type tuples for faster isinstance() checks
|
|
136
146
|
FLOAT_OR_INT = (float, int)
|
|
137
147
|
STR_OR_PATH = (str, Path)
|
|
138
148
|
|
|
139
149
|
|
|
140
150
|
class DataExportMixin:
|
|
141
|
-
"""
|
|
142
|
-
Mixin class for exporting validation metrics or prediction results in various formats.
|
|
151
|
+
"""Mixin class for exporting validation metrics or prediction results in various formats.
|
|
143
152
|
|
|
144
153
|
This class provides utilities to export performance metrics (e.g., mAP, precision, recall) or prediction results
|
|
145
154
|
from classification, object detection, segmentation, or pose estimation tasks into various formats: Polars
|
|
146
|
-
DataFrame, CSV and JSON.
|
|
155
|
+
DataFrame, CSV, and JSON.
|
|
147
156
|
|
|
148
157
|
Methods:
|
|
149
158
|
to_df: Convert summary to a Polars DataFrame.
|
|
@@ -160,30 +169,28 @@ class DataExportMixin:
|
|
|
160
169
|
"""
|
|
161
170
|
|
|
162
171
|
def to_df(self, normalize=False, decimals=5):
|
|
163
|
-
"""
|
|
164
|
-
Create a polars DataFrame from the prediction results summary or validation metrics.
|
|
172
|
+
"""Create a Polars DataFrame from the prediction results summary or validation metrics.
|
|
165
173
|
|
|
166
174
|
Args:
|
|
167
175
|
normalize (bool, optional): Normalize numerical values for easier comparison.
|
|
168
176
|
decimals (int, optional): Decimal places to round floats.
|
|
169
177
|
|
|
170
178
|
Returns:
|
|
171
|
-
(DataFrame): DataFrame containing the summary data.
|
|
179
|
+
(polars.DataFrame): Polars DataFrame containing the summary data.
|
|
172
180
|
"""
|
|
173
181
|
import polars as pl # scope for faster 'import ultralytics'
|
|
174
182
|
|
|
175
183
|
return pl.DataFrame(self.summary(normalize=normalize, decimals=decimals))
|
|
176
184
|
|
|
177
185
|
def to_csv(self, normalize=False, decimals=5):
|
|
178
|
-
"""
|
|
179
|
-
Export results or metrics to CSV string format.
|
|
186
|
+
"""Export results or metrics to CSV string format.
|
|
180
187
|
|
|
181
188
|
Args:
|
|
182
|
-
|
|
183
|
-
|
|
189
|
+
normalize (bool, optional): Normalize numeric values.
|
|
190
|
+
decimals (int, optional): Decimal precision.
|
|
184
191
|
|
|
185
192
|
Returns:
|
|
186
|
-
|
|
193
|
+
(str): CSV content as string.
|
|
187
194
|
"""
|
|
188
195
|
import polars as pl
|
|
189
196
|
|
|
@@ -207,8 +214,7 @@ class DataExportMixin:
|
|
|
207
214
|
return df_str.write_csv()
|
|
208
215
|
|
|
209
216
|
def to_json(self, normalize=False, decimals=5):
|
|
210
|
-
"""
|
|
211
|
-
Export results to JSON format.
|
|
217
|
+
"""Export results to JSON format.
|
|
212
218
|
|
|
213
219
|
Args:
|
|
214
220
|
normalize (bool, optional): Normalize numeric values.
|
|
@@ -221,11 +227,10 @@ class DataExportMixin:
|
|
|
221
227
|
|
|
222
228
|
|
|
223
229
|
class SimpleClass:
|
|
224
|
-
"""
|
|
225
|
-
A simple base class for creating objects with string representations of their attributes.
|
|
230
|
+
"""A simple base class for creating objects with string representations of their attributes.
|
|
226
231
|
|
|
227
|
-
This class provides a foundation for creating objects that can be easily printed or represented as strings,
|
|
228
|
-
|
|
232
|
+
This class provides a foundation for creating objects that can be easily printed or represented as strings, showing
|
|
233
|
+
all their non-callable attributes. It's useful for debugging and introspection of object states.
|
|
229
234
|
|
|
230
235
|
Methods:
|
|
231
236
|
__str__: Return a human-readable string representation of the object.
|
|
@@ -260,7 +265,7 @@ class SimpleClass:
|
|
|
260
265
|
# Display only the module and class name for subclasses
|
|
261
266
|
s = f"{a}: {v.__module__}.{v.__class__.__name__} object"
|
|
262
267
|
else:
|
|
263
|
-
s = f"{a}: {
|
|
268
|
+
s = f"{a}: {v!r}"
|
|
264
269
|
attr.append(s)
|
|
265
270
|
return f"{self.__module__}.{self.__class__.__name__} object with attributes:\n\n" + "\n".join(attr)
|
|
266
271
|
|
|
@@ -275,12 +280,11 @@ class SimpleClass:
|
|
|
275
280
|
|
|
276
281
|
|
|
277
282
|
class IterableSimpleNamespace(SimpleNamespace):
|
|
278
|
-
"""
|
|
279
|
-
An iterable SimpleNamespace class that provides enhanced functionality for attribute access and iteration.
|
|
283
|
+
"""An iterable SimpleNamespace class that provides enhanced functionality for attribute access and iteration.
|
|
280
284
|
|
|
281
|
-
This class extends the SimpleNamespace class with additional methods for iteration, string representation,
|
|
282
|
-
|
|
283
|
-
|
|
285
|
+
This class extends the SimpleNamespace class with additional methods for iteration, string representation, and
|
|
286
|
+
attribute access. It is designed to be used as a convenient container for storing and accessing configuration
|
|
287
|
+
parameters.
|
|
284
288
|
|
|
285
289
|
Methods:
|
|
286
290
|
__iter__: Return an iterator of key-value pairs from the namespace's attributes.
|
|
@@ -335,8 +339,7 @@ class IterableSimpleNamespace(SimpleNamespace):
|
|
|
335
339
|
|
|
336
340
|
|
|
337
341
|
def plt_settings(rcparams=None, backend="Agg"):
|
|
338
|
-
"""
|
|
339
|
-
Decorator to temporarily set rc parameters and the backend for a plotting function.
|
|
342
|
+
"""Decorator to temporarily set rc parameters and the backend for a plotting function.
|
|
340
343
|
|
|
341
344
|
Args:
|
|
342
345
|
rcparams (dict, optional): Dictionary of rc parameters to set.
|
|
@@ -389,12 +392,11 @@ def plt_settings(rcparams=None, backend="Agg"):
|
|
|
389
392
|
|
|
390
393
|
|
|
391
394
|
def set_logging(name="LOGGING_NAME", verbose=True):
|
|
392
|
-
"""
|
|
393
|
-
Set up logging with UTF-8 encoding and configurable verbosity.
|
|
395
|
+
"""Set up logging with UTF-8 encoding and configurable verbosity.
|
|
394
396
|
|
|
395
|
-
This function configures logging for the Ultralytics library, setting the appropriate logging level and
|
|
396
|
-
|
|
397
|
-
|
|
397
|
+
This function configures logging for the Ultralytics library, setting the appropriate logging level and formatter
|
|
398
|
+
based on the verbosity flag and the current process rank. It handles special cases for Windows environments where
|
|
399
|
+
UTF-8 encoding might not be the default.
|
|
398
400
|
|
|
399
401
|
Args:
|
|
400
402
|
name (str): Name of the logger.
|
|
@@ -469,8 +471,7 @@ def emojis(string=""):
|
|
|
469
471
|
|
|
470
472
|
|
|
471
473
|
class ThreadingLocked:
|
|
472
|
-
"""
|
|
473
|
-
A decorator class for ensuring thread-safe execution of a function or method.
|
|
474
|
+
"""A decorator class for ensuring thread-safe execution of a function or method.
|
|
474
475
|
|
|
475
476
|
This class can be used as a decorator to make sure that if the decorated function is called from multiple threads,
|
|
476
477
|
only one thread at a time will be able to execute the function.
|
|
@@ -503,8 +504,7 @@ class ThreadingLocked:
|
|
|
503
504
|
|
|
504
505
|
|
|
505
506
|
class YAML:
|
|
506
|
-
"""
|
|
507
|
-
YAML utility class for efficient file operations with automatic C-implementation detection.
|
|
507
|
+
"""YAML utility class for efficient file operations with automatic C-implementation detection.
|
|
508
508
|
|
|
509
509
|
This class provides optimized YAML loading and saving operations using PyYAML's fastest available implementation
|
|
510
510
|
(C-based when possible). It implements a singleton pattern with lazy initialization, allowing direct class method
|
|
@@ -554,8 +554,7 @@ class YAML:
|
|
|
554
554
|
|
|
555
555
|
@classmethod
|
|
556
556
|
def save(cls, file="data.yaml", data=None, header=""):
|
|
557
|
-
"""
|
|
558
|
-
Save Python object as YAML file.
|
|
557
|
+
"""Save Python object as YAML file.
|
|
559
558
|
|
|
560
559
|
Args:
|
|
561
560
|
file (str | Path): Path to save YAML file.
|
|
@@ -584,8 +583,7 @@ class YAML:
|
|
|
584
583
|
|
|
585
584
|
@classmethod
|
|
586
585
|
def load(cls, file="data.yaml", append_filename=False):
|
|
587
|
-
"""
|
|
588
|
-
Load YAML file to Python object with robust error handling.
|
|
586
|
+
"""Load YAML file to Python object with robust error handling.
|
|
589
587
|
|
|
590
588
|
Args:
|
|
591
589
|
file (str | Path): Path to YAML file.
|
|
@@ -619,8 +617,7 @@ class YAML:
|
|
|
619
617
|
|
|
620
618
|
@classmethod
|
|
621
619
|
def print(cls, yaml_file):
|
|
622
|
-
"""
|
|
623
|
-
Pretty print YAML file or object to console.
|
|
620
|
+
"""Pretty print YAML file or object to console.
|
|
624
621
|
|
|
625
622
|
Args:
|
|
626
623
|
yaml_file (str | Path | dict): Path to YAML file or dict to print.
|
|
@@ -643,8 +640,7 @@ DEFAULT_CFG = IterableSimpleNamespace(**DEFAULT_CFG_DICT)
|
|
|
643
640
|
|
|
644
641
|
|
|
645
642
|
def read_device_model() -> str:
|
|
646
|
-
"""
|
|
647
|
-
Read the device model information from the system and cache it for quick access.
|
|
643
|
+
"""Read the device model information from the system and cache it for quick access.
|
|
648
644
|
|
|
649
645
|
Returns:
|
|
650
646
|
(str): Kernel release information.
|
|
@@ -653,8 +649,7 @@ def read_device_model() -> str:
|
|
|
653
649
|
|
|
654
650
|
|
|
655
651
|
def is_ubuntu() -> bool:
|
|
656
|
-
"""
|
|
657
|
-
Check if the OS is Ubuntu.
|
|
652
|
+
"""Check if the OS is Ubuntu.
|
|
658
653
|
|
|
659
654
|
Returns:
|
|
660
655
|
(bool): True if OS is Ubuntu, False otherwise.
|
|
@@ -666,9 +661,34 @@ def is_ubuntu() -> bool:
|
|
|
666
661
|
return False
|
|
667
662
|
|
|
668
663
|
|
|
669
|
-
def
|
|
664
|
+
def is_debian(codenames: list[str] | None | str = None) -> list[bool] | bool:
|
|
665
|
+
"""Check if the OS is Debian.
|
|
666
|
+
|
|
667
|
+
Args:
|
|
668
|
+
codenames (list[str] | None | str): Specific Debian codename to check for (e.g., 'buster', 'bullseye'). If None,
|
|
669
|
+
only checks for Debian.
|
|
670
|
+
|
|
671
|
+
Returns:
|
|
672
|
+
(list[bool] | bool): List of booleans indicating if OS matches each Debian codename, or a single boolean if no
|
|
673
|
+
codenames provided.
|
|
670
674
|
"""
|
|
671
|
-
|
|
675
|
+
try:
|
|
676
|
+
with open("/etc/os-release") as f:
|
|
677
|
+
content = f.read()
|
|
678
|
+
if codenames is None:
|
|
679
|
+
return "ID=debian" in content
|
|
680
|
+
if isinstance(codenames, str):
|
|
681
|
+
codenames = [codenames]
|
|
682
|
+
return [
|
|
683
|
+
f"VERSION_CODENAME={codename}" in content if codename else "ID=debian" in content
|
|
684
|
+
for codename in codenames
|
|
685
|
+
]
|
|
686
|
+
except FileNotFoundError:
|
|
687
|
+
return [False] * len(codenames) if codenames else False
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
def is_colab():
|
|
691
|
+
"""Check if the current script is running inside a Google Colab notebook.
|
|
672
692
|
|
|
673
693
|
Returns:
|
|
674
694
|
(bool): True if running inside a Colab notebook, False otherwise.
|
|
@@ -677,8 +697,7 @@ def is_colab():
|
|
|
677
697
|
|
|
678
698
|
|
|
679
699
|
def is_kaggle():
|
|
680
|
-
"""
|
|
681
|
-
Check if the current script is running inside a Kaggle kernel.
|
|
700
|
+
"""Check if the current script is running inside a Kaggle kernel.
|
|
682
701
|
|
|
683
702
|
Returns:
|
|
684
703
|
(bool): True if running inside a Kaggle kernel, False otherwise.
|
|
@@ -687,8 +706,7 @@ def is_kaggle():
|
|
|
687
706
|
|
|
688
707
|
|
|
689
708
|
def is_jupyter():
|
|
690
|
-
"""
|
|
691
|
-
Check if the current script is running inside a Jupyter Notebook.
|
|
709
|
+
"""Check if the current script is running inside a Jupyter Notebook.
|
|
692
710
|
|
|
693
711
|
Returns:
|
|
694
712
|
(bool): True if running inside a Jupyter Notebook, False otherwise.
|
|
@@ -701,8 +719,7 @@ def is_jupyter():
|
|
|
701
719
|
|
|
702
720
|
|
|
703
721
|
def is_runpod():
|
|
704
|
-
"""
|
|
705
|
-
Check if the current script is running inside a RunPod container.
|
|
722
|
+
"""Check if the current script is running inside a RunPod container.
|
|
706
723
|
|
|
707
724
|
Returns:
|
|
708
725
|
(bool): True if running in RunPod, False otherwise.
|
|
@@ -711,8 +728,7 @@ def is_runpod():
|
|
|
711
728
|
|
|
712
729
|
|
|
713
730
|
def is_docker() -> bool:
|
|
714
|
-
"""
|
|
715
|
-
Determine if the script is running inside a Docker container.
|
|
731
|
+
"""Determine if the script is running inside a Docker container.
|
|
716
732
|
|
|
717
733
|
Returns:
|
|
718
734
|
(bool): True if the script is running inside a Docker container, False otherwise.
|
|
@@ -724,8 +740,7 @@ def is_docker() -> bool:
|
|
|
724
740
|
|
|
725
741
|
|
|
726
742
|
def is_raspberrypi() -> bool:
|
|
727
|
-
"""
|
|
728
|
-
Determine if the Python environment is running on a Raspberry Pi.
|
|
743
|
+
"""Determine if the Python environment is running on a Raspberry Pi.
|
|
729
744
|
|
|
730
745
|
Returns:
|
|
731
746
|
(bool): True if running on a Raspberry Pi, False otherwise.
|
|
@@ -735,8 +750,7 @@ def is_raspberrypi() -> bool:
|
|
|
735
750
|
|
|
736
751
|
@lru_cache(maxsize=3)
|
|
737
752
|
def is_jetson(jetpack=None) -> bool:
|
|
738
|
-
"""
|
|
739
|
-
Determine if the Python environment is running on an NVIDIA Jetson device.
|
|
753
|
+
"""Determine if the Python environment is running on an NVIDIA Jetson device.
|
|
740
754
|
|
|
741
755
|
Args:
|
|
742
756
|
jetpack (int | None): If specified, check for specific JetPack version (4, 5, 6).
|
|
@@ -744,20 +758,19 @@ def is_jetson(jetpack=None) -> bool:
|
|
|
744
758
|
Returns:
|
|
745
759
|
(bool): True if running on an NVIDIA Jetson device, False otherwise.
|
|
746
760
|
"""
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
761
|
+
jetson = "tegra" in DEVICE_MODEL
|
|
762
|
+
if jetson and jetpack:
|
|
763
|
+
try:
|
|
764
|
+
content = open("/etc/nv_tegra_release").read()
|
|
765
|
+
version_map = {4: "R32", 5: "R35", 6: "R36"} # JetPack to L4T major version mapping
|
|
766
|
+
return jetpack in version_map and version_map[jetpack] in content
|
|
767
|
+
except Exception:
|
|
768
|
+
return False
|
|
755
769
|
return jetson
|
|
756
770
|
|
|
757
771
|
|
|
758
772
|
def is_online() -> bool:
|
|
759
|
-
"""
|
|
760
|
-
Fast online check using DNS (v4/v6) resolution (Cloudflare + Google).
|
|
773
|
+
"""Fast online check using DNS (v4/v6) resolution (Cloudflare + Google).
|
|
761
774
|
|
|
762
775
|
Returns:
|
|
763
776
|
(bool): True if connection is successful, False otherwise.
|
|
@@ -775,8 +788,7 @@ def is_online() -> bool:
|
|
|
775
788
|
|
|
776
789
|
|
|
777
790
|
def is_pip_package(filepath: str = __name__) -> bool:
|
|
778
|
-
"""
|
|
779
|
-
Determine if the file at the given filepath is part of a pip package.
|
|
791
|
+
"""Determine if the file at the given filepath is part of a pip package.
|
|
780
792
|
|
|
781
793
|
Args:
|
|
782
794
|
filepath (str): The filepath to check.
|
|
@@ -794,21 +806,19 @@ def is_pip_package(filepath: str = __name__) -> bool:
|
|
|
794
806
|
|
|
795
807
|
|
|
796
808
|
def is_dir_writeable(dir_path: str | Path) -> bool:
|
|
797
|
-
"""
|
|
798
|
-
Check if a directory is writeable.
|
|
809
|
+
"""Check if a directory is writable.
|
|
799
810
|
|
|
800
811
|
Args:
|
|
801
812
|
dir_path (str | Path): The path to the directory.
|
|
802
813
|
|
|
803
814
|
Returns:
|
|
804
|
-
(bool): True if the directory is
|
|
815
|
+
(bool): True if the directory is writable, False otherwise.
|
|
805
816
|
"""
|
|
806
817
|
return os.access(str(dir_path), os.W_OK)
|
|
807
818
|
|
|
808
819
|
|
|
809
820
|
def is_pytest_running():
|
|
810
|
-
"""
|
|
811
|
-
Determine whether pytest is currently running or not.
|
|
821
|
+
"""Determine whether pytest is currently running or not.
|
|
812
822
|
|
|
813
823
|
Returns:
|
|
814
824
|
(bool): True if pytest is running, False otherwise.
|
|
@@ -817,8 +827,7 @@ def is_pytest_running():
|
|
|
817
827
|
|
|
818
828
|
|
|
819
829
|
def is_github_action_running() -> bool:
|
|
820
|
-
"""
|
|
821
|
-
Determine if the current environment is a GitHub Actions runner.
|
|
830
|
+
"""Determine if the current environment is a GitHub Actions runner.
|
|
822
831
|
|
|
823
832
|
Returns:
|
|
824
833
|
(bool): True if the current environment is a GitHub Actions runner, False otherwise.
|
|
@@ -827,8 +836,7 @@ def is_github_action_running() -> bool:
|
|
|
827
836
|
|
|
828
837
|
|
|
829
838
|
def get_default_args(func):
|
|
830
|
-
"""
|
|
831
|
-
Return a dictionary of default arguments for a function.
|
|
839
|
+
"""Return a dictionary of default arguments for a function.
|
|
832
840
|
|
|
833
841
|
Args:
|
|
834
842
|
func (callable): The function to inspect.
|
|
@@ -841,8 +849,7 @@ def get_default_args(func):
|
|
|
841
849
|
|
|
842
850
|
|
|
843
851
|
def get_ubuntu_version():
|
|
844
|
-
"""
|
|
845
|
-
Retrieve the Ubuntu version if the OS is Ubuntu.
|
|
852
|
+
"""Retrieve the Ubuntu version if the OS is Ubuntu.
|
|
846
853
|
|
|
847
854
|
Returns:
|
|
848
855
|
(str): Ubuntu version or None if not an Ubuntu OS.
|
|
@@ -856,8 +863,7 @@ def get_ubuntu_version():
|
|
|
856
863
|
|
|
857
864
|
|
|
858
865
|
def get_user_config_dir(sub_dir="Ultralytics"):
|
|
859
|
-
"""
|
|
860
|
-
Return a writable config dir, preferring YOLO_CONFIG_DIR and being OS-aware.
|
|
866
|
+
"""Return a writable config dir, preferring YOLO_CONFIG_DIR and being OS-aware.
|
|
861
867
|
|
|
862
868
|
Args:
|
|
863
869
|
sub_dir (str): The name of the subdirectory to create.
|
|
@@ -882,14 +888,14 @@ def get_user_config_dir(sub_dir="Ultralytics"):
|
|
|
882
888
|
p.mkdir(parents=True, exist_ok=True)
|
|
883
889
|
return p
|
|
884
890
|
|
|
885
|
-
# Fallbacks for Docker, GCP/AWS functions where only /tmp is
|
|
891
|
+
# Fallbacks for Docker, GCP/AWS functions where only /tmp is writable
|
|
886
892
|
for alt in [Path("/tmp") / sub_dir, Path.cwd() / sub_dir]:
|
|
887
893
|
if alt.exists():
|
|
888
894
|
return alt
|
|
889
895
|
if is_dir_writeable(alt.parent):
|
|
890
896
|
alt.mkdir(parents=True, exist_ok=True)
|
|
891
897
|
LOGGER.warning(
|
|
892
|
-
f"user config directory '{p}' is not
|
|
898
|
+
f"user config directory '{p}' is not writable, using '{alt}'. Set YOLO_CONFIG_DIR to override."
|
|
893
899
|
)
|
|
894
900
|
return alt
|
|
895
901
|
|
|
@@ -909,14 +915,15 @@ IS_JETSON = is_jetson()
|
|
|
909
915
|
IS_JUPYTER = is_jupyter()
|
|
910
916
|
IS_PIP_PACKAGE = is_pip_package()
|
|
911
917
|
IS_RASPBERRYPI = is_raspberrypi()
|
|
918
|
+
IS_DEBIAN, IS_DEBIAN_BOOKWORM, IS_DEBIAN_TRIXIE = is_debian([None, "bookworm", "trixie"])
|
|
919
|
+
IS_UBUNTU = is_ubuntu()
|
|
912
920
|
GIT = GitRepo()
|
|
913
921
|
USER_CONFIG_DIR = get_user_config_dir() # Ultralytics settings dir
|
|
914
922
|
SETTINGS_FILE = USER_CONFIG_DIR / "settings.json"
|
|
915
923
|
|
|
916
924
|
|
|
917
925
|
def colorstr(*input):
|
|
918
|
-
r"""
|
|
919
|
-
Color a string based on the provided color and style arguments using ANSI escape codes.
|
|
926
|
+
r"""Color a string based on the provided color and style arguments using ANSI escape codes.
|
|
920
927
|
|
|
921
928
|
This function can be called in two ways:
|
|
922
929
|
- colorstr('color', 'style', 'your string')
|
|
@@ -925,12 +932,16 @@ def colorstr(*input):
|
|
|
925
932
|
In the second form, 'blue' and 'bold' will be applied by default.
|
|
926
933
|
|
|
927
934
|
Args:
|
|
928
|
-
*input (str | Path): A sequence of strings where the first n-1 strings are color and style arguments,
|
|
929
|
-
|
|
935
|
+
*input (str | Path): A sequence of strings where the first n-1 strings are color and style arguments, and the
|
|
936
|
+
last string is the one to be colored.
|
|
930
937
|
|
|
931
938
|
Returns:
|
|
932
939
|
(str): The input string wrapped with ANSI escape codes for the specified color and style.
|
|
933
940
|
|
|
941
|
+
Examples:
|
|
942
|
+
>>> colorstr("blue", "bold", "hello world")
|
|
943
|
+
>>> "\033[34m\033[1mhello world\033[0m"
|
|
944
|
+
|
|
934
945
|
Notes:
|
|
935
946
|
Supported Colors and Styles:
|
|
936
947
|
- Basic Colors: 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'
|
|
@@ -938,10 +949,6 @@ def colorstr(*input):
|
|
|
938
949
|
'bright_blue', 'bright_magenta', 'bright_cyan', 'bright_white'
|
|
939
950
|
- Misc: 'end', 'bold', 'underline'
|
|
940
951
|
|
|
941
|
-
Examples:
|
|
942
|
-
>>> colorstr("blue", "bold", "hello world")
|
|
943
|
-
>>> "\033[34m\033[1mhello world\033[0m"
|
|
944
|
-
|
|
945
952
|
References:
|
|
946
953
|
https://en.wikipedia.org/wiki/ANSI_escape_code
|
|
947
954
|
"""
|
|
@@ -971,8 +978,7 @@ def colorstr(*input):
|
|
|
971
978
|
|
|
972
979
|
|
|
973
980
|
def remove_colorstr(input_string):
|
|
974
|
-
"""
|
|
975
|
-
Remove ANSI escape codes from a string, effectively un-coloring it.
|
|
981
|
+
"""Remove ANSI escape codes from a string, effectively un-coloring it.
|
|
976
982
|
|
|
977
983
|
Args:
|
|
978
984
|
input_string (str): The string to remove color and style from.
|
|
@@ -989,8 +995,7 @@ def remove_colorstr(input_string):
|
|
|
989
995
|
|
|
990
996
|
|
|
991
997
|
class TryExcept(contextlib.ContextDecorator):
|
|
992
|
-
"""
|
|
993
|
-
Ultralytics TryExcept class for handling exceptions gracefully.
|
|
998
|
+
"""Ultralytics TryExcept class for handling exceptions gracefully.
|
|
994
999
|
|
|
995
1000
|
This class can be used as a decorator or context manager to catch exceptions and optionally print warning messages.
|
|
996
1001
|
It allows code to continue execution even when exceptions occur, which is useful for non-critical operations.
|
|
@@ -1029,12 +1034,11 @@ class TryExcept(contextlib.ContextDecorator):
|
|
|
1029
1034
|
|
|
1030
1035
|
|
|
1031
1036
|
class Retry(contextlib.ContextDecorator):
|
|
1032
|
-
"""
|
|
1033
|
-
Retry class for function execution with exponential backoff.
|
|
1037
|
+
"""Retry class for function execution with exponential backoff.
|
|
1034
1038
|
|
|
1035
1039
|
This decorator can be used to retry a function on exceptions, up to a specified number of times with an
|
|
1036
|
-
exponentially increasing delay between retries. It's useful for handling transient failures in network
|
|
1037
|
-
|
|
1040
|
+
exponentially increasing delay between retries. It's useful for handling transient failures in network operations or
|
|
1041
|
+
other unreliable processes.
|
|
1038
1042
|
|
|
1039
1043
|
Attributes:
|
|
1040
1044
|
times (int): Maximum number of retry attempts.
|
|
@@ -1074,12 +1078,11 @@ class Retry(contextlib.ContextDecorator):
|
|
|
1074
1078
|
|
|
1075
1079
|
|
|
1076
1080
|
def threaded(func):
|
|
1077
|
-
"""
|
|
1078
|
-
Multi-thread a target function by default and return the thread or function result.
|
|
1081
|
+
"""Multi-thread a target function by default and return the thread or function result.
|
|
1079
1082
|
|
|
1080
|
-
This decorator provides flexible execution of the target function, either in a separate thread or synchronously.
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
+
This decorator provides flexible execution of the target function, either in a separate thread or synchronously. By
|
|
1084
|
+
default, the function runs in a thread, but this can be controlled via the 'threaded=False' keyword argument which
|
|
1085
|
+
is removed from kwargs before calling the function.
|
|
1083
1086
|
|
|
1084
1087
|
Args:
|
|
1085
1088
|
func (callable): The function to be potentially executed in a separate thread.
|
|
@@ -1109,8 +1112,7 @@ def threaded(func):
|
|
|
1109
1112
|
|
|
1110
1113
|
|
|
1111
1114
|
def set_sentry():
|
|
1112
|
-
"""
|
|
1113
|
-
Initialize the Sentry SDK for error tracking and reporting.
|
|
1115
|
+
"""Initialize the Sentry SDK for error tracking and reporting.
|
|
1114
1116
|
|
|
1115
1117
|
Only used if sentry_sdk package is installed and sync=True in settings. Run 'yolo settings' to see and update
|
|
1116
1118
|
settings.
|
|
@@ -1137,13 +1139,12 @@ def set_sentry():
|
|
|
1137
1139
|
return
|
|
1138
1140
|
# If sentry_sdk package is not installed then return and do not use Sentry
|
|
1139
1141
|
try:
|
|
1140
|
-
import sentry_sdk
|
|
1142
|
+
import sentry_sdk
|
|
1141
1143
|
except ImportError:
|
|
1142
1144
|
return
|
|
1143
1145
|
|
|
1144
1146
|
def before_send(event, hint):
|
|
1145
|
-
"""
|
|
1146
|
-
Modify the event before sending it to Sentry based on specific exception types and messages.
|
|
1147
|
+
"""Modify the event before sending it to Sentry based on specific exception types and messages.
|
|
1147
1148
|
|
|
1148
1149
|
Args:
|
|
1149
1150
|
event (dict): The event dictionary containing information about the error.
|
|
@@ -1179,8 +1180,7 @@ def set_sentry():
|
|
|
1179
1180
|
|
|
1180
1181
|
|
|
1181
1182
|
class JSONDict(dict):
|
|
1182
|
-
"""
|
|
1183
|
-
A dictionary-like class that provides JSON persistence for its contents.
|
|
1183
|
+
"""A dictionary-like class that provides JSON persistence for its contents.
|
|
1184
1184
|
|
|
1185
1185
|
This class extends the built-in dictionary to automatically save its contents to a JSON file whenever they are
|
|
1186
1186
|
modified. It ensures thread-safe operations using a lock and handles JSON serialization of Path objects.
|
|
@@ -1219,7 +1219,8 @@ class JSONDict(dict):
|
|
|
1219
1219
|
try:
|
|
1220
1220
|
if self.file_path.exists():
|
|
1221
1221
|
with open(self.file_path) as f:
|
|
1222
|
-
|
|
1222
|
+
# Use the base dict update to avoid persisting during reads
|
|
1223
|
+
super().update(json.load(f))
|
|
1223
1224
|
except json.JSONDecodeError:
|
|
1224
1225
|
LOGGER.warning(f"Error decoding JSON from {self.file_path}. Starting with an empty dictionary.")
|
|
1225
1226
|
except Exception as e:
|
|
@@ -1272,8 +1273,7 @@ class JSONDict(dict):
|
|
|
1272
1273
|
|
|
1273
1274
|
|
|
1274
1275
|
class SettingsManager(JSONDict):
|
|
1275
|
-
"""
|
|
1276
|
-
SettingsManager class for managing and persisting Ultralytics settings.
|
|
1276
|
+
"""SettingsManager class for managing and persisting Ultralytics settings.
|
|
1277
1277
|
|
|
1278
1278
|
This class extends JSONDict to provide JSON persistence for settings, ensuring thread-safe operations and default
|
|
1279
1279
|
values. It validates settings on initialization and provides methods to update or reset settings. The settings
|
ultralytics/utils/autobatch.py
CHANGED
|
@@ -20,8 +20,7 @@ def check_train_batch_size(
|
|
|
20
20
|
batch: int | float = -1,
|
|
21
21
|
max_num_obj: int = 1,
|
|
22
22
|
) -> int:
|
|
23
|
-
"""
|
|
24
|
-
Compute optimal YOLO training batch size using the autobatch() function.
|
|
23
|
+
"""Compute optimal YOLO training batch size using the autobatch() function.
|
|
25
24
|
|
|
26
25
|
Args:
|
|
27
26
|
model (torch.nn.Module): YOLO model to check batch size for.
|
|
@@ -50,8 +49,7 @@ def autobatch(
|
|
|
50
49
|
batch_size: int = DEFAULT_CFG.batch,
|
|
51
50
|
max_num_obj: int = 1,
|
|
52
51
|
) -> int:
|
|
53
|
-
"""
|
|
54
|
-
Automatically estimate the best YOLO batch size to use a fraction of the available CUDA memory.
|
|
52
|
+
"""Automatically estimate the best YOLO batch size to use a fraction of the available CUDA memory.
|
|
55
53
|
|
|
56
54
|
Args:
|
|
57
55
|
model (torch.nn.Module): YOLO model to compute batch size for.
|