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.
Files changed (243) hide show
  1. {dgenerate_ultralytics_headless-8.3.196.dist-info → dgenerate_ultralytics_headless-8.3.248.dist-info}/METADATA +33 -34
  2. dgenerate_ultralytics_headless-8.3.248.dist-info/RECORD +298 -0
  3. tests/__init__.py +5 -7
  4. tests/conftest.py +8 -15
  5. tests/test_cli.py +8 -10
  6. tests/test_cuda.py +9 -10
  7. tests/test_engine.py +29 -2
  8. tests/test_exports.py +69 -21
  9. tests/test_integrations.py +8 -11
  10. tests/test_python.py +109 -71
  11. tests/test_solutions.py +170 -159
  12. ultralytics/__init__.py +27 -9
  13. ultralytics/cfg/__init__.py +57 -64
  14. ultralytics/cfg/datasets/Argoverse.yaml +7 -6
  15. ultralytics/cfg/datasets/DOTAv1.5.yaml +1 -1
  16. ultralytics/cfg/datasets/DOTAv1.yaml +1 -1
  17. ultralytics/cfg/datasets/ImageNet.yaml +1 -1
  18. ultralytics/cfg/datasets/Objects365.yaml +19 -15
  19. ultralytics/cfg/datasets/SKU-110K.yaml +1 -1
  20. ultralytics/cfg/datasets/VOC.yaml +19 -21
  21. ultralytics/cfg/datasets/VisDrone.yaml +5 -5
  22. ultralytics/cfg/datasets/african-wildlife.yaml +1 -1
  23. ultralytics/cfg/datasets/coco-pose.yaml +24 -2
  24. ultralytics/cfg/datasets/coco.yaml +2 -2
  25. ultralytics/cfg/datasets/coco128-seg.yaml +1 -1
  26. ultralytics/cfg/datasets/coco8-pose.yaml +21 -0
  27. ultralytics/cfg/datasets/construction-ppe.yaml +32 -0
  28. ultralytics/cfg/datasets/dog-pose.yaml +28 -0
  29. ultralytics/cfg/datasets/dota8-multispectral.yaml +1 -1
  30. ultralytics/cfg/datasets/dota8.yaml +2 -2
  31. ultralytics/cfg/datasets/hand-keypoints.yaml +26 -2
  32. ultralytics/cfg/datasets/kitti.yaml +27 -0
  33. ultralytics/cfg/datasets/lvis.yaml +7 -7
  34. ultralytics/cfg/datasets/open-images-v7.yaml +1 -1
  35. ultralytics/cfg/datasets/tiger-pose.yaml +16 -0
  36. ultralytics/cfg/datasets/xView.yaml +16 -16
  37. ultralytics/cfg/default.yaml +96 -94
  38. ultralytics/cfg/models/11/yolo11-pose.yaml +1 -1
  39. ultralytics/cfg/models/11/yoloe-11-seg.yaml +2 -2
  40. ultralytics/cfg/models/11/yoloe-11.yaml +2 -2
  41. ultralytics/cfg/models/rt-detr/rtdetr-l.yaml +1 -1
  42. ultralytics/cfg/models/rt-detr/rtdetr-resnet101.yaml +1 -1
  43. ultralytics/cfg/models/rt-detr/rtdetr-resnet50.yaml +1 -1
  44. ultralytics/cfg/models/rt-detr/rtdetr-x.yaml +1 -1
  45. ultralytics/cfg/models/v10/yolov10b.yaml +2 -2
  46. ultralytics/cfg/models/v10/yolov10l.yaml +2 -2
  47. ultralytics/cfg/models/v10/yolov10m.yaml +2 -2
  48. ultralytics/cfg/models/v10/yolov10n.yaml +2 -2
  49. ultralytics/cfg/models/v10/yolov10s.yaml +2 -2
  50. ultralytics/cfg/models/v10/yolov10x.yaml +2 -2
  51. ultralytics/cfg/models/v3/yolov3-tiny.yaml +1 -1
  52. ultralytics/cfg/models/v6/yolov6.yaml +1 -1
  53. ultralytics/cfg/models/v8/yoloe-v8-seg.yaml +9 -6
  54. ultralytics/cfg/models/v8/yoloe-v8.yaml +9 -6
  55. ultralytics/cfg/models/v8/yolov8-cls-resnet101.yaml +1 -1
  56. ultralytics/cfg/models/v8/yolov8-cls-resnet50.yaml +1 -1
  57. ultralytics/cfg/models/v8/yolov8-ghost-p2.yaml +2 -2
  58. ultralytics/cfg/models/v8/yolov8-ghost-p6.yaml +2 -2
  59. ultralytics/cfg/models/v8/yolov8-ghost.yaml +2 -2
  60. ultralytics/cfg/models/v8/yolov8-obb.yaml +1 -1
  61. ultralytics/cfg/models/v8/yolov8-p2.yaml +1 -1
  62. ultralytics/cfg/models/v8/yolov8-pose-p6.yaml +1 -1
  63. ultralytics/cfg/models/v8/yolov8-rtdetr.yaml +1 -1
  64. ultralytics/cfg/models/v8/yolov8-seg-p6.yaml +1 -1
  65. ultralytics/cfg/models/v8/yolov8-world.yaml +1 -1
  66. ultralytics/cfg/models/v8/yolov8-worldv2.yaml +6 -6
  67. ultralytics/cfg/models/v9/yolov9s.yaml +1 -1
  68. ultralytics/cfg/trackers/botsort.yaml +16 -17
  69. ultralytics/cfg/trackers/bytetrack.yaml +9 -11
  70. ultralytics/data/__init__.py +4 -4
  71. ultralytics/data/annotator.py +3 -4
  72. ultralytics/data/augment.py +286 -476
  73. ultralytics/data/base.py +18 -26
  74. ultralytics/data/build.py +151 -26
  75. ultralytics/data/converter.py +38 -50
  76. ultralytics/data/dataset.py +47 -75
  77. ultralytics/data/loaders.py +42 -49
  78. ultralytics/data/split.py +5 -6
  79. ultralytics/data/split_dota.py +8 -15
  80. ultralytics/data/utils.py +41 -45
  81. ultralytics/engine/exporter.py +462 -462
  82. ultralytics/engine/model.py +150 -191
  83. ultralytics/engine/predictor.py +30 -40
  84. ultralytics/engine/results.py +177 -311
  85. ultralytics/engine/trainer.py +193 -120
  86. ultralytics/engine/tuner.py +77 -63
  87. ultralytics/engine/validator.py +39 -22
  88. ultralytics/hub/__init__.py +16 -19
  89. ultralytics/hub/auth.py +6 -12
  90. ultralytics/hub/google/__init__.py +7 -10
  91. ultralytics/hub/session.py +15 -25
  92. ultralytics/hub/utils.py +5 -8
  93. ultralytics/models/__init__.py +1 -1
  94. ultralytics/models/fastsam/__init__.py +1 -1
  95. ultralytics/models/fastsam/model.py +8 -10
  96. ultralytics/models/fastsam/predict.py +19 -30
  97. ultralytics/models/fastsam/utils.py +1 -2
  98. ultralytics/models/fastsam/val.py +5 -7
  99. ultralytics/models/nas/__init__.py +1 -1
  100. ultralytics/models/nas/model.py +5 -8
  101. ultralytics/models/nas/predict.py +7 -9
  102. ultralytics/models/nas/val.py +1 -2
  103. ultralytics/models/rtdetr/__init__.py +1 -1
  104. ultralytics/models/rtdetr/model.py +7 -8
  105. ultralytics/models/rtdetr/predict.py +15 -19
  106. ultralytics/models/rtdetr/train.py +10 -13
  107. ultralytics/models/rtdetr/val.py +21 -23
  108. ultralytics/models/sam/__init__.py +15 -2
  109. ultralytics/models/sam/amg.py +14 -20
  110. ultralytics/models/sam/build.py +26 -19
  111. ultralytics/models/sam/build_sam3.py +377 -0
  112. ultralytics/models/sam/model.py +29 -32
  113. ultralytics/models/sam/modules/blocks.py +83 -144
  114. ultralytics/models/sam/modules/decoders.py +22 -40
  115. ultralytics/models/sam/modules/encoders.py +44 -101
  116. ultralytics/models/sam/modules/memory_attention.py +16 -30
  117. ultralytics/models/sam/modules/sam.py +206 -79
  118. ultralytics/models/sam/modules/tiny_encoder.py +64 -83
  119. ultralytics/models/sam/modules/transformer.py +18 -28
  120. ultralytics/models/sam/modules/utils.py +174 -50
  121. ultralytics/models/sam/predict.py +2268 -366
  122. ultralytics/models/sam/sam3/__init__.py +3 -0
  123. ultralytics/models/sam/sam3/decoder.py +546 -0
  124. ultralytics/models/sam/sam3/encoder.py +529 -0
  125. ultralytics/models/sam/sam3/geometry_encoders.py +415 -0
  126. ultralytics/models/sam/sam3/maskformer_segmentation.py +286 -0
  127. ultralytics/models/sam/sam3/model_misc.py +199 -0
  128. ultralytics/models/sam/sam3/necks.py +129 -0
  129. ultralytics/models/sam/sam3/sam3_image.py +339 -0
  130. ultralytics/models/sam/sam3/text_encoder_ve.py +307 -0
  131. ultralytics/models/sam/sam3/vitdet.py +547 -0
  132. ultralytics/models/sam/sam3/vl_combiner.py +160 -0
  133. ultralytics/models/utils/loss.py +14 -26
  134. ultralytics/models/utils/ops.py +13 -17
  135. ultralytics/models/yolo/__init__.py +1 -1
  136. ultralytics/models/yolo/classify/predict.py +9 -12
  137. ultralytics/models/yolo/classify/train.py +15 -41
  138. ultralytics/models/yolo/classify/val.py +34 -32
  139. ultralytics/models/yolo/detect/predict.py +8 -11
  140. ultralytics/models/yolo/detect/train.py +13 -32
  141. ultralytics/models/yolo/detect/val.py +75 -63
  142. ultralytics/models/yolo/model.py +37 -53
  143. ultralytics/models/yolo/obb/predict.py +5 -14
  144. ultralytics/models/yolo/obb/train.py +11 -14
  145. ultralytics/models/yolo/obb/val.py +42 -39
  146. ultralytics/models/yolo/pose/__init__.py +1 -1
  147. ultralytics/models/yolo/pose/predict.py +7 -22
  148. ultralytics/models/yolo/pose/train.py +10 -22
  149. ultralytics/models/yolo/pose/val.py +40 -59
  150. ultralytics/models/yolo/segment/predict.py +16 -20
  151. ultralytics/models/yolo/segment/train.py +3 -12
  152. ultralytics/models/yolo/segment/val.py +106 -56
  153. ultralytics/models/yolo/world/train.py +12 -16
  154. ultralytics/models/yolo/world/train_world.py +11 -34
  155. ultralytics/models/yolo/yoloe/__init__.py +7 -7
  156. ultralytics/models/yolo/yoloe/predict.py +16 -23
  157. ultralytics/models/yolo/yoloe/train.py +31 -56
  158. ultralytics/models/yolo/yoloe/train_seg.py +5 -10
  159. ultralytics/models/yolo/yoloe/val.py +16 -21
  160. ultralytics/nn/__init__.py +7 -7
  161. ultralytics/nn/autobackend.py +152 -80
  162. ultralytics/nn/modules/__init__.py +60 -60
  163. ultralytics/nn/modules/activation.py +4 -6
  164. ultralytics/nn/modules/block.py +133 -217
  165. ultralytics/nn/modules/conv.py +52 -97
  166. ultralytics/nn/modules/head.py +64 -116
  167. ultralytics/nn/modules/transformer.py +79 -89
  168. ultralytics/nn/modules/utils.py +16 -21
  169. ultralytics/nn/tasks.py +111 -156
  170. ultralytics/nn/text_model.py +40 -67
  171. ultralytics/solutions/__init__.py +12 -12
  172. ultralytics/solutions/ai_gym.py +11 -17
  173. ultralytics/solutions/analytics.py +15 -16
  174. ultralytics/solutions/config.py +5 -6
  175. ultralytics/solutions/distance_calculation.py +10 -13
  176. ultralytics/solutions/heatmap.py +7 -13
  177. ultralytics/solutions/instance_segmentation.py +5 -8
  178. ultralytics/solutions/object_blurrer.py +7 -10
  179. ultralytics/solutions/object_counter.py +12 -19
  180. ultralytics/solutions/object_cropper.py +8 -14
  181. ultralytics/solutions/parking_management.py +33 -31
  182. ultralytics/solutions/queue_management.py +10 -12
  183. ultralytics/solutions/region_counter.py +9 -12
  184. ultralytics/solutions/security_alarm.py +15 -20
  185. ultralytics/solutions/similarity_search.py +13 -17
  186. ultralytics/solutions/solutions.py +75 -74
  187. ultralytics/solutions/speed_estimation.py +7 -10
  188. ultralytics/solutions/streamlit_inference.py +4 -7
  189. ultralytics/solutions/templates/similarity-search.html +7 -18
  190. ultralytics/solutions/trackzone.py +7 -10
  191. ultralytics/solutions/vision_eye.py +5 -8
  192. ultralytics/trackers/__init__.py +1 -1
  193. ultralytics/trackers/basetrack.py +3 -5
  194. ultralytics/trackers/bot_sort.py +10 -27
  195. ultralytics/trackers/byte_tracker.py +14 -30
  196. ultralytics/trackers/track.py +3 -6
  197. ultralytics/trackers/utils/gmc.py +11 -22
  198. ultralytics/trackers/utils/kalman_filter.py +37 -48
  199. ultralytics/trackers/utils/matching.py +12 -15
  200. ultralytics/utils/__init__.py +116 -116
  201. ultralytics/utils/autobatch.py +2 -4
  202. ultralytics/utils/autodevice.py +17 -18
  203. ultralytics/utils/benchmarks.py +70 -70
  204. ultralytics/utils/callbacks/base.py +8 -10
  205. ultralytics/utils/callbacks/clearml.py +5 -13
  206. ultralytics/utils/callbacks/comet.py +32 -46
  207. ultralytics/utils/callbacks/dvc.py +13 -18
  208. ultralytics/utils/callbacks/mlflow.py +4 -5
  209. ultralytics/utils/callbacks/neptune.py +7 -15
  210. ultralytics/utils/callbacks/platform.py +314 -38
  211. ultralytics/utils/callbacks/raytune.py +3 -4
  212. ultralytics/utils/callbacks/tensorboard.py +23 -31
  213. ultralytics/utils/callbacks/wb.py +10 -13
  214. ultralytics/utils/checks.py +151 -87
  215. ultralytics/utils/cpu.py +3 -8
  216. ultralytics/utils/dist.py +19 -15
  217. ultralytics/utils/downloads.py +29 -41
  218. ultralytics/utils/errors.py +6 -14
  219. ultralytics/utils/events.py +2 -4
  220. ultralytics/utils/export/__init__.py +7 -0
  221. ultralytics/utils/{export.py → export/engine.py} +16 -16
  222. ultralytics/utils/export/imx.py +325 -0
  223. ultralytics/utils/export/tensorflow.py +231 -0
  224. ultralytics/utils/files.py +24 -28
  225. ultralytics/utils/git.py +9 -11
  226. ultralytics/utils/instance.py +30 -51
  227. ultralytics/utils/logger.py +212 -114
  228. ultralytics/utils/loss.py +15 -24
  229. ultralytics/utils/metrics.py +131 -160
  230. ultralytics/utils/nms.py +21 -30
  231. ultralytics/utils/ops.py +107 -165
  232. ultralytics/utils/patches.py +33 -21
  233. ultralytics/utils/plotting.py +122 -119
  234. ultralytics/utils/tal.py +28 -44
  235. ultralytics/utils/torch_utils.py +70 -187
  236. ultralytics/utils/tqdm.py +20 -20
  237. ultralytics/utils/triton.py +13 -19
  238. ultralytics/utils/tuner.py +17 -5
  239. dgenerate_ultralytics_headless-8.3.196.dist-info/RECORD +0 -281
  240. {dgenerate_ultralytics_headless-8.3.196.dist-info → dgenerate_ultralytics_headless-8.3.248.dist-info}/WHEEL +0 -0
  241. {dgenerate_ultralytics_headless-8.3.196.dist-info → dgenerate_ultralytics_headless-8.3.248.dist-info}/entry_points.txt +0 -0
  242. {dgenerate_ultralytics_headless-8.3.196.dist-info → dgenerate_ultralytics_headless-8.3.248.dist-info}/licenses/LICENSE +0 -0
  243. {dgenerate_ultralytics_headless-8.3.196.dist-info → dgenerate_ultralytics_headless-8.3.248.dist-info}/top_level.txt +0 -0
