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.
Files changed (158) hide show
  1. {dgenerate_ultralytics_headless-8.3.222.dist-info → dgenerate_ultralytics_headless-8.3.225.dist-info}/METADATA +2 -2
  2. dgenerate_ultralytics_headless-8.3.225.dist-info/RECORD +286 -0
  3. tests/conftest.py +5 -8
  4. tests/test_cli.py +1 -8
  5. tests/test_python.py +1 -2
  6. ultralytics/__init__.py +1 -1
  7. ultralytics/cfg/__init__.py +34 -49
  8. ultralytics/cfg/datasets/ImageNet.yaml +1 -1
  9. ultralytics/cfg/datasets/kitti.yaml +27 -0
  10. ultralytics/cfg/datasets/lvis.yaml +5 -5
  11. ultralytics/cfg/datasets/open-images-v7.yaml +1 -1
  12. ultralytics/data/annotator.py +3 -4
  13. ultralytics/data/augment.py +244 -323
  14. ultralytics/data/base.py +12 -22
  15. ultralytics/data/build.py +47 -40
  16. ultralytics/data/converter.py +32 -42
  17. ultralytics/data/dataset.py +43 -71
  18. ultralytics/data/loaders.py +22 -34
  19. ultralytics/data/split.py +5 -6
  20. ultralytics/data/split_dota.py +8 -15
  21. ultralytics/data/utils.py +27 -36
  22. ultralytics/engine/exporter.py +49 -116
  23. ultralytics/engine/model.py +144 -180
  24. ultralytics/engine/predictor.py +18 -29
  25. ultralytics/engine/results.py +165 -231
  26. ultralytics/engine/trainer.py +11 -19
  27. ultralytics/engine/tuner.py +13 -23
  28. ultralytics/engine/validator.py +6 -10
  29. ultralytics/hub/__init__.py +7 -12
  30. ultralytics/hub/auth.py +6 -12
  31. ultralytics/hub/google/__init__.py +7 -10
  32. ultralytics/hub/session.py +15 -25
  33. ultralytics/hub/utils.py +3 -6
  34. ultralytics/models/fastsam/model.py +6 -8
  35. ultralytics/models/fastsam/predict.py +5 -10
  36. ultralytics/models/fastsam/utils.py +1 -2
  37. ultralytics/models/fastsam/val.py +2 -4
  38. ultralytics/models/nas/model.py +5 -8
  39. ultralytics/models/nas/predict.py +7 -9
  40. ultralytics/models/nas/val.py +1 -2
  41. ultralytics/models/rtdetr/model.py +5 -8
  42. ultralytics/models/rtdetr/predict.py +15 -18
  43. ultralytics/models/rtdetr/train.py +10 -13
  44. ultralytics/models/rtdetr/val.py +13 -20
  45. ultralytics/models/sam/amg.py +12 -18
  46. ultralytics/models/sam/build.py +6 -9
  47. ultralytics/models/sam/model.py +16 -23
  48. ultralytics/models/sam/modules/blocks.py +62 -84
  49. ultralytics/models/sam/modules/decoders.py +17 -24
  50. ultralytics/models/sam/modules/encoders.py +40 -56
  51. ultralytics/models/sam/modules/memory_attention.py +10 -16
  52. ultralytics/models/sam/modules/sam.py +41 -47
  53. ultralytics/models/sam/modules/tiny_encoder.py +64 -83
  54. ultralytics/models/sam/modules/transformer.py +17 -27
  55. ultralytics/models/sam/modules/utils.py +31 -42
  56. ultralytics/models/sam/predict.py +172 -209
  57. ultralytics/models/utils/loss.py +14 -26
  58. ultralytics/models/utils/ops.py +13 -17
  59. ultralytics/models/yolo/classify/predict.py +8 -11
  60. ultralytics/models/yolo/classify/train.py +8 -16
  61. ultralytics/models/yolo/classify/val.py +13 -20
  62. ultralytics/models/yolo/detect/predict.py +4 -8
  63. ultralytics/models/yolo/detect/train.py +11 -20
  64. ultralytics/models/yolo/detect/val.py +38 -48
  65. ultralytics/models/yolo/model.py +35 -47
  66. ultralytics/models/yolo/obb/predict.py +5 -8
  67. ultralytics/models/yolo/obb/train.py +11 -14
  68. ultralytics/models/yolo/obb/val.py +20 -28
  69. ultralytics/models/yolo/pose/predict.py +5 -8
  70. ultralytics/models/yolo/pose/train.py +4 -8
  71. ultralytics/models/yolo/pose/val.py +31 -39
  72. ultralytics/models/yolo/segment/predict.py +9 -14
  73. ultralytics/models/yolo/segment/train.py +3 -6
  74. ultralytics/models/yolo/segment/val.py +16 -26
  75. ultralytics/models/yolo/world/train.py +8 -14
  76. ultralytics/models/yolo/world/train_world.py +11 -16
  77. ultralytics/models/yolo/yoloe/predict.py +16 -23
  78. ultralytics/models/yolo/yoloe/train.py +30 -43
  79. ultralytics/models/yolo/yoloe/train_seg.py +5 -10
  80. ultralytics/models/yolo/yoloe/val.py +15 -20
  81. ultralytics/nn/autobackend.py +10 -18
  82. ultralytics/nn/modules/activation.py +4 -6
  83. ultralytics/nn/modules/block.py +99 -185
  84. ultralytics/nn/modules/conv.py +45 -90
  85. ultralytics/nn/modules/head.py +44 -98
  86. ultralytics/nn/modules/transformer.py +44 -76
  87. ultralytics/nn/modules/utils.py +14 -19
  88. ultralytics/nn/tasks.py +86 -146
  89. ultralytics/nn/text_model.py +25 -40
  90. ultralytics/solutions/ai_gym.py +10 -16
  91. ultralytics/solutions/analytics.py +7 -10
  92. ultralytics/solutions/config.py +4 -5
  93. ultralytics/solutions/distance_calculation.py +9 -12
  94. ultralytics/solutions/heatmap.py +7 -13
  95. ultralytics/solutions/instance_segmentation.py +5 -8
  96. ultralytics/solutions/object_blurrer.py +7 -10
  97. ultralytics/solutions/object_counter.py +8 -12
  98. ultralytics/solutions/object_cropper.py +5 -8
  99. ultralytics/solutions/parking_management.py +12 -14
  100. ultralytics/solutions/queue_management.py +4 -6
  101. ultralytics/solutions/region_counter.py +7 -10
  102. ultralytics/solutions/security_alarm.py +14 -19
  103. ultralytics/solutions/similarity_search.py +7 -12
  104. ultralytics/solutions/solutions.py +31 -53
  105. ultralytics/solutions/speed_estimation.py +6 -9
  106. ultralytics/solutions/streamlit_inference.py +2 -4
  107. ultralytics/solutions/trackzone.py +7 -10
  108. ultralytics/solutions/vision_eye.py +5 -8
  109. ultralytics/trackers/basetrack.py +2 -4
  110. ultralytics/trackers/bot_sort.py +6 -11
  111. ultralytics/trackers/byte_tracker.py +10 -15
  112. ultralytics/trackers/track.py +3 -6
  113. ultralytics/trackers/utils/gmc.py +6 -12
  114. ultralytics/trackers/utils/kalman_filter.py +35 -43
  115. ultralytics/trackers/utils/matching.py +6 -10
  116. ultralytics/utils/__init__.py +61 -100
  117. ultralytics/utils/autobatch.py +2 -4
  118. ultralytics/utils/autodevice.py +11 -13
  119. ultralytics/utils/benchmarks.py +25 -35
  120. ultralytics/utils/callbacks/base.py +8 -10
  121. ultralytics/utils/callbacks/clearml.py +2 -4
  122. ultralytics/utils/callbacks/comet.py +30 -44
  123. ultralytics/utils/callbacks/dvc.py +13 -18
  124. ultralytics/utils/callbacks/mlflow.py +4 -5
  125. ultralytics/utils/callbacks/neptune.py +4 -6
  126. ultralytics/utils/callbacks/raytune.py +3 -4
  127. ultralytics/utils/callbacks/tensorboard.py +4 -6
  128. ultralytics/utils/callbacks/wb.py +10 -13
  129. ultralytics/utils/checks.py +29 -56
  130. ultralytics/utils/cpu.py +1 -2
  131. ultralytics/utils/dist.py +8 -12
  132. ultralytics/utils/downloads.py +17 -27
  133. ultralytics/utils/errors.py +6 -8
  134. ultralytics/utils/events.py +2 -4
  135. ultralytics/utils/export/__init__.py +4 -239
  136. ultralytics/utils/export/engine.py +237 -0
  137. ultralytics/utils/export/imx.py +11 -17
  138. ultralytics/utils/export/tensorflow.py +217 -0
  139. ultralytics/utils/files.py +10 -15
  140. ultralytics/utils/git.py +5 -7
  141. ultralytics/utils/instance.py +30 -51
  142. ultralytics/utils/logger.py +11 -15
  143. ultralytics/utils/loss.py +8 -14
  144. ultralytics/utils/metrics.py +98 -138
  145. ultralytics/utils/nms.py +13 -16
  146. ultralytics/utils/ops.py +47 -74
  147. ultralytics/utils/patches.py +11 -18
  148. ultralytics/utils/plotting.py +29 -42
  149. ultralytics/utils/tal.py +25 -39
  150. ultralytics/utils/torch_utils.py +45 -73
  151. ultralytics/utils/tqdm.py +6 -8
  152. ultralytics/utils/triton.py +9 -12
  153. ultralytics/utils/tuner.py +1 -2
  154. dgenerate_ultralytics_headless-8.3.222.dist-info/RECORD +0 -283
  155. {dgenerate_ultralytics_headless-8.3.222.dist-info → dgenerate_ultralytics_headless-8.3.225.dist-info}/WHEEL +0 -0
  156. {dgenerate_ultralytics_headless-8.3.222.dist-info → dgenerate_ultralytics_headless-8.3.225.dist-info}/entry_points.txt +0 -0
  157. {dgenerate_ultralytics_headless-8.3.222.dist-info → dgenerate_ultralytics_headless-8.3.225.dist-info}/licenses/LICENSE +0 -0
  158. {dgenerate_ultralytics_headless-8.3.222.dist-info → dgenerate_ultralytics_headless-8.3.225.dist-info}/top_level.txt +0 -0
