dgenerate-ultralytics-headless 8.3.222__py3-none-any.whl → 8.3.225__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.222.dist-info → dgenerate_ultralytics_headless-8.3.225.dist-info}/METADATA +2 -2
- dgenerate_ultralytics_headless-8.3.225.dist-info/RECORD +286 -0
- tests/conftest.py +5 -8
- tests/test_cli.py +1 -8
- tests/test_python.py +1 -2
- ultralytics/__init__.py +1 -1
- ultralytics/cfg/__init__.py +34 -49
- ultralytics/cfg/datasets/ImageNet.yaml +1 -1
- ultralytics/cfg/datasets/kitti.yaml +27 -0
- ultralytics/cfg/datasets/lvis.yaml +5 -5
- ultralytics/cfg/datasets/open-images-v7.yaml +1 -1
- ultralytics/data/annotator.py +3 -4
- ultralytics/data/augment.py +244 -323
- ultralytics/data/base.py +12 -22
- ultralytics/data/build.py +47 -40
- ultralytics/data/converter.py +32 -42
- ultralytics/data/dataset.py +43 -71
- ultralytics/data/loaders.py +22 -34
- ultralytics/data/split.py +5 -6
- ultralytics/data/split_dota.py +8 -15
- ultralytics/data/utils.py +27 -36
- ultralytics/engine/exporter.py +49 -116
- ultralytics/engine/model.py +144 -180
- ultralytics/engine/predictor.py +18 -29
- ultralytics/engine/results.py +165 -231
- ultralytics/engine/trainer.py +11 -19
- ultralytics/engine/tuner.py +13 -23
- ultralytics/engine/validator.py +6 -10
- ultralytics/hub/__init__.py +7 -12
- ultralytics/hub/auth.py +6 -12
- ultralytics/hub/google/__init__.py +7 -10
- ultralytics/hub/session.py +15 -25
- ultralytics/hub/utils.py +3 -6
- ultralytics/models/fastsam/model.py +6 -8
- ultralytics/models/fastsam/predict.py +5 -10
- ultralytics/models/fastsam/utils.py +1 -2
- ultralytics/models/fastsam/val.py +2 -4
- ultralytics/models/nas/model.py +5 -8
- ultralytics/models/nas/predict.py +7 -9
- ultralytics/models/nas/val.py +1 -2
- ultralytics/models/rtdetr/model.py +5 -8
- ultralytics/models/rtdetr/predict.py +15 -18
- ultralytics/models/rtdetr/train.py +10 -13
- ultralytics/models/rtdetr/val.py +13 -20
- ultralytics/models/sam/amg.py +12 -18
- ultralytics/models/sam/build.py +6 -9
- ultralytics/models/sam/model.py +16 -23
- ultralytics/models/sam/modules/blocks.py +62 -84
- ultralytics/models/sam/modules/decoders.py +17 -24
- ultralytics/models/sam/modules/encoders.py +40 -56
- ultralytics/models/sam/modules/memory_attention.py +10 -16
- ultralytics/models/sam/modules/sam.py +41 -47
- ultralytics/models/sam/modules/tiny_encoder.py +64 -83
- ultralytics/models/sam/modules/transformer.py +17 -27
- ultralytics/models/sam/modules/utils.py +31 -42
- ultralytics/models/sam/predict.py +172 -209
- ultralytics/models/utils/loss.py +14 -26
- ultralytics/models/utils/ops.py +13 -17
- ultralytics/models/yolo/classify/predict.py +8 -11
- ultralytics/models/yolo/classify/train.py +8 -16
- ultralytics/models/yolo/classify/val.py +13 -20
- ultralytics/models/yolo/detect/predict.py +4 -8
- ultralytics/models/yolo/detect/train.py +11 -20
- ultralytics/models/yolo/detect/val.py +38 -48
- ultralytics/models/yolo/model.py +35 -47
- ultralytics/models/yolo/obb/predict.py +5 -8
- ultralytics/models/yolo/obb/train.py +11 -14
- ultralytics/models/yolo/obb/val.py +20 -28
- ultralytics/models/yolo/pose/predict.py +5 -8
- ultralytics/models/yolo/pose/train.py +4 -8
- ultralytics/models/yolo/pose/val.py +31 -39
- ultralytics/models/yolo/segment/predict.py +9 -14
- ultralytics/models/yolo/segment/train.py +3 -6
- ultralytics/models/yolo/segment/val.py +16 -26
- ultralytics/models/yolo/world/train.py +8 -14
- ultralytics/models/yolo/world/train_world.py +11 -16
- ultralytics/models/yolo/yoloe/predict.py +16 -23
- ultralytics/models/yolo/yoloe/train.py +30 -43
- ultralytics/models/yolo/yoloe/train_seg.py +5 -10
- ultralytics/models/yolo/yoloe/val.py +15 -20
- ultralytics/nn/autobackend.py +10 -18
- ultralytics/nn/modules/activation.py +4 -6
- ultralytics/nn/modules/block.py +99 -185
- ultralytics/nn/modules/conv.py +45 -90
- ultralytics/nn/modules/head.py +44 -98
- ultralytics/nn/modules/transformer.py +44 -76
- ultralytics/nn/modules/utils.py +14 -19
- ultralytics/nn/tasks.py +86 -146
- ultralytics/nn/text_model.py +25 -40
- ultralytics/solutions/ai_gym.py +10 -16
- ultralytics/solutions/analytics.py +7 -10
- ultralytics/solutions/config.py +4 -5
- ultralytics/solutions/distance_calculation.py +9 -12
- 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 +8 -12
- ultralytics/solutions/object_cropper.py +5 -8
- ultralytics/solutions/parking_management.py +12 -14
- ultralytics/solutions/queue_management.py +4 -6
- ultralytics/solutions/region_counter.py +7 -10
- ultralytics/solutions/security_alarm.py +14 -19
- ultralytics/solutions/similarity_search.py +7 -12
- ultralytics/solutions/solutions.py +31 -53
- ultralytics/solutions/speed_estimation.py +6 -9
- ultralytics/solutions/streamlit_inference.py +2 -4
- ultralytics/solutions/trackzone.py +7 -10
- ultralytics/solutions/vision_eye.py +5 -8
- ultralytics/trackers/basetrack.py +2 -4
- ultralytics/trackers/bot_sort.py +6 -11
- ultralytics/trackers/byte_tracker.py +10 -15
- ultralytics/trackers/track.py +3 -6
- ultralytics/trackers/utils/gmc.py +6 -12
- ultralytics/trackers/utils/kalman_filter.py +35 -43
- ultralytics/trackers/utils/matching.py +6 -10
- ultralytics/utils/__init__.py +61 -100
- ultralytics/utils/autobatch.py +2 -4
- ultralytics/utils/autodevice.py +11 -13
- ultralytics/utils/benchmarks.py +25 -35
- ultralytics/utils/callbacks/base.py +8 -10
- ultralytics/utils/callbacks/clearml.py +2 -4
- ultralytics/utils/callbacks/comet.py +30 -44
- ultralytics/utils/callbacks/dvc.py +13 -18
- ultralytics/utils/callbacks/mlflow.py +4 -5
- ultralytics/utils/callbacks/neptune.py +4 -6
- ultralytics/utils/callbacks/raytune.py +3 -4
- ultralytics/utils/callbacks/tensorboard.py +4 -6
- ultralytics/utils/callbacks/wb.py +10 -13
- ultralytics/utils/checks.py +29 -56
- ultralytics/utils/cpu.py +1 -2
- ultralytics/utils/dist.py +8 -12
- ultralytics/utils/downloads.py +17 -27
- ultralytics/utils/errors.py +6 -8
- ultralytics/utils/events.py +2 -4
- ultralytics/utils/export/__init__.py +4 -239
- ultralytics/utils/export/engine.py +237 -0
- ultralytics/utils/export/imx.py +11 -17
- ultralytics/utils/export/tensorflow.py +217 -0
- ultralytics/utils/files.py +10 -15
- ultralytics/utils/git.py +5 -7
- ultralytics/utils/instance.py +30 -51
- ultralytics/utils/logger.py +11 -15
- ultralytics/utils/loss.py +8 -14
- ultralytics/utils/metrics.py +98 -138
- ultralytics/utils/nms.py +13 -16
- ultralytics/utils/ops.py +47 -74
- ultralytics/utils/patches.py +11 -18
- ultralytics/utils/plotting.py +29 -42
- ultralytics/utils/tal.py +25 -39
- ultralytics/utils/torch_utils.py +45 -73
- ultralytics/utils/tqdm.py +6 -8
- ultralytics/utils/triton.py +9 -12
- ultralytics/utils/tuner.py +1 -2
- dgenerate_ultralytics_headless-8.3.222.dist-info/RECORD +0 -283
- {dgenerate_ultralytics_headless-8.3.222.dist-info → dgenerate_ultralytics_headless-8.3.225.dist-info}/WHEEL +0 -0
- {dgenerate_ultralytics_headless-8.3.222.dist-info → dgenerate_ultralytics_headless-8.3.225.dist-info}/entry_points.txt +0 -0
- {dgenerate_ultralytics_headless-8.3.222.dist-info → dgenerate_ultralytics_headless-8.3.225.dist-info}/licenses/LICENSE +0 -0
- {dgenerate_ultralytics_headless-8.3.222.dist-info → dgenerate_ultralytics_headless-8.3.225.dist-info}/top_level.txt +0 -0
|
@@ -16,8 +16,7 @@ except (ImportError, AssertionError):
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
def _custom_table(x, y, classes, title="Precision Recall Curve", x_title="Recall", y_title="Precision"):
|
|
19
|
-
"""
|
|
20
|
-
Create and log a custom metric visualization to wandb.plot.pr_curve.
|
|
19
|
+
"""Create and log a custom metric visualization to wandb.plot.pr_curve.
|
|
21
20
|
|
|
22
21
|
This function crafts a custom metric visualization that mimics the behavior of the default wandb precision-recall
|
|
23
22
|
curve while allowing for enhanced customization. The visual metric is useful for monitoring model performance across
|
|
@@ -61,11 +60,10 @@ def _plot_curve(
|
|
|
61
60
|
num_x=100,
|
|
62
61
|
only_mean=False,
|
|
63
62
|
):
|
|
64
|
-
"""
|
|
65
|
-
Log a metric curve visualization.
|
|
63
|
+
"""Log a metric curve visualization.
|
|
66
64
|
|
|
67
|
-
This function generates a metric curve based on input data and logs the visualization to wandb.
|
|
68
|
-
|
|
65
|
+
This function generates a metric curve based on input data and logs the visualization to wandb. The curve can
|
|
66
|
+
represent aggregated data (mean) or individual class data, depending on the 'only_mean' flag.
|
|
69
67
|
|
|
70
68
|
Args:
|
|
71
69
|
x (np.ndarray): Data points for the x-axis with length N.
|
|
@@ -105,15 +103,14 @@ def _plot_curve(
|
|
|
105
103
|
|
|
106
104
|
|
|
107
105
|
def _log_plots(plots, step):
|
|
108
|
-
"""
|
|
109
|
-
Log plots to WandB at a specific step if they haven't been logged already.
|
|
106
|
+
"""Log plots to WandB at a specific step if they haven't been logged already.
|
|
110
107
|
|
|
111
|
-
This function checks each plot in the input dictionary against previously processed plots and logs
|
|
112
|
-
|
|
108
|
+
This function checks each plot in the input dictionary against previously processed plots and logs new or updated
|
|
109
|
+
plots to WandB at the specified step.
|
|
113
110
|
|
|
114
111
|
Args:
|
|
115
|
-
plots (dict): Dictionary of plots to log, where keys are plot names and values are dictionaries
|
|
116
|
-
|
|
112
|
+
plots (dict): Dictionary of plots to log, where keys are plot names and values are dictionaries containing plot
|
|
113
|
+
metadata including timestamps.
|
|
117
114
|
step (int): The step/epoch at which to log the plots in the WandB run.
|
|
118
115
|
|
|
119
116
|
Notes:
|
|
@@ -140,11 +137,11 @@ def on_pretrain_routine_start(trainer):
|
|
|
140
137
|
|
|
141
138
|
def on_fit_epoch_end(trainer):
|
|
142
139
|
"""Log training metrics and model information at the end of an epoch."""
|
|
143
|
-
wb.run.log(trainer.metrics, step=trainer.epoch + 1)
|
|
144
140
|
_log_plots(trainer.plots, step=trainer.epoch + 1)
|
|
145
141
|
_log_plots(trainer.validator.plots, step=trainer.epoch + 1)
|
|
146
142
|
if trainer.epoch == 0:
|
|
147
143
|
wb.run.log(model_info_for_loggers(trainer), step=trainer.epoch + 1)
|
|
144
|
+
wb.run.log(trainer.metrics, step=trainer.epoch + 1, commit=True) # commit forces sync
|
|
148
145
|
|
|
149
146
|
|
|
150
147
|
def on_train_epoch_end(trainer):
|
ultralytics/utils/checks.py
CHANGED
|
@@ -53,8 +53,7 @@ from ultralytics.utils import (
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
def parse_requirements(file_path=ROOT.parent / "requirements.txt", package=""):
|
|
56
|
-
"""
|
|
57
|
-
Parse a requirements.txt file, ignoring lines that start with '#' and any text after '#'.
|
|
56
|
+
"""Parse a requirements.txt file, ignoring lines that start with '#' and any text after '#'.
|
|
58
57
|
|
|
59
58
|
Args:
|
|
60
59
|
file_path (Path): Path to the requirements.txt file.
|
|
@@ -86,8 +85,7 @@ def parse_requirements(file_path=ROOT.parent / "requirements.txt", package=""):
|
|
|
86
85
|
|
|
87
86
|
@functools.lru_cache
|
|
88
87
|
def parse_version(version="0.0.0") -> tuple:
|
|
89
|
-
"""
|
|
90
|
-
Convert a version string to a tuple of integers, ignoring any extra non-numeric string attached to the version.
|
|
88
|
+
"""Convert a version string to a tuple of integers, ignoring any extra non-numeric string attached to the version.
|
|
91
89
|
|
|
92
90
|
Args:
|
|
93
91
|
version (str): Version string, i.e. '2.0.1+cpu'
|
|
@@ -103,8 +101,7 @@ def parse_version(version="0.0.0") -> tuple:
|
|
|
103
101
|
|
|
104
102
|
|
|
105
103
|
def is_ascii(s) -> bool:
|
|
106
|
-
"""
|
|
107
|
-
Check if a string is composed of only ASCII characters.
|
|
104
|
+
"""Check if a string is composed of only ASCII characters.
|
|
108
105
|
|
|
109
106
|
Args:
|
|
110
107
|
s (str | list | tuple | dict): Input to be checked (all are converted to string for checking).
|
|
@@ -116,8 +113,7 @@ def is_ascii(s) -> bool:
|
|
|
116
113
|
|
|
117
114
|
|
|
118
115
|
def check_imgsz(imgsz, stride=32, min_dim=1, max_dim=2, floor=0):
|
|
119
|
-
"""
|
|
120
|
-
Verify image size is a multiple of the given stride in each dimension. If the image size is not a multiple of the
|
|
116
|
+
"""Verify image size is a multiple of the given stride in each dimension. If the image size is not a multiple of the
|
|
121
117
|
stride, update it to the nearest multiple of the stride that is greater than or equal to the given floor value.
|
|
122
118
|
|
|
123
119
|
Args:
|
|
@@ -187,8 +183,7 @@ def check_version(
|
|
|
187
183
|
verbose: bool = False,
|
|
188
184
|
msg: str = "",
|
|
189
185
|
) -> bool:
|
|
190
|
-
"""
|
|
191
|
-
Check current version against the required version or range.
|
|
186
|
+
"""Check current version against the required version or range.
|
|
192
187
|
|
|
193
188
|
Args:
|
|
194
189
|
current (str): Current version or package name to get version from.
|
|
@@ -268,8 +263,7 @@ def check_version(
|
|
|
268
263
|
|
|
269
264
|
|
|
270
265
|
def check_latest_pypi_version(package_name="ultralytics"):
|
|
271
|
-
"""
|
|
272
|
-
Return the latest version of a PyPI package without downloading or installing it.
|
|
266
|
+
"""Return the latest version of a PyPI package without downloading or installing it.
|
|
273
267
|
|
|
274
268
|
Args:
|
|
275
269
|
package_name (str): The name of the package to find the latest version for.
|
|
@@ -289,8 +283,7 @@ def check_latest_pypi_version(package_name="ultralytics"):
|
|
|
289
283
|
|
|
290
284
|
|
|
291
285
|
def check_pip_update_available():
|
|
292
|
-
"""
|
|
293
|
-
Check if a new version of the ultralytics package is available on PyPI.
|
|
286
|
+
"""Check if a new version of the ultralytics package is available on PyPI.
|
|
294
287
|
|
|
295
288
|
Returns:
|
|
296
289
|
(bool): True if an update is available, False otherwise.
|
|
@@ -314,8 +307,7 @@ def check_pip_update_available():
|
|
|
314
307
|
@ThreadingLocked()
|
|
315
308
|
@functools.lru_cache
|
|
316
309
|
def check_font(font="Arial.ttf"):
|
|
317
|
-
"""
|
|
318
|
-
Find font locally or download to user's configuration directory if it does not already exist.
|
|
310
|
+
"""Find font locally or download to user's configuration directory if it does not already exist.
|
|
319
311
|
|
|
320
312
|
Args:
|
|
321
313
|
font (str): Path or name of font.
|
|
@@ -344,8 +336,7 @@ def check_font(font="Arial.ttf"):
|
|
|
344
336
|
|
|
345
337
|
|
|
346
338
|
def check_python(minimum: str = "3.8.0", hard: bool = True, verbose: bool = False) -> bool:
|
|
347
|
-
"""
|
|
348
|
-
Check current python version against the required minimum version.
|
|
339
|
+
"""Check current python version against the required minimum version.
|
|
349
340
|
|
|
350
341
|
Args:
|
|
351
342
|
minimum (str): Required minimum version of python.
|
|
@@ -360,13 +351,12 @@ def check_python(minimum: str = "3.8.0", hard: bool = True, verbose: bool = Fals
|
|
|
360
351
|
|
|
361
352
|
@TryExcept()
|
|
362
353
|
def check_requirements(requirements=ROOT.parent / "requirements.txt", exclude=(), install=True, cmds=""):
|
|
363
|
-
"""
|
|
364
|
-
Check if installed dependencies meet Ultralytics YOLO models requirements and attempt to auto-update if needed.
|
|
354
|
+
"""Check if installed dependencies meet Ultralytics YOLO models requirements and attempt to auto-update if needed.
|
|
365
355
|
|
|
366
356
|
Args:
|
|
367
357
|
requirements (Path | str | list[str|tuple] | tuple[str]): Path to a requirements.txt file, a single package
|
|
368
|
-
requirement as a string, a list of package requirements as strings, or a list containing strings and
|
|
369
|
-
|
|
358
|
+
requirement as a string, a list of package requirements as strings, or a list containing strings and tuples
|
|
359
|
+
of interchangeable packages.
|
|
370
360
|
exclude (tuple): Tuple of package names to exclude from checking.
|
|
371
361
|
install (bool): If True, attempt to auto-update packages that don't meet requirements.
|
|
372
362
|
cmds (str): Additional commands to pass to the pip install command when auto-updating.
|
|
@@ -459,8 +449,7 @@ def check_requirements(requirements=ROOT.parent / "requirements.txt", exclude=()
|
|
|
459
449
|
|
|
460
450
|
|
|
461
451
|
def check_torchvision():
|
|
462
|
-
"""
|
|
463
|
-
Check the installed versions of PyTorch and Torchvision to ensure they're compatible.
|
|
452
|
+
"""Check the installed versions of PyTorch and Torchvision to ensure they're compatible.
|
|
464
453
|
|
|
465
454
|
This function checks the installed versions of PyTorch and Torchvision, and warns if they're incompatible according
|
|
466
455
|
to the compatibility table based on: https://github.com/pytorch/vision#installation.
|
|
@@ -495,8 +484,7 @@ def check_torchvision():
|
|
|
495
484
|
|
|
496
485
|
|
|
497
486
|
def check_suffix(file="yolo11n.pt", suffix=".pt", msg=""):
|
|
498
|
-
"""
|
|
499
|
-
Check file(s) for acceptable suffix.
|
|
487
|
+
"""Check file(s) for acceptable suffix.
|
|
500
488
|
|
|
501
489
|
Args:
|
|
502
490
|
file (str | list[str]): File or list of files to check.
|
|
@@ -512,8 +500,7 @@ def check_suffix(file="yolo11n.pt", suffix=".pt", msg=""):
|
|
|
512
500
|
|
|
513
501
|
|
|
514
502
|
def check_yolov5u_filename(file: str, verbose: bool = True):
|
|
515
|
-
"""
|
|
516
|
-
Replace legacy YOLOv5 filenames with updated YOLOv5u filenames.
|
|
503
|
+
"""Replace legacy YOLOv5 filenames with updated YOLOv5u filenames.
|
|
517
504
|
|
|
518
505
|
Args:
|
|
519
506
|
file (str): Filename to check and potentially update.
|
|
@@ -540,8 +527,7 @@ def check_yolov5u_filename(file: str, verbose: bool = True):
|
|
|
540
527
|
|
|
541
528
|
|
|
542
529
|
def check_model_file_from_stem(model="yolo11n"):
|
|
543
|
-
"""
|
|
544
|
-
Return a model filename from a valid model stem.
|
|
530
|
+
"""Return a model filename from a valid model stem.
|
|
545
531
|
|
|
546
532
|
Args:
|
|
547
533
|
model (str): Model stem to check.
|
|
@@ -556,8 +542,7 @@ def check_model_file_from_stem(model="yolo11n"):
|
|
|
556
542
|
|
|
557
543
|
|
|
558
544
|
def check_file(file, suffix="", download=True, download_dir=".", hard=True):
|
|
559
|
-
"""
|
|
560
|
-
Search/download file (if necessary), check suffix (if provided), and return path.
|
|
545
|
+
"""Search/download file (if necessary), check suffix (if provided), and return path.
|
|
561
546
|
|
|
562
547
|
Args:
|
|
563
548
|
file (str): File name or path.
|
|
@@ -596,8 +581,7 @@ def check_file(file, suffix="", download=True, download_dir=".", hard=True):
|
|
|
596
581
|
|
|
597
582
|
|
|
598
583
|
def check_yaml(file, suffix=(".yaml", ".yml"), hard=True):
|
|
599
|
-
"""
|
|
600
|
-
Search/download YAML file (if necessary) and return path, checking suffix.
|
|
584
|
+
"""Search/download YAML file (if necessary) and return path, checking suffix.
|
|
601
585
|
|
|
602
586
|
Args:
|
|
603
587
|
file (str | Path): File name or path.
|
|
@@ -611,8 +595,7 @@ def check_yaml(file, suffix=(".yaml", ".yml"), hard=True):
|
|
|
611
595
|
|
|
612
596
|
|
|
613
597
|
def check_is_path_safe(basedir, path):
|
|
614
|
-
"""
|
|
615
|
-
Check if the resolved path is under the intended directory to prevent path traversal.
|
|
598
|
+
"""Check if the resolved path is under the intended directory to prevent path traversal.
|
|
616
599
|
|
|
617
600
|
Args:
|
|
618
601
|
basedir (Path | str): The intended directory.
|
|
@@ -629,8 +612,7 @@ def check_is_path_safe(basedir, path):
|
|
|
629
612
|
|
|
630
613
|
@functools.lru_cache
|
|
631
614
|
def check_imshow(warn=False):
|
|
632
|
-
"""
|
|
633
|
-
Check if environment supports image displays.
|
|
615
|
+
"""Check if environment supports image displays.
|
|
634
616
|
|
|
635
617
|
Args:
|
|
636
618
|
warn (bool): Whether to warn if environment doesn't support image displays.
|
|
@@ -654,8 +636,7 @@ def check_imshow(warn=False):
|
|
|
654
636
|
|
|
655
637
|
|
|
656
638
|
def check_yolo(verbose=True, device=""):
|
|
657
|
-
"""
|
|
658
|
-
Return a human-readable YOLO software and hardware summary.
|
|
639
|
+
"""Return a human-readable YOLO software and hardware summary.
|
|
659
640
|
|
|
660
641
|
Args:
|
|
661
642
|
verbose (bool): Whether to print verbose information.
|
|
@@ -691,8 +672,7 @@ def check_yolo(verbose=True, device=""):
|
|
|
691
672
|
|
|
692
673
|
|
|
693
674
|
def collect_system_info():
|
|
694
|
-
"""
|
|
695
|
-
Collect and print relevant system information including OS, Python, RAM, CPU, and CUDA.
|
|
675
|
+
"""Collect and print relevant system information including OS, Python, RAM, CPU, and CUDA.
|
|
696
676
|
|
|
697
677
|
Returns:
|
|
698
678
|
(dict): Dictionary containing system information.
|
|
@@ -752,8 +732,7 @@ def collect_system_info():
|
|
|
752
732
|
|
|
753
733
|
|
|
754
734
|
def check_amp(model):
|
|
755
|
-
"""
|
|
756
|
-
Check the PyTorch Automatic Mixed Precision (AMP) functionality of a YOLO model.
|
|
735
|
+
"""Check the PyTorch Automatic Mixed Precision (AMP) functionality of a YOLO model.
|
|
757
736
|
|
|
758
737
|
If the checks fail, it means there are anomalies with AMP on the system that may cause NaN losses or zero-mAP
|
|
759
738
|
results, so AMP will be disabled during training.
|
|
@@ -849,8 +828,7 @@ def check_multiple_install():
|
|
|
849
828
|
|
|
850
829
|
|
|
851
830
|
def print_args(args: dict | None = None, show_file=True, show_func=False):
|
|
852
|
-
"""
|
|
853
|
-
Print function arguments (optional args dict).
|
|
831
|
+
"""Print function arguments (optional args dict).
|
|
854
832
|
|
|
855
833
|
Args:
|
|
856
834
|
args (dict, optional): Arguments to print.
|
|
@@ -876,8 +854,7 @@ def print_args(args: dict | None = None, show_file=True, show_func=False):
|
|
|
876
854
|
|
|
877
855
|
|
|
878
856
|
def cuda_device_count() -> int:
|
|
879
|
-
"""
|
|
880
|
-
Get the number of NVIDIA GPUs available in the environment.
|
|
857
|
+
"""Get the number of NVIDIA GPUs available in the environment.
|
|
881
858
|
|
|
882
859
|
Returns:
|
|
883
860
|
(int): The number of NVIDIA GPUs available.
|
|
@@ -902,8 +879,7 @@ def cuda_device_count() -> int:
|
|
|
902
879
|
|
|
903
880
|
|
|
904
881
|
def cuda_is_available() -> bool:
|
|
905
|
-
"""
|
|
906
|
-
Check if CUDA is available in the environment.
|
|
882
|
+
"""Check if CUDA is available in the environment.
|
|
907
883
|
|
|
908
884
|
Returns:
|
|
909
885
|
(bool): True if one or more NVIDIA GPUs are available, False otherwise.
|
|
@@ -912,8 +888,7 @@ def cuda_is_available() -> bool:
|
|
|
912
888
|
|
|
913
889
|
|
|
914
890
|
def is_rockchip():
|
|
915
|
-
"""
|
|
916
|
-
Check if the current environment is running on a Rockchip SoC.
|
|
891
|
+
"""Check if the current environment is running on a Rockchip SoC.
|
|
917
892
|
|
|
918
893
|
Returns:
|
|
919
894
|
(bool): True if running on a Rockchip SoC, False otherwise.
|
|
@@ -932,8 +907,7 @@ def is_rockchip():
|
|
|
932
907
|
|
|
933
908
|
|
|
934
909
|
def is_intel():
|
|
935
|
-
"""
|
|
936
|
-
Check if the system has Intel hardware (CPU or GPU).
|
|
910
|
+
"""Check if the system has Intel hardware (CPU or GPU).
|
|
937
911
|
|
|
938
912
|
Returns:
|
|
939
913
|
(bool): True if Intel hardware is detected, False otherwise.
|
|
@@ -953,8 +927,7 @@ def is_intel():
|
|
|
953
927
|
|
|
954
928
|
|
|
955
929
|
def is_sudo_available() -> bool:
|
|
956
|
-
"""
|
|
957
|
-
Check if the sudo command is available in the environment.
|
|
930
|
+
"""Check if the sudo command is available in the environment.
|
|
958
931
|
|
|
959
932
|
Returns:
|
|
960
933
|
(bool): True if the sudo command is available, False otherwise.
|
ultralytics/utils/cpu.py
CHANGED
|
@@ -10,8 +10,7 @@ from pathlib import Path
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class CPUInfo:
|
|
13
|
-
"""
|
|
14
|
-
Provide cross-platform CPU brand and model information.
|
|
13
|
+
"""Provide cross-platform CPU brand and model information.
|
|
15
14
|
|
|
16
15
|
Query platform-specific sources to retrieve a human-readable CPU descriptor and normalize it for consistent
|
|
17
16
|
presentation across macOS, Linux, and Windows. If platform-specific probing fails, generic platform identifiers are
|
ultralytics/utils/dist.py
CHANGED
|
@@ -10,8 +10,7 @@ from .torch_utils import TORCH_1_9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def find_free_network_port() -> int:
|
|
13
|
-
"""
|
|
14
|
-
Find a free port on localhost.
|
|
13
|
+
"""Find a free port on localhost.
|
|
15
14
|
|
|
16
15
|
It is useful in single-node training when we don't want to connect to a real main node but have to set the
|
|
17
16
|
`MASTER_PORT` environment variable.
|
|
@@ -27,11 +26,10 @@ def find_free_network_port() -> int:
|
|
|
27
26
|
|
|
28
27
|
|
|
29
28
|
def generate_ddp_file(trainer):
|
|
30
|
-
"""
|
|
31
|
-
Generate a DDP (Distributed Data Parallel) file for multi-GPU training.
|
|
29
|
+
"""Generate a DDP (Distributed Data Parallel) file for multi-GPU training.
|
|
32
30
|
|
|
33
|
-
This function creates a temporary Python file that enables distributed training across multiple GPUs.
|
|
34
|
-
|
|
31
|
+
This function creates a temporary Python file that enables distributed training across multiple GPUs. The file
|
|
32
|
+
contains the necessary configuration to initialize the trainer in a distributed environment.
|
|
35
33
|
|
|
36
34
|
Args:
|
|
37
35
|
trainer (ultralytics.engine.trainer.BaseTrainer): The trainer containing training configuration and arguments.
|
|
@@ -77,8 +75,7 @@ if __name__ == "__main__":
|
|
|
77
75
|
|
|
78
76
|
|
|
79
77
|
def generate_ddp_command(trainer):
|
|
80
|
-
"""
|
|
81
|
-
Generate command for distributed training.
|
|
78
|
+
"""Generate command for distributed training.
|
|
82
79
|
|
|
83
80
|
Args:
|
|
84
81
|
trainer (ultralytics.engine.trainer.BaseTrainer): The trainer containing configuration for distributed training.
|
|
@@ -108,11 +105,10 @@ def generate_ddp_command(trainer):
|
|
|
108
105
|
|
|
109
106
|
|
|
110
107
|
def ddp_cleanup(trainer, file):
|
|
111
|
-
"""
|
|
112
|
-
Delete temporary file if created during distributed data parallel (DDP) training.
|
|
108
|
+
"""Delete temporary file if created during distributed data parallel (DDP) training.
|
|
113
109
|
|
|
114
|
-
This function checks if the provided file contains the trainer's ID in its name, indicating it was created
|
|
115
|
-
|
|
110
|
+
This function checks if the provided file contains the trainer's ID in its name, indicating it was created as a
|
|
111
|
+
temporary file for DDP training, and deletes it if so.
|
|
116
112
|
|
|
117
113
|
Args:
|
|
118
114
|
trainer (ultralytics.engine.trainer.BaseTrainer): The trainer used for distributed training.
|
ultralytics/utils/downloads.py
CHANGED
|
@@ -43,8 +43,7 @@ GITHUB_ASSETS_STEMS = frozenset(k.rpartition(".")[0] for k in GITHUB_ASSETS_NAME
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
def is_url(url: str | Path, check: bool = False) -> bool:
|
|
46
|
-
"""
|
|
47
|
-
Validate if the given string is a URL and optionally check if the URL exists online.
|
|
46
|
+
"""Validate if the given string is a URL and optionally check if the URL exists online.
|
|
48
47
|
|
|
49
48
|
Args:
|
|
50
49
|
url (str): The string to be validated as a URL.
|
|
@@ -71,8 +70,7 @@ def is_url(url: str | Path, check: bool = False) -> bool:
|
|
|
71
70
|
|
|
72
71
|
|
|
73
72
|
def delete_dsstore(path: str | Path, files_to_delete: tuple[str, ...] = (".DS_Store", "__MACOSX")) -> None:
|
|
74
|
-
"""
|
|
75
|
-
Delete all specified system files in a directory.
|
|
73
|
+
"""Delete all specified system files in a directory.
|
|
76
74
|
|
|
77
75
|
Args:
|
|
78
76
|
path (str | Path): The directory path where the files should be deleted.
|
|
@@ -99,8 +97,7 @@ def zip_directory(
|
|
|
99
97
|
exclude: tuple[str, ...] = (".DS_Store", "__MACOSX"),
|
|
100
98
|
progress: bool = True,
|
|
101
99
|
) -> Path:
|
|
102
|
-
"""
|
|
103
|
-
Zip the contents of a directory, excluding specified files.
|
|
100
|
+
"""Zip the contents of a directory, excluding specified files.
|
|
104
101
|
|
|
105
102
|
The resulting zip file is named after the directory and placed alongside it.
|
|
106
103
|
|
|
@@ -142,12 +139,11 @@ def unzip_file(
|
|
|
142
139
|
exist_ok: bool = False,
|
|
143
140
|
progress: bool = True,
|
|
144
141
|
) -> Path:
|
|
145
|
-
"""
|
|
146
|
-
Unzip a *.zip file to the specified path, excluding specified files.
|
|
142
|
+
"""Unzip a *.zip file to the specified path, excluding specified files.
|
|
147
143
|
|
|
148
|
-
If the zipfile does not contain a single top-level directory, the function will create a new
|
|
149
|
-
|
|
150
|
-
|
|
144
|
+
If the zipfile does not contain a single top-level directory, the function will create a new directory with the same
|
|
145
|
+
name as the zipfile (without the extension) to extract its contents. If a path is not provided, the function will
|
|
146
|
+
use the parent directory of the zipfile as the default path.
|
|
151
147
|
|
|
152
148
|
Args:
|
|
153
149
|
file (str | Path): The path to the zipfile to be extracted.
|
|
@@ -210,8 +206,7 @@ def check_disk_space(
|
|
|
210
206
|
sf: float = 1.5,
|
|
211
207
|
hard: bool = True,
|
|
212
208
|
) -> bool:
|
|
213
|
-
"""
|
|
214
|
-
Check if there is sufficient disk space to download and store a file.
|
|
209
|
+
"""Check if there is sufficient disk space to download and store a file.
|
|
215
210
|
|
|
216
211
|
Args:
|
|
217
212
|
file_bytes (int): The file size in bytes.
|
|
@@ -238,8 +233,7 @@ def check_disk_space(
|
|
|
238
233
|
|
|
239
234
|
|
|
240
235
|
def get_google_drive_file_info(link: str) -> tuple[str, str | None]:
|
|
241
|
-
"""
|
|
242
|
-
Retrieve the direct download link and filename for a shareable Google Drive file link.
|
|
236
|
+
"""Retrieve the direct download link and filename for a shareable Google Drive file link.
|
|
243
237
|
|
|
244
238
|
Args:
|
|
245
239
|
link (str): The shareable link of the Google Drive file.
|
|
@@ -289,16 +283,15 @@ def safe_download(
|
|
|
289
283
|
exist_ok: bool = False,
|
|
290
284
|
progress: bool = True,
|
|
291
285
|
) -> Path | str:
|
|
292
|
-
"""
|
|
293
|
-
Download files from a URL with options for retrying, unzipping, and deleting the downloaded file. Enhanced with
|
|
286
|
+
"""Download files from a URL with options for retrying, unzipping, and deleting the downloaded file. Enhanced with
|
|
294
287
|
robust partial download detection using Content-Length validation.
|
|
295
288
|
|
|
296
289
|
Args:
|
|
297
290
|
url (str): The URL of the file to be downloaded.
|
|
298
|
-
file (str, optional): The filename of the downloaded file.
|
|
299
|
-
|
|
300
|
-
dir (str | Path, optional): The directory to save the downloaded file.
|
|
301
|
-
|
|
291
|
+
file (str, optional): The filename of the downloaded file. If not provided, the file will be saved with the same
|
|
292
|
+
name as the URL.
|
|
293
|
+
dir (str | Path, optional): The directory to save the downloaded file. If not provided, the file will be saved
|
|
294
|
+
in the current working directory.
|
|
302
295
|
unzip (bool, optional): Whether to unzip the downloaded file.
|
|
303
296
|
delete (bool, optional): Whether to delete the downloaded file after unzipping.
|
|
304
297
|
curl (bool, optional): Whether to use curl command line tool for downloading.
|
|
@@ -397,8 +390,7 @@ def get_github_assets(
|
|
|
397
390
|
version: str = "latest",
|
|
398
391
|
retry: bool = False,
|
|
399
392
|
) -> tuple[str, list[str]]:
|
|
400
|
-
"""
|
|
401
|
-
Retrieve the specified version's tag and assets from a GitHub repository.
|
|
393
|
+
"""Retrieve the specified version's tag and assets from a GitHub repository.
|
|
402
394
|
|
|
403
395
|
If the version is not specified, the function fetches the latest release assets.
|
|
404
396
|
|
|
@@ -435,8 +427,7 @@ def attempt_download_asset(
|
|
|
435
427
|
release: str = "v8.3.0",
|
|
436
428
|
**kwargs,
|
|
437
429
|
) -> str:
|
|
438
|
-
"""
|
|
439
|
-
Attempt to download a file from GitHub release assets if it is not found locally.
|
|
430
|
+
"""Attempt to download a file from GitHub release assets if it is not found locally.
|
|
440
431
|
|
|
441
432
|
Args:
|
|
442
433
|
file (str | Path): The filename or file path to be downloaded.
|
|
@@ -495,8 +486,7 @@ def download(
|
|
|
495
486
|
retry: int = 3,
|
|
496
487
|
exist_ok: bool = False,
|
|
497
488
|
) -> None:
|
|
498
|
-
"""
|
|
499
|
-
Download files from specified URLs to a given directory.
|
|
489
|
+
"""Download files from specified URLs to a given directory.
|
|
500
490
|
|
|
501
491
|
Supports concurrent downloads if multiple threads are specified.
|
|
502
492
|
|
ultralytics/utils/errors.py
CHANGED
|
@@ -4,11 +4,10 @@ from ultralytics.utils import emojis
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class HUBModelError(Exception):
|
|
7
|
-
"""
|
|
8
|
-
Exception raised when a model cannot be found or retrieved from Ultralytics HUB.
|
|
7
|
+
"""Exception raised when a model cannot be found or retrieved from Ultralytics HUB.
|
|
9
8
|
|
|
10
|
-
This custom exception is used specifically for handling errors related to model fetching in Ultralytics YOLO.
|
|
11
|
-
|
|
9
|
+
This custom exception is used specifically for handling errors related to model fetching in Ultralytics YOLO. The
|
|
10
|
+
error message is processed to include emojis for better user experience.
|
|
12
11
|
|
|
13
12
|
Attributes:
|
|
14
13
|
message (str): The error message displayed when the exception is raised.
|
|
@@ -25,11 +24,10 @@ class HUBModelError(Exception):
|
|
|
25
24
|
"""
|
|
26
25
|
|
|
27
26
|
def __init__(self, message: str = "Model not found. Please check model URL and try again."):
|
|
28
|
-
"""
|
|
29
|
-
Initialize a HUBModelError exception.
|
|
27
|
+
"""Initialize a HUBModelError exception.
|
|
30
28
|
|
|
31
|
-
This exception is raised when a requested model is not found or cannot be retrieved from Ultralytics HUB.
|
|
32
|
-
|
|
29
|
+
This exception is raised when a requested model is not found or cannot be retrieved from Ultralytics HUB. The
|
|
30
|
+
message is processed to include emojis for better user experience.
|
|
33
31
|
|
|
34
32
|
Args:
|
|
35
33
|
message (str, optional): The error message to display when the exception is raised.
|
ultralytics/utils/events.py
CHANGED
|
@@ -24,8 +24,7 @@ def _post(url: str, data: dict, timeout: float = 5.0) -> None:
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
class Events:
|
|
27
|
-
"""
|
|
28
|
-
Collect and send anonymous usage analytics with rate-limiting.
|
|
27
|
+
"""Collect and send anonymous usage analytics with rate-limiting.
|
|
29
28
|
|
|
30
29
|
Event collection and transmission are enabled when sync is enabled in settings, the current process is rank -1 or 0,
|
|
31
30
|
tests are not running, the environment is online, and the installation source is either pip or the official
|
|
@@ -71,8 +70,7 @@ class Events:
|
|
|
71
70
|
)
|
|
72
71
|
|
|
73
72
|
def __call__(self, cfg, device=None) -> None:
|
|
74
|
-
"""
|
|
75
|
-
Queue an event and flush the queue asynchronously when the rate limit elapses.
|
|
73
|
+
"""Queue an event and flush the queue asynchronously when the rate limit elapses.
|
|
76
74
|
|
|
77
75
|
Args:
|
|
78
76
|
cfg (IterableSimpleNamespace): The configuration object containing mode and task information.
|