ultralytics 8.3.93__py3-none-any.whl → 8.3.95__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 (70) hide show
  1. tests/conftest.py +1 -1
  2. tests/test_exports.py +2 -2
  3. ultralytics/__init__.py +1 -1
  4. ultralytics/cfg/__init__.py +10 -10
  5. ultralytics/data/augment.py +37 -37
  6. ultralytics/data/base.py +6 -6
  7. ultralytics/data/converter.py +1 -1
  8. ultralytics/data/dataset.py +3 -3
  9. ultralytics/data/split_dota.py +2 -2
  10. ultralytics/engine/exporter.py +5 -5
  11. ultralytics/engine/model.py +6 -6
  12. ultralytics/engine/predictor.py +2 -2
  13. ultralytics/engine/results.py +3 -3
  14. ultralytics/engine/trainer.py +5 -5
  15. ultralytics/engine/tuner.py +6 -6
  16. ultralytics/engine/validator.py +8 -8
  17. ultralytics/hub/session.py +8 -8
  18. ultralytics/hub/utils.py +1 -1
  19. ultralytics/models/fastsam/model.py +5 -5
  20. ultralytics/models/fastsam/predict.py +1 -1
  21. ultralytics/models/fastsam/val.py +2 -2
  22. ultralytics/models/nas/predict.py +1 -1
  23. ultralytics/models/rtdetr/model.py +1 -1
  24. ultralytics/models/rtdetr/predict.py +1 -1
  25. ultralytics/models/rtdetr/train.py +5 -5
  26. ultralytics/models/rtdetr/val.py +4 -4
  27. ultralytics/models/sam/model.py +2 -2
  28. ultralytics/models/sam/modules/blocks.py +1 -1
  29. ultralytics/models/sam/predict.py +12 -12
  30. ultralytics/models/utils/loss.py +9 -9
  31. ultralytics/models/utils/ops.py +2 -2
  32. ultralytics/models/yolo/classify/predict.py +1 -1
  33. ultralytics/models/yolo/classify/train.py +1 -1
  34. ultralytics/models/yolo/classify/val.py +1 -1
  35. ultralytics/models/yolo/detect/predict.py +1 -1
  36. ultralytics/models/yolo/detect/train.py +4 -4
  37. ultralytics/models/yolo/detect/val.py +17 -17
  38. ultralytics/models/yolo/obb/val.py +1 -1
  39. ultralytics/models/yolo/pose/train.py +2 -2
  40. ultralytics/models/yolo/pose/val.py +2 -2
  41. ultralytics/models/yolo/segment/predict.py +2 -2
  42. ultralytics/models/yolo/segment/val.py +17 -15
  43. ultralytics/models/yolo/world/train.py +5 -5
  44. ultralytics/models/yolo/world/train_world.py +4 -4
  45. ultralytics/nn/autobackend.py +2 -2
  46. ultralytics/nn/modules/block.py +1 -1
  47. ultralytics/nn/modules/transformer.py +3 -3
  48. ultralytics/nn/tasks.py +5 -5
  49. ultralytics/solutions/analytics.py +1 -1
  50. ultralytics/solutions/object_counter.py +1 -1
  51. ultralytics/solutions/queue_management.py +1 -1
  52. ultralytics/solutions/region_counter.py +6 -6
  53. ultralytics/solutions/solutions.py +2 -2
  54. ultralytics/solutions/streamlit_inference.py +1 -1
  55. ultralytics/trackers/basetrack.py +1 -1
  56. ultralytics/trackers/utils/gmc.py +1 -1
  57. ultralytics/utils/__init__.py +18 -2
  58. ultralytics/utils/benchmarks.py +2 -2
  59. ultralytics/utils/callbacks/raytune.py +13 -1
  60. ultralytics/utils/callbacks/wb.py +4 -4
  61. ultralytics/utils/checks.py +1 -0
  62. ultralytics/utils/ops.py +4 -4
  63. ultralytics/utils/plotting.py +1 -1
  64. ultralytics/utils/torch_utils.py +1 -1
  65. {ultralytics-8.3.93.dist-info → ultralytics-8.3.95.dist-info}/METADATA +7 -6
  66. {ultralytics-8.3.93.dist-info → ultralytics-8.3.95.dist-info}/RECORD +70 -70
  67. {ultralytics-8.3.93.dist-info → ultralytics-8.3.95.dist-info}/WHEEL +1 -1
  68. {ultralytics-8.3.93.dist-info → ultralytics-8.3.95.dist-info}/entry_points.txt +0 -0
  69. {ultralytics-8.3.93.dist-info → ultralytics-8.3.95.dist-info/licenses}/LICENSE +0 -0
  70. {ultralytics-8.3.93.dist-info → ultralytics-8.3.95.dist-info}/top_level.txt +0 -0
tests/conftest.py CHANGED
@@ -25,7 +25,7 @@ def pytest_collection_modifyitems(config, items):
25
25
 
26
26
  Args:
27
27
  config (pytest.config.Config): The pytest configuration object that provides access to command-line options.
28
- items (List): The list of collected pytest item objects to be modified based on the presence of --slow option.
28
+ items (list): The list of collected pytest item objects to be modified based on the presence of --slow option.
29
29
 