@@ -25,6 +25,7 @@ MNN | `mnn` | yolo11n.mnn
25
25
  NCNN | `ncnn` | yolo11n_ncnn_model/
26
26
  IMX | `imx` | yolo11n_imx_model/
27
27
  RKNN | `rknn` | yolo11n_rknn_model/
28
+ ExecuTorch | `executorch` | yolo11n_executorch_model/
28
29
  """
29
30
 
30
31
  from __future__ import annotations
@@ -62,8 +63,7 @@ def benchmark(
62
63
  format="",
63
64
  **kwargs,
64
65
  ):
65
- """
66
- Benchmark a YOLO model across different formats for speed and accuracy.
66
+ """Benchmark a YOLO model across different formats for speed and accuracy.
67
67
 
68
68
  Args:
69
69
  model (str | Path): Path to the model file or directory.
@@ -78,8 +78,8 @@ def benchmark(
78
78
  **kwargs (Any): Additional keyword arguments for exporter.
79
79
 
80
80
  Returns:
81
- (polars.DataFrame): A polars DataFrame with benchmark results for each format, including file size, metric,
82
- and inference time.
81
+ (polars.DataFrame): A polars DataFrame with benchmark results for each format, including file size, metric, and
82
+ inference time.
83
83
 
84
84
  Examples:
85
85
  Benchmark a YOLO model with default settings:
@@ -153,6 +153,9 @@ def benchmark(
153
153
  assert not is_end2end, "End-to-end models not supported by RKNN yet"
154
154
  assert LINUX, "RKNN only supported on Linux"
155
155
  assert not is_rockchip(), "RKNN Inference only supported on Rockchip devices"
156
+ if format == "executorch":
157
+ assert not isinstance(model, YOLOWorld), "YOLOWorldv2 ExecuTorch exports not supported yet"
158
+ assert not is_end2end, "End-to-end models not supported by ExecuTorch yet"
156
159
  if "cpu" in device.type:
157
160
  assert cpu, "inference not supported on CPU"
158
161
  if "cuda" in device.type:
@@ -172,6 +175,7 @@ def benchmark(
172
175
 
173
176
  # Predict
174
177
  assert model.task != "pose" or format != "pb", "GraphDef Pose inference is not supported"
178
+ assert model.task != "pose" or format != "executorch", "ExecuTorch Pose inference is not supported"
175
179
  assert format not in {"edgetpu", "tfjs"}, "inference not supported"
176
180
  assert format != "coreml" or platform.system() == "Darwin", "inference only supported on macOS>=10.13"
177
181
  if format == "ncnn":
@@ -222,8 +226,7 @@ def benchmark(
222
226
 
223
227
 
224
228
  class RF100Benchmark:
225
- """
226
- Benchmark YOLO model performance across various formats for speed and accuracy.
229
+ """Benchmark YOLO model performance across various formats for speed and accuracy.
227
230
 
228
231
  This class provides functionality to benchmark YOLO models on the RF100 dataset collection.
229
232
 
@@ -248,8 +251,7 @@ class RF100Benchmark:
248
251
  self.val_metrics = ["class", "images", "targets", "precision", "recall", "map50", "map95"]
249
252
 
250
253
  def set_key(self, api_key: str):
251
- """
252
- Set Roboflow API key for processing.
254
+ """Set Roboflow API key for processing.
253
255
 
254
256
  Args:
255
257
  api_key (str): The API key.
@@ -265,8 +267,7 @@ class RF100Benchmark:
265
267
  self.rf = Roboflow(api_key=api_key)
266
268
 
267
269
  def parse_dataset(self, ds_link_txt: str = "datasets_links.txt"):
268
- """
269
- Parse dataset links and download datasets.
270
+ """Parse dataset links and download datasets.
270
271
 
271
272
  Args:
272
273
  ds_link_txt (str): Path to the file containing dataset links.
@@ -310,8 +311,7 @@ class RF100Benchmark:
310
311
  YAML.dump(yaml_data, path)
311
312
 
312
313
  def evaluate(self, yaml_path: str, val_log_file: str, eval_log_file: str, list_ind: int):
313
- """
314
- Evaluate model performance on validation results.
314
+ """Evaluate model performance on validation results.
315
315
 
316
316
  Args:
317
317
  yaml_path (str): Path to the YAML configuration file.
@@ -368,8 +368,7 @@ class RF100Benchmark:
368
368
 
369
369
 
370
370
  class ProfileModels:
371
- """
372
- ProfileModels class for profiling different models on ONNX and TensorRT.
371
+ """ProfileModels class for profiling different models on ONNX and TensorRT.
373
372
 
374
373
  This class profiles the performance of different models, returning results such as model speed and FLOPs.
375
374
 
@@ -412,8 +411,7 @@ class ProfileModels:
412
411
  trt: bool = True,
413
412
  device: torch.device | str | None = None,
414
413
  ):
415
- """
416
- Initialize the ProfileModels class for profiling models.
414
+ """Initialize the ProfileModels class for profiling models.
417
415
 
418
416
  Args:
419
417
  paths (list[str]): List of paths of the models to be profiled.
@@ -425,14 +423,14 @@ class ProfileModels:
425
423
  trt (bool): Flag to indicate whether to profile using TensorRT.
426
424
  device (torch.device | str | None): Device used for profiling. If None, it is determined automatically.
427
425
 
428
- Notes:
429
- FP16 'half' argument option removed for ONNX as slower on CPU than FP32.
430
-
431
426
  Examples:
432
427
  Initialize and profile models
433
428
  >>> from ultralytics.utils.benchmarks import ProfileModels
434
429
  >>> profiler = ProfileModels(["yolo11n.yaml", "yolov8s.yaml"], imgsz=640)
435
430
  >>> profiler.run()
431
+
432
+ Notes:
433
+ FP16 'half' argument option removed for ONNX as slower on CPU than FP32.
436
434
  """
