ultralytics 8.3.93__py3-none-any.whl → 8.3.94__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.
- tests/conftest.py +1 -1
- ultralytics/__init__.py +1 -1
- ultralytics/cfg/__init__.py +5 -5
- ultralytics/data/augment.py +37 -37
- ultralytics/data/base.py +6 -6
- ultralytics/data/converter.py +1 -1
- ultralytics/data/dataset.py +3 -3
- ultralytics/data/split_dota.py +2 -2
- ultralytics/engine/exporter.py +4 -4
- ultralytics/engine/model.py +6 -6
- ultralytics/engine/predictor.py +2 -2
- ultralytics/engine/results.py +3 -3
- ultralytics/engine/trainer.py +5 -5
- ultralytics/engine/tuner.py +6 -6
- ultralytics/engine/validator.py +8 -8
- ultralytics/hub/session.py +8 -8
- ultralytics/hub/utils.py +1 -1
- ultralytics/models/fastsam/model.py +5 -5
- ultralytics/models/fastsam/predict.py +1 -1
- ultralytics/models/fastsam/val.py +2 -2
- ultralytics/models/nas/predict.py +1 -1
- ultralytics/models/rtdetr/model.py +1 -1
- ultralytics/models/rtdetr/predict.py +1 -1
- ultralytics/models/rtdetr/train.py +5 -5
- ultralytics/models/rtdetr/val.py +4 -4
- ultralytics/models/sam/model.py +2 -2
- ultralytics/models/sam/modules/blocks.py +1 -1
- ultralytics/models/sam/predict.py +12 -12
- ultralytics/models/utils/loss.py +9 -9
- ultralytics/models/utils/ops.py +2 -2
- ultralytics/models/yolo/classify/predict.py +1 -1
- ultralytics/models/yolo/classify/train.py +1 -1
- ultralytics/models/yolo/classify/val.py +1 -1
- ultralytics/models/yolo/detect/predict.py +1 -1
- ultralytics/models/yolo/detect/train.py +4 -4
- ultralytics/models/yolo/detect/val.py +17 -17
- ultralytics/models/yolo/obb/val.py +1 -1
- ultralytics/models/yolo/pose/train.py +2 -2
- ultralytics/models/yolo/pose/val.py +2 -2
- ultralytics/models/yolo/segment/predict.py +2 -2
- ultralytics/models/yolo/segment/val.py +17 -15
- ultralytics/models/yolo/world/train.py +5 -5
- ultralytics/models/yolo/world/train_world.py +4 -4
- ultralytics/nn/autobackend.py +2 -2
- ultralytics/nn/modules/block.py +1 -1
- ultralytics/nn/modules/transformer.py +3 -3
- ultralytics/nn/tasks.py +5 -5
- ultralytics/solutions/analytics.py +1 -1
- ultralytics/solutions/object_counter.py +1 -1
- ultralytics/solutions/region_counter.py +6 -6
- ultralytics/solutions/solutions.py +2 -2
- ultralytics/solutions/streamlit_inference.py +1 -1
- ultralytics/trackers/basetrack.py +1 -1
- ultralytics/trackers/utils/gmc.py +1 -1
- ultralytics/utils/__init__.py +18 -2
- ultralytics/utils/callbacks/raytune.py +13 -1
- ultralytics/utils/callbacks/wb.py +4 -4
- ultralytics/utils/ops.py +4 -4
- ultralytics/utils/plotting.py +1 -1
- ultralytics/utils/torch_utils.py +1 -1
- {ultralytics-8.3.93.dist-info → ultralytics-8.3.94.dist-info}/METADATA +3 -2
- {ultralytics-8.3.93.dist-info → ultralytics-8.3.94.dist-info}/RECORD +66 -66
- {ultralytics-8.3.93.dist-info → ultralytics-8.3.94.dist-info}/WHEEL +1 -1
- {ultralytics-8.3.93.dist-info → ultralytics-8.3.94.dist-info}/entry_points.txt +0 -0
- {ultralytics-8.3.93.dist-info → ultralytics-8.3.94.dist-info/licenses}/LICENSE +0 -0
- {ultralytics-8.3.93.dist-info → ultralytics-8.3.94.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 (
|
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.
|
ultralytics/__init__.py
CHANGED
ultralytics/cfg/__init__.py
CHANGED
@@ -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
|
-
(
|
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 (
|
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 (
|
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 (
|
467
|
-
custom (
|
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:
|
ultralytics/data/augment.py
CHANGED
@@ -86,10 +86,10 @@ class BaseTransform:
|
|
86
86
|
logic.
|
87
87
|
|
88
88
|
Args:
|
89
|
-
labels (
|
89
|
+
labels (dict): A dictionary containing label information, including object instances.
|
90
90
|
|
91
91
|
Returns:
|
92
|
-
(
|
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 (
|
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
|
-
(
|
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
|
-
(
|
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 (
|
377
|
+
labels (dict): A dictionary containing label data for an image.
|
378
378
|
|
379
379
|
Returns:
|
380
|
-
(
|
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 (
|
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
|
-
(
|
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 (
|
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
|
-
(
|
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 (
|
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
|
-
(
|
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 (
|
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
|
-
(
|
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 (
|
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
|
-
(
|
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 (
|
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
|
-
(
|
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 (
|
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
|
-
(
|
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
|
-
(
|
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 (
|
935
|
+
labels (dict): A dictionary containing the original image and label information.
|
936
936
|
|
937
937
|
Returns:
|
938
|
-
(
|
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 (
|
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
|
-
(
|
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 (
|
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 (
|
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
|
-
(
|
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 (
|
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
|
-
(
|
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 (
|
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
|
-
(
|
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 (
|
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
|
-
(
|
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 (
|
2225
|
+
labels (dict): A dictionary containing image labels and metadata. Must include 'texts' and 'cls' keys.
|
2226
2226
|
|
2227
2227
|
Returns:
|
2228
|
-
(
|
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 (
|
42
|
+
buffer (list): Buffer for mosaic images.
|
43
43
|
max_buffer_length (int): Maximum buffer size.
|
44
|
-
ims (
|
45
|
-
im_hw0 (
|
46
|
-
im_hw (
|
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 (
|
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 (
|
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)):
|
ultralytics/data/converter.py
CHANGED
@@ -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
|
-
(
|
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 [
|
ultralytics/data/dataset.py
CHANGED
@@ -408,7 +408,7 @@ class GroundingDataset(YOLODataset):
|
|
408
408
|
img_path (str): Path to the directory containing images.
|
409
409
|
|
410
410
|
Returns:
|
411
|
-
(
|
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 (
|
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
|
-
(
|
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
|
ultralytics/data/split_dota.py
CHANGED
@@ -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 (
|
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 (
|
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.
|
ultralytics/engine/exporter.py
CHANGED
@@ -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 (
|
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 (
|
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 (
|
223
|
-
_callbacks (
|
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
|
ultralytics/engine/model.py
CHANGED
@@ -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 (
|
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 (
|
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 (
|
46
|
-
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
|
-
(
|
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
|
-
(
|
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.
|
ultralytics/engine/predictor.py
CHANGED
@@ -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 (
|
85
|
+
windows (list): List of window names for visualization.
|
86
86
|
batch (tuple): Current batch data.
|
87
|
-
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.
|
ultralytics/engine/results.py
CHANGED
@@ -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 (
|
203
|
-
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 (
|
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.
|
ultralytics/engine/trainer.py
CHANGED
@@ -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 (
|
90
|
+
loss_names (list): List of loss names.
|
91
91
|
csv (Path): Path to results CSV file.
|
92
|
-
metrics (
|
93
|
-
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 (
|
103
|
-
_callbacks (
|
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)
|
ultralytics/engine/tuner.py
CHANGED
@@ -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 (
|
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 (
|
42
|
-
callbacks (
|
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 (
|
67
|
-
_callbacks (
|
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
|
-
(
|
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)
|
ultralytics/engine/validator.py
CHANGED
@@ -51,22 +51,22 @@ class BaseValidator:
|
|
51
51
|
dataloader (DataLoader): Dataloader to use for validation.
|
52
52
|
pbar (tqdm): Progress bar to update during validation.
|
53
53
|
model (nn.Module): Model to validate.
|
54
|
-
data (
|
54
|
+
data (dict): Data dictionary containing dataset information.
|
55
55
|
device (torch.device): Device to use for validation.
|
56
56
|
batch_i (int): Current batch index.
|
57
57
|
training (bool): Whether the model is in training mode.
|
58
|
-
names (
|
58
|
+
names (dict): Class names mapping.
|
59
59
|
seen (int): Number of images seen so far during validation.
|
60
|
-
stats (
|
60
|
+
stats (dict): Statistics collected during validation.
|
61
61
|
confusion_matrix: Confusion matrix for classification evaluation.
|
62
62
|
nc (int): Number of classes.
|
63
63
|
iouv (torch.Tensor): IoU thresholds from 0.50 to 0.95 in spaces of 0.05.
|
64
|
-
jdict (
|
65
|
-
speed (
|
64
|
+
jdict (list): List to store JSON validation results.
|
65
|
+
speed (dict): Dictionary with keys 'preprocess', 'inference', 'loss', 'postprocess' and their respective
|
66
66
|
batch processing times in milliseconds.
|
67
67
|
save_dir (Path): Directory to save results.
|
68
|
-
plots (
|
69
|
-
callbacks (
|
68
|
+
plots (dict): Dictionary to store plots for visualization.
|
69
|
+
callbacks (dict): Dictionary to store various callback functions.
|
70
70
|
|
71
71
|
Methods:
|
72
72
|
__call__: Execute validation process, running inference on dataloader and computing performance metrics.
|
@@ -100,7 +100,7 @@ class BaseValidator:
|
|
100
100
|
save_dir (Path, optional): Directory to save results.
|
101
101
|
pbar (tqdm.tqdm, optional): Progress bar for displaying progress.
|
102
102
|
args (SimpleNamespace, optional): Configuration for the validator.
|
103
|
-
_callbacks (
|
103
|
+
_callbacks (dict, optional): Dictionary to store various callback functions.
|
104
104
|
"""
|
105
105
|
self.args = get_cfg(overrides=args)
|
106
106
|
self.dataloader = dataloader
|