30
30
  Returns:
31
31
  (None): The function modifies the 'items' list in place.
tests/test_exports.py CHANGED
@@ -114,7 +114,7 @@ def test_export_torchscript_matrix(task, dynamic, int8, half, batch, nms):
114
114
  @pytest.mark.slow
115
115
  @pytest.mark.skipif(not MACOS, reason="CoreML inference only supported on macOS")
116
116
  @pytest.mark.skipif(not TORCH_1_9, reason="CoreML>=7.2 not supported with PyTorch<=1.8")
117
- @pytest.mark.skipif(checks.IS_PYTHON_3_12, reason="CoreML not supported in Python 3.12")
117
+ @pytest.mark.skipif(checks.IS_PYTHON_3_13, reason="CoreML not supported in Python 3.13")
118
118
  @pytest.mark.parametrize(
119
119
  "task, dynamic, int8, half, batch",
120
120
  [ # generate all combinations except for exclusion cases
@@ -165,7 +165,7 @@ def test_export_tflite_matrix(task, dynamic, int8, half, batch, nms):
165
165
  @pytest.mark.skipif(not TORCH_1_9, reason="CoreML>=7.2 not supported with PyTorch<=1.8")
166
166
  @pytest.mark.skipif(WINDOWS, reason="CoreML not supported on Windows") # RuntimeError: BlobWriter not loaded
167
167
  @pytest.mark.skipif(LINUX and ARM64, reason="CoreML not supported on aarch64 Linux")
168
- @pytest.mark.skipif(checks.IS_PYTHON_3_12, reason="CoreML not supported in Python 3.12")
168
+ @pytest.mark.skipif(checks.IS_PYTHON_3_13, reason="CoreML not supported in Python 3.13")
169
169
  def test_export_coreml():
170
170
  """Test YOLO exports to CoreML format, optimized for macOS only."""
171
171
  if MACOS:
ultralytics/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
2
 
3
- __version__ = "8.3.93"
3
+ __version__ = "8.3.95"
4
4
 
5
5
  import os
6
6
 
@@ -87,13 +87,13 @@ SOLUTIONS_HELP_MSG = f"""
87
87
  at https://docs.ultralytics.com/usage/cfg
88
88
 
89
89
  1. Call object counting solution
90
- yolo solutions count source="path/to/video/file.mp4" region=[(20, 400), (1080, 400), (1080, 360), (20, 360)]
90
+ yolo solutions count source="path/to/video.mp4" region="[(20, 400), (1080, 400), (1080, 360), (20, 360)]"
91
91
 
92
92
  2. Call heatmaps solution
93
93
  yolo solutions heatmap colormap=cv2.COLORMAP_PARULA model=yolo11n.pt
94
94
 
95
95
  3. Call queue management solution
96
- yolo solutions queue region=[(20, 400), (1080, 400), (1080, 360), (20, 360)] model=yolo11n.pt
96
+ yolo solutions queue region="[(20, 400), (1080, 400), (1080, 360), (20, 360)]" model=yolo11n.pt
97
97
 
98
98
  4. Call workouts monitoring solution for push-ups
99
99
  yolo solutions workout model=yolo11n-pose.pt kpts=[6, 8, 10]
@@ -102,7 +102,7 @@ SOLUTIONS_HELP_MSG = f"""
102
102
  yolo solutions analytics analytics_type="pie"
103
103
 
104
104
  6. Track objects within specific zones
105
- yolo solutions trackzone source="path/to/video/file.mp4" region=[(150, 150), (1130, 150), (1130, 570), (150, 570)]
105
+ yolo solutions trackzone source="path/to/video.mp4" region="[(150, 150), (1130, 150), (1130, 570), (150, 570)]"
106
106
 
107
107
  7. Streamlit real-time webcam inference GUI
108
108
  yolo streamlit-predict
@@ -130,7 +130,7 @@ CLI_HELP_MSG = f"""
130
130
  yolo export model=yolo11n-cls.pt format=onnx imgsz=224,128
131
131
 
132
132
  5. Ultralytics solutions usage
133
- yolo solutions count or in {list(SOLUTION_MAP.keys())[1:-1]} source="path/to/video/file.mp4"
133
+ yolo solutions count or in {list(SOLUTION_MAP.keys())[1:-1]} source="path/to/video.mp4"
134
134
 
135
135
  6. Run special commands:
136
136
  yolo help
@@ -251,7 +251,7 @@ def cfg2dict(cfg: Union[str, Path, Dict, SimpleNamespace]) -> Dict:
251
251
  a string, a dictionary, or a SimpleNamespace object.
252
252
 
253
253
  Returns:
254
- (Dict): Configuration object in dictionary format.
254
+ (dict): Configuration object in dictionary format.
255
255
 
256
256
  Examples:
257
257
  Convert a YAML file path to a dictionary:
@@ -334,7 +334,7 @@ def check_cfg(cfg: Dict, hard: bool = True) -> None:
334
334
  `CFG_FRACTION_KEYS`, `CFG_INT_KEYS`, and `CFG_BOOL_KEYS`.
335
335
 
336
336
  Args:
337
- cfg (Dict): Configuration dictionary to validate.
337
+ cfg (dict): Configuration dictionary to validate.
338
338
  hard (bool): If True, raises exceptions for invalid types and values; if False, attempts to convert them.
339
339
 
340
340
  Examples:
@@ -424,7 +424,7 @@ def _handle_deprecation(custom: Dict) -> Dict:
424
424
  Handles deprecated configuration keys by mapping them to current equivalents with deprecation warnings.
425
425
 
426
426
  Args:
427
- custom (Dict): Configuration dictionary potentially containing deprecated keys.
427
+ custom (dict): Configuration dictionary potentially containing deprecated keys.
428
428
 
429
429
  Examples:
430
430
  >>> custom_config = {"boxes": True, "hide_labels": "False", "line_thickness": 2}
@@ -463,8 +463,8 @@ def check_dict_alignment(base: Dict, custom: Dict, e: Exception = None) -> None:
463
463
  messages for mismatched keys.
464
464
 
465
465
  Args:
466
- base (Dict): The base configuration dictionary containing valid keys.
467
- custom (Dict): The custom configuration dictionary to be checked for alignment.
466
+ base (dict): The base configuration dictionary containing valid keys.
467
+ custom (dict): The custom configuration dictionary to be checked for alignment.
468
468
  e (Exception | None): Optional error instance passed by the calling function.
469
469
 
470
470
  Raises:
@@ -643,7 +643,7 @@ def handle_yolo_solutions(args: List[str]) -> None:
643
643
  >>> handle_yolo_solutions(["count"])
644
644
 
645
645
  Run analytics with custom configuration:
646
- >>> handle_yolo_solutions(["analytics", "conf=0.25", "source=path/to/video/file.mp4"])
646
+ >>> handle_yolo_solutions(["analytics", "conf=0.25", "source=path/to/video.mp4"])
647
647
 
648
648
  Run inference with custom configuration, requires Streamlit version 1.29.0 or higher.
649
649
  >>> handle_yolo_solutions(["inference", "model=yolo11n.pt"])
@@ -86,10 +86,10 @@ class BaseTransform:
86
86
  logic.
87
87
 
88
88
  Args:
89
- labels (Dict): A dictionary containing label information, including object instances.
89
+ labels (dict): A dictionary containing label information, including object instances.
90
90
 
91
91
  Returns:
92
- (Dict): The modified labels dictionary with transformed object instances.
92
+ (dict): The modified labels dictionary with transformed object instances.
93
93
 
94
94
  Examples:
95
95
  >>> transform = BaseTransform()
@@ -127,11 +127,11 @@ class BaseTransform:
127
127
  image and object instances, respectively.
128
128
 
129
129
  Args:
130
- labels (Dict): A dictionary containing image data and annotations. Expected keys include 'img' for
130
+ labels (dict): A dictionary containing image data and annotations. Expected keys include 'img' for
131
131
  the image data, and 'instances' for object instances.
132
132
 
133
133
  Returns:
134
- (Dict): The input labels dictionary with transformed image and instances.
134
+ (dict): The input labels dictionary with transformed image and instances.
135
135
 
136
136
  Examples:
137
137
  >>> transform = BaseTransform()
@@ -285,7 +285,7 @@ class Compose:
285
285
  Converts the list of transforms to a standard Python list.
286
286
 
287
287
  Returns:
288
- (List): A list containing all the transform objects in the Compose instance.
288
+ (list): A list containing all the transform objects in the Compose instance.
289
289
 
290
290
  Examples:
291
291
  >>> transforms = [RandomFlip(), RandomPerspective(10), CenterCrop()]
@@ -374,10 +374,10 @@ class BaseMixTransform:
374
374
  selects additional images, applies pre-transforms if specified, and then performs the mix transform.
375
375
 
376
376
  Args:
377
- labels (Dict): A dictionary containing label data for an image.
377
+ labels (dict): A dictionary containing label data for an image.
378
378
 
379
379
  Returns:
380
- (Dict): The transformed labels dictionary, which may include mixed data from other images.
380
+ (dict): The transformed labels dictionary, which may include mixed data from other images.
381
381
 
382
382
  Examples:
383
383
  >>> transform = BaseMixTransform(dataset, pre_transform=None, p=0.5)
@@ -414,11 +414,11 @@ class BaseMixTransform:
414
414
  Mosaic. It modifies the input label dictionary in-place with the augmented data.
415
415
 
416
416
  Args:
417
- labels (Dict): A dictionary containing image and label data. Expected to have a 'mix_labels' key
417
+ labels (dict): A dictionary containing image and label data. Expected to have a 'mix_labels' key
418
418
  with a list of additional image and label data for mixing.
419
419
 
420
420
  Returns:
421
- (Dict): The modified labels dictionary with augmented data after applying the mix transform.
421
+ (dict): The modified labels dictionary with augmented data after applying the mix transform.
422
422
 
423
423
  Examples:
424
424
  >>> transform = BaseMixTransform(dataset)
@@ -450,11 +450,11 @@ class BaseMixTransform:
450
450
  creating a unified set of text labels and updating class IDs accordingly.
451
451
 
452
452
  Args:
453
- labels (Dict): A dictionary containing label information, including 'texts' and 'cls' fields,
453
+ labels (dict): A dictionary containing label information, including 'texts' and 'cls' fields,
454
454
  and optionally a 'mix_labels' field with additional label dictionaries.
455
455
 
456
456
  Returns:
457
- (Dict): The updated labels dictionary with unified text labels and updated class IDs.
457
+ (dict): The updated labels dictionary with unified text labels and updated class IDs.
458
458
 
459
459
  Examples:
460
460
  >>> labels = {
@@ -576,12 +576,12 @@ class Mosaic(BaseMixTransform):
576
576
  mosaic augmentation.
577
577
 
578
578
  Args:
579
- labels (Dict): A dictionary containing image data and annotations. Expected keys include:
579
+ labels (dict): A dictionary containing image data and annotations. Expected keys include:
580
580
  - 'rect_shape': Should be None as rect and mosaic are mutually exclusive.
581
581
  - 'mix_labels': A list of dictionaries containing data for other images to be used in the mosaic.
582
582
 
583
583
  Returns:
584
- (Dict): A dictionary containing the mosaic-augmented image and updated annotations.
584
+ (dict): A dictionary containing the mosaic-augmented image and updated annotations.
585
585
 
586
586
  Raises:
587
587
  AssertionError: If 'rect_shape' is not None or if 'mix_labels' is empty.
@@ -604,12 +604,12 @@ class Mosaic(BaseMixTransform):
604
604
  additional images on either side. It's part of the Mosaic augmentation technique used in object detection.
605
605
 
606
606
  Args:
607
- labels (Dict): A dictionary containing image and label information for the main (center) image.
607
+ labels (dict): A dictionary containing image and label information for the main (center) image.
608
608
  Must include 'img' key with the image array, and 'mix_labels' key with a list of two
609
609
  dictionaries containing information for the side images.
610
610
 
611
611
  Returns:
612
- (Dict): A dictionary with the mosaic image and updated labels. Keys include:
612
+ (dict): A dictionary with the mosaic image and updated labels. Keys include:
613
613
  - 'img' (np.ndarray): The mosaic image array with shape (H, W, C).
614
614
  - Other keys from the input labels, updated to reflect the new image dimensions.
615
615
 
@@ -663,11 +663,11 @@ class Mosaic(BaseMixTransform):
663
663
  updates the corresponding labels for each image in the mosaic.
664
664
 
665
665
  Args:
666
- labels (Dict): A dictionary containing image data and labels for the base image (index 0) and three
666
+ labels (dict): A dictionary containing image data and labels for the base image (index 0) and three
667
667
  additional images (indices 1-3) in the 'mix_labels' key.
668
668
 
669
669
  Returns:
670
- (Dict): A dictionary containing the mosaic image and updated labels. The 'img' key contains the mosaic
670
+ (dict): A dictionary containing the mosaic image and updated labels. The 'img' key contains the mosaic
671
671
  image as a numpy array, and other keys contain the combined and adjusted labels for all four images.
672
672
 
673
673
  Examples:
@@ -721,7 +721,7 @@ class Mosaic(BaseMixTransform):
721
721
  and eight additional images from the dataset are placed around it in a 3x3 grid pattern.
722
722
 
723
723
  Args:
724
- labels (Dict): A dictionary containing the input image and its associated labels. It should have
724
+ labels (dict): A dictionary containing the input image and its associated labels. It should have
725
725
  the following keys:
726
726
  - 'img' (numpy.ndarray): The input image.
727
727
  - 'resized_shape' (Tuple[int, int]): The shape of the resized image (height, width).
@@ -729,7 +729,7 @@ class Mosaic(BaseMixTransform):
729
729
  eight images, each with the same structure as the input labels.
730
730
 
731
731
  Returns:
732
- (Dict): A dictionary containing the mosaic image and updated labels. It includes the following keys:
732
+ (dict): A dictionary containing the mosaic image and updated labels. It includes the following keys:
733
733
  - 'img' (numpy.ndarray): The final mosaic image.
734
734
  - Other keys from the input labels, updated to reflect the new mosaic arrangement.
735
735
 
@@ -794,12 +794,12 @@ class Mosaic(BaseMixTransform):
794
794
  values. It also denormalizes the coordinates if they were previously normalized.
795
795
 
796
796
  Args:
797
- labels (Dict): A dictionary containing image and instance information.
797
+ labels (dict): A dictionary containing image and instance information.
798
798
  padw (int): Padding width to be added to the x-coordinates.
799
799
  padh (int): Padding height to be added to the y-coordinates.
800
800
 
801
801
  Returns:
802
- (Dict): Updated labels dictionary with adjusted instance coordinates.
802
+ (dict): Updated labels dictionary with adjusted instance coordinates.
803
803
 
804
804
  Examples:
805
805
  >>> labels = {"img": np.zeros((100, 100, 3)), "instances": Instances(...)}
@@ -823,7 +823,7 @@ class Mosaic(BaseMixTransform):
823
823
  mosaic_labels (List[Dict]): A list of label dictionaries for each image in the mosaic.
824
824
 
825
825
  Returns:
826
- (Dict): A dictionary containing concatenated and processed labels for the mosaic image, including:
826
+ (dict): A dictionary containing concatenated and processed labels for the mosaic image, including:
827
827
  - im_file (str): File path of the first image in the mosaic.
828
828
  - ori_shape (Tuple[int, int]): Original shape of the first image.
829
829
  - resized_shape (Tuple[int, int]): Shape of the mosaic image (imgsz * 2, imgsz * 2).
@@ -932,10 +932,10 @@ class MixUp(BaseMixTransform):
932
932
  "mixup: Beyond Empirical Risk Minimization" (https://arxiv.org/abs/1710.09412).
933
933
 
934
934
  Args:
935
- labels (Dict): A dictionary containing the original image and label information.
935
+ labels (dict): A dictionary containing the original image and label information.
936
936
 
937
937
  Returns:
938
- (Dict): A dictionary containing the mixed-up image and combined label information.
938
+ (dict): A dictionary containing the mixed-up image and combined label information.
939
939
 
940
940
  Examples:
941
941
  >>> mixer = MixUp(dataset)
@@ -1191,7 +1191,7 @@ class RandomPerspective:
1191
1191
  and keypoints accordingly.
1192
1192
 
1193
1193
  Args:
1194
- labels (Dict): A dictionary containing image data and annotations.
1194
+ labels (dict): A dictionary containing image data and annotations.
1195
1195
  Must include:
1196
1196
  'img' (np.ndarray): The input image.
1197
1197
  'cls' (np.ndarray): Class labels.
@@ -1200,7 +1200,7 @@ class RandomPerspective:
1200
1200
  'mosaic_border' (Tuple[int, int]): Border size for mosaic augmentation.
1201
1201
 
1202
1202
  Returns:
1203
- (Dict): Transformed labels dictionary containing:
1203
+ (dict): Transformed labels dictionary containing:
1204
1204
  - 'img' (np.ndarray): The transformed image.
1205
1205
  - 'cls' (np.ndarray): Updated class labels.
1206
1206
  - 'instances' (Instances): Updated object instances.
@@ -1351,7 +1351,7 @@ class RandomHSV:
1351
1351
  The adjustments are made within the limits set by hgain, sgain, and vgain during initialization.
1352
1352
 
1353
1353
  Args:
1354
- labels (Dict): A dictionary containing image data and metadata. Must include an 'img' key with
1354
+ labels (dict): A dictionary containing image data and metadata. Must include an 'img' key with
1355
1355
  the image as a numpy array.
1356
1356
 
1357
1357
  Returns:
@@ -1439,13 +1439,13 @@ class RandomFlip:
1439
1439
  match the flipped image.
1440
1440
 
1441
1441
  Args:
1442
- labels (Dict): A dictionary containing the following keys:
1442
+ labels (dict): A dictionary containing the following keys:
1443
1443
  'img' (numpy.ndarray): The image to be flipped.
1444
1444
  'instances' (ultralytics.utils.instance.Instances): An object containing bounding boxes and
1445
1445
  optionally keypoints.
1446
1446
 
1447
1447
  Returns:
1448
- (Dict): The same dictionary with the flipped image and updated instances:
1448
+ (dict): The same dictionary with the flipped image and updated instances:
1449
1449
  'img' (numpy.ndarray): The flipped image.
1450
1450
  'instances' (ultralytics.utils.instance.Instances): Updated instances matching the flipped image.
1451
1451
 
@@ -1611,13 +1611,13 @@ class LetterBox:
1611
1611
  to account for resizing and padding applied during letterboxing.
1612
1612
 
1613
1613
  Args:
1614
- labels (Dict): A dictionary containing image labels and instances.
1614
+ labels (dict): A dictionary containing image labels and instances.
1615
1615
  ratio (Tuple[float, float]): Scaling ratios (width, height) applied to the image.
1616
1616
  padw (float): Padding width added to the image.
1617
1617
  padh (float): Padding height added to the image.
1618
1618
 
1619
1619
  Returns:
1620
- (Dict): Updated labels dictionary with modified instance coordinates.
1620
+ (dict): Updated labels dictionary with modified instance coordinates.
1621
1621
 
1622
1622
  Examples:
1623
1623
  >>> letterbox = LetterBox(new_shape=(640, 640))
@@ -1879,13 +1879,13 @@ class Albumentations:
1879
1879
  spatial and non-spatial transformations on the input image and its corresponding labels.
1880
1880
 
1881
1881
  Args:
1882
- labels (Dict): A dictionary containing image data and annotations. Expected keys are:
1882
+ labels (dict): A dictionary containing image data and annotations. Expected keys are:
1883
1883
  - 'img': numpy.ndarray representing the image
1884
1884
  - 'cls': numpy.ndarray of class labels
1885
1885
  - 'instances': object containing bounding boxes and other instance information
1886
1886
 
1887
1887
  Returns:
1888
- (Dict): The input dictionary with augmented image and updated annotations.
1888
+ (dict): The input dictionary with augmented image and updated annotations.
1889
1889
 
1890
1890
  Examples:
1891
1891
  >>> transform = Albumentations(p=0.5)
@@ -2019,13 +2019,13 @@ class Format:
2019
2019
  applying normalization if required.
2020
2020
 
2021
2021
  Args:
2022
- labels (Dict): A dictionary containing image and annotation data with the following keys:
2022
+ labels (dict): A dictionary containing image and annotation data with the following keys:
2023
2023
  - 'img': The input image as a numpy array.
2024
2024
  - 'cls': Class labels for instances.
2025
2025
  - 'instances': An Instances object containing bounding boxes, segments, and keypoints.
2026
2026
 
2027
2027
  Returns:
2028
- (Dict): A dictionary with formatted data, including:
2028
+ (dict): A dictionary with formatted data, including:
2029
2029
  - 'img': Formatted image tensor.
2030
2030
  - 'cls': Class label's tensor.
2031
2031
  - 'bboxes': Bounding boxes tensor in the specified format.
@@ -2222,10 +2222,10 @@ class RandomLoadText:
2222
2222
  new sampled text order.
2223
2223
 
2224
2224
  Args:
2225
- labels (Dict): A dictionary containing image labels and metadata. Must include 'texts' and 'cls' keys.
2225
+ labels (dict): A dictionary containing image labels and metadata. Must include 'texts' and 'cls' keys.
2226
2226
 
2227
2227
  Returns:
2228
- (Dict): Updated labels dictionary with new 'cls' and 'texts' entries.
2228
+ (dict): Updated labels dictionary with new 'cls' and 'texts' entries.
2229
2229
 
2230
2230
  Examples:
2231
2231
  >>> loader = RandomLoadText(prompt_format="A photo of {}", neg_samples=(5, 10), max_samples=20)
ultralytics/data/base.py CHANGED
@@ -39,11 +39,11 @@ class BaseDataset(Dataset):
39
39
  batch_size (int): Size of batches.
40
40
  stride (int): Stride used in the model.
41
41
  pad (float): Padding value.
42
- buffer (List): Buffer for mosaic images.
42
+ buffer (list): Buffer for mosaic images.
43
43
  max_buffer_length (int): Maximum buffer size.
44
- ims (List): List of loaded images.
45
- im_hw0 (List): List of original image dimensions (h, w).
46
- im_hw (List): List of resized image dimensions (h, w).
44
+ ims (list): List of loaded images.
45
+ im_hw0 (list): List of original image dimensions (h, w).
46
+ im_hw (list): List of resized image dimensions (h, w).
47
47
  npy_files (List[Path]): List of numpy file paths.
48
48
  cache (str): Cache images to RAM or disk during training.
49
49
  transforms (callable): Image transformation function.
@@ -94,7 +94,7 @@ class BaseDataset(Dataset):
94
94
  stride (int, optional): Stride used in the model.
95
95
  pad (float, optional): Padding value.
96
96
  single_cls (bool, optional): If True, single class training is used.
97
- classes (List, optional): List of included classes.
97
+ classes (list, optional): List of included classes.
98
98
  fraction (float, optional): Fraction of dataset to utilize.
99
99
  """
100
100
  super().__init__()
@@ -179,7 +179,7 @@ class BaseDataset(Dataset):
179
179
  Update labels to include only specified classes.
180
180
 
181
181
  Args:
182
- include_class (List, optional): List of classes to include. If None, all classes are included.
182
+ include_class (list, optional): List of classes to include. If None, all classes are included.
183
183
  """
184
184
  include_class_array = np.array(include_class).reshape(1, -1)
185
185
  for i in range(len(self.labels)):
@@ -21,7 +21,7 @@ def coco91_to_coco80_class():
21
21
  Converts 91-index COCO class IDs to 80-index COCO class IDs.
22
22
 
23
23
  Returns:
24
- (List): A list of 91 class IDs where the index represents the 80-index class ID and the value is the
24
+ (list): A list of 91 class IDs where the index represents the 80-index class ID and the value is the
25
25
  corresponding 91-index class ID.
26
26
  """
27
27
  return [
@@ -408,7 +408,7 @@ class GroundingDataset(YOLODataset):
408
408
  img_path (str): Path to the directory containing images.
409
409
 
410
410
  Returns:
411
- (List): Empty list as image files are read in get_labels.
411
+ (list): Empty list as image files are read in get_labels.
412
412
  """
413
413
  return []
414
414
 
@@ -537,7 +537,7 @@ class ClassificationDataset:
537
537
  Attributes:
538
538
  cache_ram (bool): Indicates if caching in RAM is enabled.
539
539
  cache_disk (bool): Indicates if caching on disk is enabled.
540
- samples (List): A list of tuples, each containing the path to an image, its class index, path to its .npy cache
540
+ samples (list): A list of tuples, each containing the path to an image, its class index, path to its .npy cache
541
541
  file (if caching on disk), and optionally the loaded image array (if caching in RAM).
542
542
  torch_transforms (callable): PyTorch transforms to be applied to the images.
543
543
  root (str): Root directory of the dataset.
@@ -635,7 +635,7 @@ class ClassificationDataset:
635
635
  Verify all images in dataset.
636
636
 
637
637
  Returns:
638
- (List): List of valid samples after verification.
638
+ (list): List of valid samples after verification.
639
639
  """
640
640
  desc = f"{self.prefix}Scanning {self.root}..."
641
641
  path = Path(self.root).with_suffix(".cache") # *.cache file path
@@ -163,9 +163,9 @@ def crop_and_save(anno, windows, window_objs, im_dir, lb_dir, allow_background_i
163
163
  Crop images and save new labels.
164
164
 
165
165
  Args:
166
- anno (Dict): Annotation dict, including `filepath`, `label`, `ori_size` as its keys.
166
+ anno (dict): Annotation dict, including `filepath`, `label`, `ori_size` as its keys.
167
167
  windows (np.ndarray): Array of windows coordinates with shape (n, 4).
168
- window_objs (List): A list of labels inside each window.
168
+ window_objs (list): A list of labels inside each window.
169
169
  im_dir (str): The output directory path of images.
170
170
  lb_dir (str): The output directory path of labels.
171
171
  allow_background_images (bool): Whether to include background images without labels.
@@ -138,7 +138,7 @@ def validate_args(format, passed_args, valid_args):
138
138
  Args:
139
139
  format (str): The export format.
140
140
  passed_args (Namespace): The arguments used during export.
141
- valid_args (List): List of valid arguments for the format.
141
+ valid_args (list): List of valid arguments for the format.
142
142
 
143
143
  Raises:
144
144
  AssertionError: If an unsupported argument is used, or if the format lacks supported argument listings.
@@ -210,7 +210,7 @@ class Exporter:
210
210
 
211
211
  Attributes:
212
212
  args (SimpleNamespace): Configuration for the exporter.
213
- callbacks (List, optional): List of callback functions.
213
+ callbacks (list, optional): List of callback functions.
214
214
  """
215
215
 
216
216
  def __init__(self, cfg=DEFAULT_CFG, overrides=None, _callbacks=None):
@@ -219,8 +219,8 @@ class Exporter:
219
219
 
220
220
  Args:
221
221
  cfg (str, optional): Path to a configuration file.
222
- overrides (Dict, optional): Configuration overrides.
223
- _callbacks (Dict, optional): Dictionary of callback functions.
222
+ overrides (dict, optional): Configuration overrides.
223
+ _callbacks (dict, optional): Dictionary of callback functions.
224
224
  """
225
225
  self.args = get_cfg(cfg, overrides)
226
226
  if self.args.format.lower() in {"coreml", "mlmodel"}: # fix attempt for protobuf<3.20.x errors
@@ -773,7 +773,7 @@ class Exporter:
773
773
  def export_coreml(self, prefix=colorstr("CoreML:")):
774
774
  """YOLO CoreML export."""
775
775
  mlmodel = self.args.format.lower() == "mlmodel" # legacy *.mlmodel export format requested
776
- check_requirements("coremltools>=6.0,<=6.2" if mlmodel else "coremltools>=7.0")
776
+ check_requirements("coremltools>=6.0,<=6.2" if mlmodel else "coremltools>=8.0")
777
777
  import coremltools as ct # noqa
778
778
 
779
779
  LOGGER.info(f"\n{prefix} starting export with coremltools {ct.__version__}...")
@@ -35,15 +35,15 @@ class Model(torch.nn.Module):
35
35
  loaded from local files, Ultralytics HUB, or Triton Server.
36
36
 
37
37
  Attributes:
38
- callbacks (Dict): A dictionary of callback functions for various events during model operations.
38
+ callbacks (dict): A dictionary of callback functions for various events during model operations.
39
39
  predictor (BasePredictor): The predictor object used for making predictions.
40
40
  model (torch.nn.Module): The underlying PyTorch model.
41
41
  trainer (BaseTrainer): The trainer object used for training the model.
42
- ckpt (Dict): The checkpoint data if the model is loaded from a *.pt file.
42
+ ckpt (dict): The checkpoint data if the model is loaded from a *.pt file.
43
43
  cfg (str): The configuration of the model if loaded from a *.yaml file.
44
44
  ckpt_path (str): The path to the checkpoint file.
45
- overrides (Dict): A dictionary of overrides for model configuration.
46
- metrics (Dict): The latest training/validation metrics.
45
+ overrides (dict): A dictionary of overrides for model configuration.
46
+ metrics (dict): The latest training/validation metrics.
47
47
  session (HUBTrainingSession): The Ultralytics HUB session, if applicable.
48
48
  task (str): The type of task the model is intended for.
49
49
  model_name (str): The name of the model.
@@ -652,7 +652,7 @@ class Model(torch.nn.Module):
652
652
  - format (str): Export format name for specific benchmarking.
653
653
 
654
654
  Returns:
655
- (Dict): A dictionary containing the results of the benchmarking process, including metrics for
655
+ (dict): A dictionary containing the results of the benchmarking process, including metrics for
656
656
  different export formats.
657
657
 
658
658
  Raises:
@@ -820,7 +820,7 @@ class Model(torch.nn.Module):
820
820
  overrides and defaults to configure the tuning process.
821
821
 
822
822
  Returns:
823
- (Dict): Results of the hyperparameter search, including best parameters and performance metrics.
823
+ (dict): Results of the hyperparameter search, including best parameters and performance metrics.
824
824
 
825
825
  Raises:
826
826
  TypeError: If the model is not a PyTorch model.
@@ -82,9 +82,9 @@ class BasePredictor:
82
82
  plotted_img (numpy.ndarray): Last plotted image.
83
83
  source_type (SimpleNamespace): Type of input source.
84
84
  seen (int): Number of images processed.
85
- windows (List): List of window names for visualization.
85
+ windows (list): List of window names for visualization.
86
86
  batch (tuple): Current batch data.
87
- results (List): Current batch results.
87
+ results (list): Current batch results.
88
88
  transforms (callable): Image transforms for classification.
89
89
  callbacks (dict): Callback functions for different events.
90
90
  txt_path (Path): Path to save text results.
@@ -199,8 +199,8 @@ class Results(SimpleClass):
199
199
  probs (Probs | None): Classification probabilities.
200
200
  keypoints (Keypoints | None): Detected keypoints.
201
201
  obb (OBB | None): Oriented bounding boxes.
202
- speed (Dict): Dictionary containing inference speed information.
203
- names (Dict): Dictionary mapping class indices to class names.
202
+ speed (dict): Dictionary containing inference speed information.
203
+ names (dict): Dictionary mapping class indices to class names.
204
204
  path (str): Path to the input image file.
205
205
  save_dir (str | None): Directory to save results.
206
206
 
@@ -243,7 +243,7 @@ class Results(SimpleClass):
243
243
  Args:
244
244
  orig_img (numpy.ndarray): The original image as a numpy array.
245
245
  path (str): The path to the image file.
246
- names (Dict): A dictionary of class names.
246
+ names (dict): A dictionary of class names.
247
247
  boxes (torch.Tensor | None): A 2D tensor of bounding box coordinates for each detection.
248
248
  masks (torch.Tensor | None): A 3D tensor of detection masks, where each mask is a binary image.
249
249
  probs (torch.Tensor | None): A 1D tensor of probabilities of each class for classification task.
@@ -87,10 +87,10 @@ class BaseTrainer:
87
87
  fitness (float): Current fitness value.
88
88
  loss (float): Current loss value.
89
89
  tloss (float): Total loss value.
90
- loss_names (List): List of loss names.
90
+ loss_names (list): List of loss names.
91
91
  csv (Path): Path to results CSV file.
92
- metrics (Dict): Dictionary of metrics.
93
- plots (Dict): Dictionary of plots.
92
+ metrics (dict): Dictionary of metrics.
93
+ plots (dict): Dictionary of plots.
94
94
  """
95
95
 
96
96
  def __init__(self, cfg=DEFAULT_CFG, overrides=None, _callbacks=None):
@@ -99,8 +99,8 @@ class BaseTrainer:
99
99
 
100
100
  Args:
101
101
  cfg (str, optional): Path to a configuration file. Defaults to DEFAULT_CFG.
102
- overrides (Dict, optional): Configuration overrides. Defaults to None.
103
- _callbacks (List, optional): List of callback functions. Defaults to None.
102
+ overrides (dict, optional): Configuration overrides. Defaults to None.
103
+ _callbacks (list, optional): List of callback functions. Defaults to None.
104
104
  """
105
105
  self.args = get_cfg(cfg, overrides)
106
106
  self.check_resume(overrides)
@@ -35,11 +35,11 @@ class Tuner:
35
35
  search space and retraining the model to evaluate their performance.
36
36
 
37
37
  Attributes:
38
- space (Dict): Hyperparameter search space containing bounds and scaling factors for mutation.
38
+ space (dict): Hyperparameter search space containing bounds and scaling factors for mutation.
39
39
  tune_dir (Path): Directory where evolution logs and results will be saved.
40
40
  tune_csv (Path): Path to the CSV file where evolution logs are saved.
41
- args (Dict): Configuration arguments for the tuning process.
42
- callbacks (List): Callback functions to be executed during tuning.
41
+ args (dict): Configuration arguments for the tuning process.
42
+ callbacks (list): Callback functions to be executed during tuning.
43
43
  prefix (str): Prefix string for logging messages.
44
44
 
45
45
  Methods:
@@ -63,8 +63,8 @@ class Tuner:
63
63
  Initialize the Tuner with configurations.
64
64
 
65
65
  Args:
66
- args (Dict): Configuration for hyperparameter evolution.
67
- _callbacks (List, optional): Callback functions to be executed during tuning.
66
+ args (dict): Configuration for hyperparameter evolution.
67
+ _callbacks (list, optional): Callback functions to be executed during tuning.
68
68
  """
69
69
  self.space = args.pop("space", None) or { # key: (min, max, gain(optional))
70
70
  # 'optimizer': tune.choice(['SGD', 'Adam', 'AdamW', 'NAdam', 'RAdam', 'RMSProp']),
@@ -115,7 +115,7 @@ class Tuner:
115
115
  sigma (float): Standard deviation for Gaussian random number generator.
116
116
 
117
117
  Returns:
118
- (Dict): A dictionary containing mutated hyperparameters.
118
+ (dict): A dictionary containing mutated hyperparameters.
119
119
  """
120
120
  if self.tune_csv.exists(): # if CSV file exists: select best hyps and mutate
121
121
  # Select parent(s)