437
435
  self.paths = paths
438
436
  self.num_timed_runs = num_timed_runs
@@ -444,8 +442,7 @@ class ProfileModels:
444
442
  self.device = device if isinstance(device, torch.device) else select_device(device)
445
443
 
446
444
  def run(self):
447
- """
448
- Profile YOLO models for speed and accuracy across various formats including ONNX and TensorRT.
445
+ """Profile YOLO models for speed and accuracy across various formats including ONNX and TensorRT.
449
446
 
450
447
  Returns:
451
448
  (list[dict]): List of dictionaries containing profiling results for each model.
@@ -499,8 +496,7 @@ class ProfileModels:
499
496
  return output
500
497
 
501
498
  def get_files(self):
502
- """
503
- Return a list of paths for all relevant model files given by the user.
499
+ """Return a list of paths for all relevant model files given by the user.
504
500
 
505
501
  Returns:
506
502
  (list[Path]): List of Path objects for the model files.
@@ -526,8 +522,7 @@ class ProfileModels:
526
522
 
527
523
  @staticmethod
528
524
  def iterative_sigma_clipping(data: np.ndarray, sigma: float = 2, max_iters: int = 3):
529
- """
530
- Apply iterative sigma clipping to data to remove outliers.
525
+ """Apply iterative sigma clipping to data to remove outliers.
531
526
 