@@ -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.
@@ -261,7 +256,7 @@ def _format_prediction_annotations(image_path, metadata, class_label_map=None, c
261
256
  class_label_map = {class_map[k]: v for k, v in class_label_map.items()}
262
257
  try:
263
258
  # import pycotools utilities to decompress annotations for various tasks, e.g. segmentation
264
- from faster_coco_eval.core.mask import decode # noqa
259
+ from faster_coco_eval.core.mask import decode
265
260
  except ImportError:
266
261
  decode = None
267
262
 
@@ -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.
@@ -350,25 +343,24 @@ def _create_prediction_metadata_map(model_predictions) -> dict:
350
343
  def _log_confusion_matrix(experiment, trainer, curr_step, curr_epoch) -> None:
351
344
  """Log the confusion matrix to Comet experiment."""
352
345
  conf_mat = trainer.validator.confusion_matrix.matrix
353
- names = list(trainer.data["names"].values()) + ["background"]
346
+ names = [*list(trainer.data["names"].values()), "background"]
354
347
  experiment.log_confusion_matrix(
355
348
  matrix=conf_mat, labels=names, max_categories=len(names), epoch=curr_epoch, step=curr_step
356
349
  )
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.
@@ -108,15 +106,9 @@ def on_train_end(trainer) -> None:
108
106
  """Log final results, plots, and model weights at the end of training."""
109
107
  if run:
110
108
  # Log final results, CM matrix + PR plots
111
- files = [
112
- "results.png",
113
- "confusion_matrix.png",
114
- "confusion_matrix_normalized.png",
115
- *(f"{x}_curve.png" for x in ("F1", "PR", "P", "R")),
116
- ]
117
- files = [(trainer.save_dir / f) for f in files if (trainer.save_dir / f).exists()] # filter
118
- for f in files:
119
- _log_plot(title=f.stem, plot_path=f)
109
+ for f in [*trainer.plots.keys(), *trainer.validator.plots.keys()]:
110
+ if "batch" not in f.name:
111
+ _log_plot(title=f.stem, plot_path=f)
120
112
  # Log the final model
121
113
  run[f"weights/{trainer.args.name or trainer.args.task}/{trainer.best.name}"].upload(File(str(trainer.best)))
122
114