532
527
  Args:
533
528
  data (np.ndarray): Input data array.
@@ -547,8 +542,7 @@ class ProfileModels:
547
542
  return data
548
543
 
549
544
  def profile_tensorrt_model(self, engine_file: str, eps: float = 1e-3):
550
- """
551
- Profile YOLO model performance with TensorRT, measuring average run time and standard deviation.
545
+ """Profile YOLO model performance with TensorRT, measuring average run time and standard deviation.
552
546
 
553
547
  Args:
554
548
  engine_file (str): Path to the TensorRT engine file.
@@ -591,8 +585,7 @@ class ProfileModels:
591
585
  return not all(isinstance(dim, int) and dim >= 0 for dim in tensor_shape)
592
586
 
593
587
  def profile_onnx_model(self, onnx_file: str, eps: float = 1e-3):
594
- """
595
- Profile an ONNX model, measuring average inference time and standard deviation across multiple runs.
588
+ """Profile an ONNX model, measuring average inference time and standard deviation across multiple runs.
596
589
 
597
590
  Args:
598
591
  onnx_file (str): Path to the ONNX model file.
@@ -671,8 +664,7 @@ class ProfileModels:
671
664
  t_engine: tuple[float, float],
672
665
  model_info: tuple[float, float, float, float],
673
666
  ):
674
- """
675
- Generate a table row string with model performance metrics.
667
+ """Generate a table row string with model performance metrics.
676
668
 
677
669
  Args:
678
670
  model_name (str): Name of the model.
@@ -696,8 +688,7 @@ class ProfileModels:
696
688
  t_engine: tuple[float, float],
697
689
  model_info: tuple[float, float, float, float],
698
690
  ):
699
- """
700
- Generate a dictionary of profiling results.
691
+ """Generate a dictionary of profiling results.
701
692
 
702
693
  Args:
703
694
  model_name (str): Name of the model.
@@ -719,8 +710,7 @@ class ProfileModels:
719
710
 
720
711
  @staticmethod
721
712
  def print_table(table_rows: list[str]):
722
- """
723
- Print a formatted table of model profiling results.
713
+ """Print a formatted table of model profiling results.
724
714
 
725
715
  Args:
726
716
  table_rows (list[str]): List of formatted table row strings.
@@ -175,13 +175,12 @@ default_callbacks = {
175
175
 
176
176
 
177
177
  def get_default_callbacks():
178
- """
179
- Get the default callbacks for Ultralytics training, validation, prediction, and export processes.
178
+ """Get the default callbacks for Ultralytics training, validation, prediction, and export processes.
180
179
 
181
180
  Returns:
182
181
  (dict): Dictionary of default callbacks for various training events. Each key represents an event during the
183
- training process, and the corresponding value is a list of callback functions executed when that event
184
- occurs.
182
+ training process, and the corresponding value is a list of callback functions executed when that
183
+ event occurs.
185
184
 
186
185
  Examples:
187
186
  >>> callbacks = get_default_callbacks()
@@ -192,17 +191,16 @@ def get_default_callbacks():
192
191
 
193
192
 
194
193
  def add_integration_callbacks(instance):
195
- """
196
- Add integration callbacks to the instance's callbacks dictionary.
194
+ """Add integration callbacks to the instance's callbacks dictionary.
197
195
 
198
196
  This function loads and adds various integration callbacks to the provided instance. The specific callbacks added
199
197
  depend on the type of instance provided. All instances receive HUB callbacks, while Trainer instances also receive
200
- additional callbacks for various integrations like ClearML, Comet, DVC, MLflow, Neptune, Ray Tune, TensorBoard,
201
- and Weights & Biases.
198
+ additional callbacks for various integrations like ClearML, Comet, DVC, MLflow, Neptune, Ray Tune, TensorBoard, and
199
+ Weights & Biases.
202
200
 
203
201
  Args:
204
- instance (Trainer | Predictor | Validator | Exporter): The object instance to which callbacks will be added.
205
- The type of instance determines which callbacks are loaded.
202
+ instance (Trainer | Predictor | Validator | Exporter): The object instance to which callbacks will be added. The
203
+ type of instance determines which callbacks are loaded.
206
204
 
207
205
  Examples:
208
206
  >>> from ultralytics.engine.trainer import BaseTrainer
@@ -15,8 +15,7 @@ except (ImportError, AssertionError):
15
15
 
16
16
 
17
17
  def _log_debug_samples(files, title: str = "Debug Samples") -> None:
18
- """
19
- Log files (images) as debug samples in the ClearML task.
18
+ """Log files (images) as debug samples in the ClearML task.
20
19
 
21
20
  Args:
22
21
  files (list[Path]): A list of file paths in PosixPath format.
@@ -35,8 +34,7 @@ def _log_debug_samples(files, title: str = "Debug Samples") -> None:
35
34
 
36
35
 
37
36
  def _log_plot(title: str, plot_path: str) -> None:
38
- """
39
- Log an image as a plot in the plot section of ClearML.
37
+ """Log an image as a plot in the plot section of ClearML.
40
38
 
41
39
  Args:
42
40
  title (str): The title of the plot.
@@ -88,8 +88,7 @@ def _should_log_image_predictions() -> bool:
88
88
 
89
89
 
90
90
  def _resume_or_create_experiment(args: SimpleNamespace) -> None:
91
- """
92
- Resume CometML experiment or create a new experiment based on args.
91
+ """Resume CometML experiment or create a new experiment based on args.
93
92
 
94
93
  Ensures that the experiment object is only created in a single process during distributed training.
95
94
 
@@ -124,8 +123,7 @@ def _resume_or_create_experiment(args: SimpleNamespace) -> None:
124
123
 
125
124
 
126
125
  def _fetch_trainer_metadata(trainer) -> dict:
127
- """
128
- Return metadata for YOLO training including epoch and asset saving status.
126
+ """Return metadata for YOLO training including epoch and asset saving status.
129
127
 
130
128
  Args:
131
129
  trainer (ultralytics.engine.trainer.BaseTrainer): The YOLO trainer object containing training state and config.
@@ -150,11 +148,10 @@ def _fetch_trainer_metadata(trainer) -> dict:
150
148
  def _scale_bounding_box_to_original_image_shape(
151
149
  box, resized_image_shape, original_image_shape, ratio_pad
152
150
  ) -> list[float]:
153
- """
154
- Scale bounding box from resized image coordinates to original image coordinates.
151
+ """Scale bounding box from resized image coordinates to original image coordinates.
155
152
 
156
- YOLO resizes images during training and the label values are normalized based on this resized shape.
157
- This function rescales the bounding box labels to the original image shape.
153
+ YOLO resizes images during training and the label values are normalized based on this resized shape. This function
154
+ rescales the bounding box labels to the original image shape.
158
155
 
159
156
  Args:
160
157
  box (torch.Tensor): Bounding box in normalized xywh format.
@@ -181,8 +178,7 @@ def _scale_bounding_box_to_original_image_shape(
181
178
 
182
179
 
183
180
  def _format_ground_truth_annotations_for_detection(img_idx, image_path, batch, class_name_map=None) -> dict | None:
184
- """
185
- Format ground truth annotations for object detection.
181
+ """Format ground truth annotations for object detection.
186
182
 
187
183
  This function processes ground truth annotations from a batch of images for object detection tasks. It extracts
188
184
  bounding boxes, class labels, and other metadata for a specific image in the batch, and formats them for
@@ -205,7 +201,7 @@ def _format_ground_truth_annotations_for_detection(img_idx, image_path, batch, c
205
201
  - 'boxes': List of box coordinates [x, y, width, height]
206
202
  - 'label': Label string with format "gt_{class_name}"
207
203
  - 'score': Confidence score (always 1.0, scaled by _scale_confidence_score)
208
- Returns None if no bounding boxes are found for the image.
204
+ Returns None if no bounding boxes are found for the image.
209
205
  """
210
206
  indices = batch["batch_idx"] == img_idx
211
207
  bboxes = batch["bboxes"][indices]
@@ -236,8 +232,7 @@ def _format_ground_truth_annotations_for_detection(img_idx, image_path, batch, c
236
232
 
237
233
 
238
234
  def _format_prediction_annotations(image_path, metadata, class_label_map=None, class_map=None) -> dict | None:
239
- """
240
- Format YOLO predictions for object detection visualization.
235
+ """Format YOLO predictions for object detection visualization.
241
236
 
242
237
  Args:
243
238
  image_path (Path): Path to the image file.
@@ -289,8 +284,7 @@ def _format_prediction_annotations(image_path, metadata, class_label_map=None, c
289
284
 
290
285
 
291
286
  def _extract_segmentation_annotation(segmentation_raw: str, decode: Callable) -> list[list[Any]] | None:
292
- """
293
- Extract segmentation annotation from compressed segmentations as list of polygons.
287
+ """Extract segmentation annotation from compressed segmentations as list of polygons.
294
288
 
295
289
  Args:
296
290
  segmentation_raw (str): Raw segmentation data in compressed format.
@@ -310,8 +304,7 @@ def _extract_segmentation_annotation(segmentation_raw: str, decode: Callable) ->
310
304
 
311
305
 
312
306
  def _fetch_annotations(img_idx, image_path, batch, prediction_metadata_map, class_label_map, class_map) -> list | None:
313
- """
314
- Join the ground truth and prediction annotations if they exist.
307
+ """Join the ground truth and prediction annotations if they exist.
315
308
 
316
309
  Args:
317
310
  img_idx (int): Index of the image in the batch.
@@ -357,18 +350,17 @@ def _log_confusion_matrix(experiment, trainer, curr_step, curr_epoch) -> None:
357
350
 
358
351
 
359
352
  def _log_images(experiment, image_paths, curr_step: int | None, annotations=None) -> None:
360
- """
361
- Log images to the experiment with optional annotations.
353
+ """Log images to the experiment with optional annotations.
362
354
 
363
- This function logs images to a Comet ML experiment, optionally including annotation data for visualization
364
- such as bounding boxes or segmentation masks.
355
+ This function logs images to a Comet ML experiment, optionally including annotation data for visualization such as
356
+ bounding boxes or segmentation masks.
365
357
 
366
358
  Args:
367
359
  experiment (comet_ml.CometExperiment): The Comet ML experiment to log images to.
368
360
  image_paths (list[Path]): List of paths to images that will be logged.
369
361
  curr_step (int): Current training step/iteration for tracking in the experiment timeline.
370
- annotations (list[list[dict]], optional): Nested list of annotation dictionaries for each image. Each
371
- annotation contains visualization data like bounding boxes, labels, and confidence scores.
362
+ annotations (list[list[dict]], optional): Nested list of annotation dictionaries for each image. Each annotation
363
+ contains visualization data like bounding boxes, labels, and confidence scores.
372
364
  """
373
365
  if annotations:
374
366
  for image_path, annotation in zip(image_paths, annotations):
@@ -380,11 +372,10 @@ def _log_images(experiment, image_paths, curr_step: int | None, annotations=None
380
372
 
381
373
 
382
374
  def _log_image_predictions(experiment, validator, curr_step) -> None:
383
- """
384
- Log predicted boxes for a single image during training.
375
+ """Log predicted boxes for a single image during training.
385
376
 
386
- This function logs image predictions to a Comet ML experiment during model validation. It processes
387
- validation data and formats both ground truth and prediction annotations for visualization in the Comet
377
+ This function logs image predictions to a Comet ML experiment during model validation. It processes validation data
378
+ and formats both ground truth and prediction annotations for visualization in the Comet
388
379
  dashboard. The function respects configured limits on the number of images to log.
389
380
 
390
381
  Args:
@@ -443,12 +434,11 @@ def _log_image_predictions(experiment, validator, curr_step) -> None:
443
434
 
444
435
 
445
436
  def _log_plots(experiment, trainer) -> None:
446
- """
447
- Log evaluation plots and label plots for the experiment.
437
+ """Log evaluation plots and label plots for the experiment.
448
438
 
449
439
  This function logs various evaluation plots and confusion matrices to the experiment tracking system. It handles
450
- different types of metrics (SegmentMetrics, PoseMetrics, DetMetrics, OBBMetrics) and logs the appropriate plots
451
- for each type.
440
+ different types of metrics (SegmentMetrics, PoseMetrics, DetMetrics, OBBMetrics) and logs the appropriate plots for
441
+ each type.
452
442
 
453
443
  Args:
454
444
  experiment (comet_ml.CometExperiment): The Comet ML experiment to log plots to.
@@ -503,8 +493,7 @@ def _log_image_batches(experiment, trainer, curr_step: int) -> None:
503
493
 
504
494
 
505
495
  def _log_asset(experiment, asset_path) -> None:
506
- """
507
- Logs a specific asset file to the given experiment.
496
+ """Logs a specific asset file to the given experiment.
508
497
 
509
498
  This function facilitates logging an asset, such as a file, to the provided
510
499
  experiment. It enables integration with experiment tracking platforms.
@@ -517,11 +506,9 @@ def _log_asset(experiment, asset_path) -> None:
517
506
 
518
507
 
519
508
  def _log_table(experiment, table_path) -> None:
520
- """
521
- Logs a table to the provided experiment.
509
+ """Logs a table to the provided experiment.
522
510
 
523
- This function is used to log a table file to the given experiment. The table
524
- is identified by its file path.
511
+ This function is used to log a table file to the given experiment. The table is identified by its file path.
525
512
 
526
513
  Args:
527
514
  experiment (comet_ml.CometExperiment): The experiment object where the table file will be logged.
@@ -549,16 +536,15 @@ def on_train_epoch_end(trainer) -> None:
549
536
 
550
537
 
551
538
  def on_fit_epoch_end(trainer) -> None:
552
- """
553
- Log model assets at the end of each epoch during training.
539
+ """Log model assets at the end of each epoch during training.
554
540
 
555
- This function is called at the end of each training epoch to log metrics, learning rates, and model information
556
- to a Comet ML experiment. It also logs model assets, confusion matrices, and image predictions based on
557
- configuration settings.
541
+ This function is called at the end of each training epoch to log metrics, learning rates, and model information to a
542
+ Comet ML experiment. It also logs model assets, confusion matrices, and image predictions based on configuration
543
+ settings.
558
544
 
559
545
  The function retrieves the current Comet ML experiment and logs various training metrics. If it's the first epoch,
560
- it also logs model information. On specified save intervals, it logs the model, confusion matrix (if enabled),
561
- and image predictions (if enabled).
546
+ it also logs model information. On specified save intervals, it logs the model, confusion matrix (if enabled), and
547
+ image predictions (if enabled).
562
548
 
563
549
  Args:
564
550
  trainer (BaseTrainer): The YOLO trainer object containing training state, metrics, and configuration.
@@ -27,8 +27,7 @@ except (ImportError, AssertionError, TypeError):
27
27
 
28
28
 
29
29
  def _log_images(path: Path, prefix: str = "") -> None:
30
- """
31
- Log images at specified path with an optional prefix using DVCLive.
30
+ """Log images at specified path with an optional prefix using DVCLive.
32
31
 
33
32
  This function logs images found at the given path to DVCLive, organizing them by batch to enable slider
34
33
  functionality in the UI. It processes image filenames to extract batch information and restructures the path
@@ -55,8 +54,7 @@ def _log_images(path: Path, prefix: str = "") -> None:
55
54
 
56
55
 
57
56
  def _log_plots(plots: dict, prefix: str = "") -> None:
58
- """
59
- Log plot images for training progress if they have not been previously processed.
57
+ """Log plot images for training progress if they have not been previously processed.
60
58
 
61
59
  Args:
62
60
  plots (dict): Dictionary containing plot information with timestamps.
@@ -70,15 +68,14 @@ def _log_plots(plots: dict, prefix: str = "") -> None:
70
68
 
71
69
 
72
70
  def _log_confusion_matrix(validator) -> None:
73
- """
74
- Log confusion matrix for a validator using DVCLive.
71
+ """Log confusion matrix for a validator using DVCLive.
75
72
 
76
- This function processes the confusion matrix from a validator object and logs it to DVCLive by converting
77
- the matrix into lists of target and prediction labels.
73
+ This function processes the confusion matrix from a validator object and logs it to DVCLive by converting the matrix
74
+ into lists of target and prediction labels.
78
75
 
79
76
  Args:
80
77
  validator (BaseValidator): The validator object containing the confusion matrix and class names. Must have
81
- attributes: confusion_matrix.matrix, confusion_matrix.task, and names.
78
+ attributes confusion_matrix.matrix, confusion_matrix.task, and names.
82
79
  """
83
80
  targets = []
84
81
  preds = []
@@ -123,11 +120,10 @@ def on_train_epoch_start(trainer) -> None:
123
120
 
124
121
 
125
122
  def on_fit_epoch_end(trainer) -> None:
126
- """
127
- Log training metrics, model info, and advance to next step at the end of each fit epoch.
123
+ """Log training metrics, model info, and advance to next step at the end of each fit epoch.
128
124
 
129
- This function is called at the end of each fit epoch during training. It logs various metrics including
130
- training loss items, validation metrics, and learning rates. On the first epoch, it also logs model
125
+ This function is called at the end of each fit epoch during training. It logs various metrics including training
126
+ loss items, validation metrics, and learning rates. On the first epoch, it also logs model
131
127
  information. Additionally, it logs training and validation plots and advances the DVCLive step counter.
132
128
 
133
129
  Args:
@@ -157,12 +153,11 @@ def on_fit_epoch_end(trainer) -> None:
157
153
 
158
154
 
159
155
  def on_train_end(trainer) -> None:
160
- """
161
- Log best metrics, plots, and confusion matrix at the end of training.
156
+ """Log best metrics, plots, and confusion matrix at the end of training.
162
157
 
163
- This function is called at the conclusion of the training process to log final metrics, visualizations, and
164
- model artifacts if DVCLive logging is active. It captures the best model performance metrics, training plots,
165
- validation plots, and confusion matrix for later analysis.
158
+ This function is called at the conclusion of the training process to log final metrics, visualizations, and model
159
+ artifacts if DVCLive logging is active. It captures the best model performance metrics, training plots, validation
160
+ plots, and confusion matrix for later analysis.
166
161
 
167
162
  Args:
168
163
  trainer (BaseTrainer): The trainer object containing training state, metrics, and validation results.
@@ -45,17 +45,16 @@ def sanitize_dict(x: dict) -> dict:
45
45
 
46
46
 
47
47
  def on_pretrain_routine_end(trainer):
48
- """
49
- Log training parameters to MLflow at the end of the pretraining routine.
48
+ """Log training parameters to MLflow at the end of the pretraining routine.
50
49
 
51
50
  This function sets up MLflow logging based on environment variables and trainer arguments. It sets the tracking URI,
52
- experiment name, and run name, then starts the MLflow run if not already active. It finally logs the parameters
53
- from the trainer.
51
+ experiment name, and run name, then starts the MLflow run if not already active. It finally logs the parameters from
52
+ the trainer.
54
53
 
55
54
  Args:
56
55
  trainer (ultralytics.engine.trainer.BaseTrainer): The training object with arguments and parameters to log.
57
56
 
58
- Environment Variables:
57
+ Notes:
59
58
  MLFLOW_TRACKING_URI: The URI for MLflow tracking. If not set, defaults to 'runs/mlflow'.
60
59
  MLFLOW_EXPERIMENT_NAME: The name of the MLflow experiment. If not set, defaults to trainer.args.project.
61
60
  MLFLOW_RUN: The name of the MLflow run. If not set, defaults to trainer.args.name.
@@ -18,8 +18,7 @@ except (ImportError, AssertionError):
18
18
 
19
19
 
20
20
  def _log_scalars(scalars: dict, step: int = 0) -> None:
21
- """
22
- Log scalars to the NeptuneAI experiment logger.
21
+ """Log scalars to the NeptuneAI experiment logger.
23
22
 
24
23
  Args:
25
24
  scalars (dict): Dictionary of scalar values to log to NeptuneAI.
@@ -35,11 +34,10 @@ def _log_scalars(scalars: dict, step: int = 0) -> None:
35
34
 
36
35
 
37
36
  def _log_images(imgs_dict: dict, group: str = "") -> None:
38
- """
39
- Log images to the NeptuneAI experiment logger.
37
+ """Log images to the NeptuneAI experiment logger.
40
38
 
41
- This function logs image data to Neptune.ai when a valid Neptune run is active. Images are organized
42
- under the specified group name.
39
+ This function logs image data to Neptune.ai when a valid Neptune run is active. Images are organized under the
40
+ specified group name.
43
41
 
44
42
  Args:
45
43
  imgs_dict (dict): Dictionary of images to log, with keys as image names and values as image data.
@@ -13,11 +13,10 @@ except (ImportError, AssertionError):
13
13
 
14
14
 
15
15
  def on_fit_epoch_end(trainer):
16
- """
17
- Report training metrics to Ray Tune at epoch end when a Ray session is active.
16
+ """Report training metrics to Ray Tune at epoch end when a Ray session is active.
18
17
 
19
- Captures metrics from the trainer object and sends them to Ray Tune with the current epoch number,
20
- enabling hyperparameter tuning optimization. Only executes when within an active Ray Tune session.
18
+ Captures metrics from the trainer object and sends them to Ray Tune with the current epoch number, enabling
19
+ hyperparameter tuning optimization. Only executes when within an active Ray Tune session.
21
20
 
22
21
  Args:
23
22
  trainer (ultralytics.engine.trainer.BaseTrainer): The Ultralytics trainer object containing metrics and epochs.
@@ -22,8 +22,7 @@ except (ImportError, AssertionError, TypeError, AttributeError):
22
22
 
23
23
 
24
24
  def _log_scalars(scalars: dict, step: int = 0) -> None:
25
- """
26
- Log scalar values to TensorBoard.
25
+ """Log scalar values to TensorBoard.
27
26
 
28
27
  Args:
29
28
  scalars (dict): Dictionary of scalar values to log to TensorBoard. Keys are scalar names and values are the
@@ -41,16 +40,15 @@ def _log_scalars(scalars: dict, step: int = 0) -> None:
41
40
 
42
41
 
43
42
  def _log_tensorboard_graph(trainer) -> None:
44
- """
45
- Log model graph to TensorBoard.
43
+ """Log model graph to TensorBoard.
46
44
 
47
45
  This function attempts to visualize the model architecture in TensorBoard by tracing the model with a dummy input
48
46
  tensor. It first tries a simple method suitable for YOLO models, and if that fails, falls back to a more complex
49
47
  approach for models like RTDETR that may require special handling.
50
48
 
51
49
  Args:
52
- trainer (ultralytics.engine.trainer.BaseTrainer): The trainer object containing the model to visualize.
53
- Must have attributes model and args with imgsz.
50
+ trainer (ultralytics.engine.trainer.BaseTrainer): The trainer object containing the model to visualize. Must
51
+ have attributes model and args with imgsz.
54
52
 
55
53
  Notes:
56
54
  This function requires TensorBoard integration to be enabled and the global WRITER to be initialized.