ultralytics 8.3.79__py3-none-any.whl → 8.3.81__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/test_exports.py +4 -1
- ultralytics/__init__.py +1 -1
- ultralytics/cfg/__init__.py +6 -6
- ultralytics/data/augment.py +2 -2
- ultralytics/data/utils.py +1 -1
- ultralytics/engine/exporter.py +2 -2
- ultralytics/models/fastsam/val.py +1 -1
- ultralytics/models/nas/model.py +2 -0
- ultralytics/models/yolo/detect/val.py +2 -2
- ultralytics/models/yolo/obb/val.py +1 -1
- ultralytics/models/yolo/pose/val.py +1 -1
- ultralytics/models/yolo/segment/val.py +1 -1
- ultralytics/nn/autobackend.py +2 -2
- ultralytics/utils/checks.py +1 -0
- ultralytics/utils/metrics.py +16 -24
- ultralytics/utils/ops.py +5 -4
- ultralytics/utils/plotting.py +27 -0
- {ultralytics-8.3.79.dist-info → ultralytics-8.3.81.dist-info}/METADATA +2 -2
- {ultralytics-8.3.79.dist-info → ultralytics-8.3.81.dist-info}/RECORD +23 -23
- {ultralytics-8.3.79.dist-info → ultralytics-8.3.81.dist-info}/WHEEL +1 -1
- {ultralytics-8.3.79.dist-info → ultralytics-8.3.81.dist-info}/LICENSE +0 -0
- {ultralytics-8.3.79.dist-info → ultralytics-8.3.81.dist-info}/entry_points.txt +0 -0
- {ultralytics-8.3.79.dist-info → ultralytics-8.3.81.dist-info}/top_level.txt +0 -0
tests/test_exports.py
CHANGED
@@ -139,7 +139,10 @@ def test_export_coreml_matrix(task, dynamic, int8, half, batch):
|
|
139
139
|
|
140
140
|
@pytest.mark.slow
|
141
141
|
@pytest.mark.skipif(not checks.IS_PYTHON_MINIMUM_3_10, reason="TFLite export requires Python>=3.10")
|
142
|
-
@pytest.mark.skipif(
|
142
|
+
@pytest.mark.skipif(
|
143
|
+
not LINUX or IS_RASPBERRYPI,
|
144
|
+
reason="Test disabled as TF suffers from install conflicts on Windows, macOS and Raspberry Pi",
|
145
|
+
)
|
143
146
|
@pytest.mark.parametrize(
|
144
147
|
"task, dynamic, int8, half, batch, nms",
|
145
148
|
[ # generate all combinations except for exclusion cases
|
ultralytics/__init__.py
CHANGED
ultralytics/cfg/__init__.py
CHANGED
@@ -326,8 +326,8 @@ def check_cfg(cfg, hard=True):
|
|
326
326
|
Checks configuration argument types and values for the Ultralytics library.
|
327
327
|
|
328
328
|
This function validates the types and values of configuration arguments, ensuring correctness and converting
|
329
|
-
them if necessary. It checks for specific key types defined in global variables such as CFG_FLOAT_KEYS
|
330
|
-
CFG_FRACTION_KEYS
|
329
|
+
them if necessary. It checks for specific key types defined in global variables such as `CFG_FLOAT_KEYS`,
|
330
|
+
`CFG_FRACTION_KEYS`, `CFG_INT_KEYS`, and `CFG_BOOL_KEYS`.
|
331
331
|
|
332
332
|
Args:
|
333
333
|
cfg (Dict): Configuration dictionary to validate.
|
@@ -498,10 +498,10 @@ def merge_equals_args(args: List[str]) -> List[str]:
|
|
498
498
|
Merges arguments around isolated '=' in a list of strings and joins fragments with brackets.
|
499
499
|
|
500
500
|
This function handles the following cases:
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
501
|
+
1. ['arg', '=', 'val'] becomes ['arg=val']
|
502
|
+
2. ['arg=', 'val'] becomes ['arg=val']
|
503
|
+
3. ['arg', '=val'] becomes ['arg=val']
|
504
|
+
4. Joins fragments with brackets, e.g., ['imgsz=[3,', '640,', '640]'] becomes ['imgsz=[3,640,640]']
|
505
505
|
|
506
506
|
Args:
|
507
507
|
args (List[str]): A list of strings where each element represents an argument or fragment.
|
ultralytics/data/augment.py
CHANGED
@@ -868,8 +868,8 @@ class MixUp(BaseMixTransform):
|
|
868
868
|
"""
|
869
869
|
Applies MixUp augmentation to image datasets.
|
870
870
|
|
871
|
-
This class implements the MixUp augmentation technique as described in the paper
|
872
|
-
Minimization
|
871
|
+
This class implements the MixUp augmentation technique as described in the paper [mixup: Beyond Empirical Risk
|
872
|
+
Minimization](https://arxiv.org/abs/1710.09412). MixUp combines two images and their labels using a random weight.
|
873
873
|
|
874
874
|
Attributes:
|
875
875
|
dataset (Any): The dataset to which MixUp augmentation will be applied.
|
ultralytics/data/utils.py
CHANGED
@@ -184,7 +184,7 @@ def visualize_image_annotations(image_path, txt_path, label_map):
|
|
184
184
|
- height (float): The height of the bounding box (relative to image height).
|
185
185
|
label_map (dict): A dictionary that maps class IDs (integers) to class labels (strings).
|
186
186
|
|
187
|
-
|
187
|
+
Examples:
|
188
188
|
>>> label_map = {0: "cat", 1: "dog", 2: "bird"} # It should include all annotated classes details
|
189
189
|
>>> visualize_image_annotations("path/to/image.jpg", "path/to/annotations.txt", label_map)
|
190
190
|
"""
|
ultralytics/engine/exporter.py
CHANGED
@@ -570,7 +570,7 @@ class Exporter:
|
|
570
570
|
@try_export
|
571
571
|
def export_openvino(self, prefix=colorstr("OpenVINO:")):
|
572
572
|
"""YOLO OpenVINO export."""
|
573
|
-
check_requirements("openvino>=2024.
|
573
|
+
check_requirements("openvino>=2024.0.0,<2025.0.0")
|
574
574
|
import openvino as ov
|
575
575
|
|
576
576
|
LOGGER.info(f"\n{prefix} starting export with openvino {ov.__version__}...")
|
@@ -592,7 +592,7 @@ class Exporter:
|
|
592
592
|
if self.model.task != "classify":
|
593
593
|
ov_model.set_rt_info("fit_to_window_letterbox", ["model_info", "resize_type"])
|
594
594
|
|
595
|
-
ov.
|
595
|
+
ov.save_model(ov_model, file, compress_to_fp16=self.args.half)
|
596
596
|
yaml_save(Path(file).parent / "metadata.yaml", self.metadata) # add metadata.yaml
|
597
597
|
|
598
598
|
if self.args.int8:
|
@@ -37,4 +37,4 @@ class FastSAMValidator(SegmentationValidator):
|
|
37
37
|
super().__init__(dataloader, save_dir, pbar, args, _callbacks)
|
38
38
|
self.args.task = "segment"
|
39
39
|
self.args.plots = False # disable ConfusionMatrix and other plots to avoid errors
|
40
|
-
self.metrics = SegmentMetrics(save_dir=self.save_dir
|
40
|
+
self.metrics = SegmentMetrics(save_dir=self.save_dir)
|
ultralytics/models/nas/model.py
CHANGED
@@ -16,6 +16,7 @@ from pathlib import Path
|
|
16
16
|
import torch
|
17
17
|
|
18
18
|
from ultralytics.engine.model import Model
|
19
|
+
from ultralytics.utils import DEFAULT_CFG_DICT
|
19
20
|
from ultralytics.utils.downloads import attempt_download_asset
|
20
21
|
from ultralytics.utils.torch_utils import model_info
|
21
22
|
|
@@ -77,6 +78,7 @@ class NAS(Model):
|
|
77
78
|
self.model.yaml = {} # for info()
|
78
79
|
self.model.pt_path = weights # for export()
|
79
80
|
self.model.task = "detect" # for export()
|
81
|
+
self.model.args = {**DEFAULT_CFG_DICT, **self.overrides} # for export()
|
80
82
|
|
81
83
|
def info(self, detailed=False, verbose=True):
|
82
84
|
"""
|
@@ -37,7 +37,7 @@ class DetectionValidator(BaseValidator):
|
|
37
37
|
self.is_lvis = False
|
38
38
|
self.class_map = None
|
39
39
|
self.args.task = "detect"
|
40
|
-
self.metrics = DetMetrics(save_dir=self.save_dir
|
40
|
+
self.metrics = DetMetrics(save_dir=self.save_dir)
|
41
41
|
self.iouv = torch.linspace(0.5, 0.95, 10) # IoU vector for mAP@0.5:0.95
|
42
42
|
self.niou = self.iouv.numel()
|
43
43
|
self.lb = [] # for autolabelling
|
@@ -187,7 +187,7 @@ class DetectionValidator(BaseValidator):
|
|
187
187
|
self.nt_per_image = np.bincount(stats["target_img"].astype(int), minlength=self.nc)
|
188
188
|
stats.pop("target_img", None)
|
189
189
|
if len(stats):
|
190
|
-
self.metrics.process(**stats)
|
190
|
+
self.metrics.process(**stats, on_plot=self.on_plot)
|
191
191
|
return self.metrics.results_dict
|
192
192
|
|
193
193
|
def print_results(self):
|
@@ -28,7 +28,7 @@ class OBBValidator(DetectionValidator):
|
|
28
28
|
"""Initialize OBBValidator and set task to 'obb', metrics to OBBMetrics."""
|
29
29
|
super().__init__(dataloader, save_dir, pbar, args, _callbacks)
|
30
30
|
self.args.task = "obb"
|
31
|
-
self.metrics = OBBMetrics(save_dir=self.save_dir, plot=True
|
31
|
+
self.metrics = OBBMetrics(save_dir=self.save_dir, plot=True)
|
32
32
|
|
33
33
|
def init_metrics(self, model):
|
34
34
|
"""Initialize evaluation metrics for YOLO."""
|
@@ -32,7 +32,7 @@ class PoseValidator(DetectionValidator):
|
|
32
32
|
self.sigma = None
|
33
33
|
self.kpt_shape = None
|
34
34
|
self.args.task = "pose"
|
35
|
-
self.metrics = PoseMetrics(save_dir=self.save_dir
|
35
|
+
self.metrics = PoseMetrics(save_dir=self.save_dir)
|
36
36
|
if isinstance(self.args.device, str) and self.args.device.lower() == "mps":
|
37
37
|
LOGGER.warning(
|
38
38
|
"WARNING ⚠️ Apple MPS known Pose bug. Recommend 'device=cpu' for Pose models. "
|
@@ -34,7 +34,7 @@ class SegmentationValidator(DetectionValidator):
|
|
34
34
|
self.plot_masks = None
|
35
35
|
self.process = None
|
36
36
|
self.args.task = "segment"
|
37
|
-
self.metrics = SegmentMetrics(save_dir=self.save_dir
|
37
|
+
self.metrics = SegmentMetrics(save_dir=self.save_dir)
|
38
38
|
|
39
39
|
def preprocess(self, batch):
|
40
40
|
"""Preprocesses batch by converting masks to float and sending to device."""
|
ultralytics/nn/autobackend.py
CHANGED
@@ -244,7 +244,7 @@ class AutoBackend(nn.Module):
|
|
244
244
|
# OpenVINO
|
245
245
|
elif xml:
|
246
246
|
LOGGER.info(f"Loading {w} for OpenVINO inference...")
|
247
|
-
check_requirements("openvino>=2024.0.0")
|
247
|
+
check_requirements("openvino>=2024.0.0,<2025.0.0")
|
248
248
|
import openvino as ov
|
249
249
|
|
250
250
|
core = ov.Core()
|
@@ -600,7 +600,7 @@ class AutoBackend(nn.Module):
|
|
600
600
|
results[userdata] = request.results
|
601
601
|
|
602
602
|
# Create AsyncInferQueue, set the callback and start asynchronous inference for each input image
|
603
|
-
async_queue = self.ov.
|
603
|
+
async_queue = self.ov.AsyncInferQueue(self.ov_compiled_model)
|
604
604
|
async_queue.set_callback(callback)
|
605
605
|
for i in range(n):
|
606
606
|
# Start async inference with userdata=i to specify the position in results list
|
ultralytics/utils/checks.py
CHANGED
@@ -609,6 +609,7 @@ def collect_system_info():
|
|
609
609
|
"Environment": ENVIRONMENT,
|
610
610
|
"Python": PYTHON_VERSION,
|
611
611
|
"Install": "git" if IS_GIT_DIR else "pip" if IS_PIP_PACKAGE else "other",
|
612
|
+
"Path": str(ROOT),
|
612
613
|
"RAM": f"{psutil.virtual_memory().total / gib:.2f} GB",
|
613
614
|
"Disk": f"{(total - free) / gib:.1f}/{total / gib:.1f} GB",
|
614
615
|
"CPU": get_cpu_info(),
|
ultralytics/utils/metrics.py
CHANGED
@@ -803,13 +803,11 @@ class DetMetrics(SimpleClass):
|
|
803
803
|
Args:
|
804
804
|
save_dir (Path): A path to the directory where the output plots will be saved. Defaults to current directory.
|
805
805
|
plot (bool): A flag that indicates whether to plot precision-recall curves for each class. Defaults to False.
|
806
|
-
on_plot (func): An optional callback to pass plots path and data when they are rendered. Defaults to None.
|
807
806
|
names (dict of str): A dict of strings that represents the names of the classes. Defaults to an empty tuple.
|
808
807
|
|
809
808
|
Attributes:
|
810
809
|
save_dir (Path): A path to the directory where the output plots will be saved.
|
811
810
|
plot (bool): A flag that indicates whether to plot the precision-recall curves for each class.
|
812
|
-
on_plot (func): An optional callback to pass plots path and data when they are rendered.
|
813
811
|
names (dict of str): A dict of strings that represents the names of the classes.
|
814
812
|
box (Metric): An instance of the Metric class for storing the results of the detection metrics.
|
815
813
|
speed (dict): A dictionary for storing the execution time of different parts of the detection process.
|
@@ -827,17 +825,16 @@ class DetMetrics(SimpleClass):
|
|
827
825
|
curves_results: TODO
|
828
826
|
"""
|
829
827
|
|
830
|
-
def __init__(self, save_dir=Path("."), plot=False,
|
828
|
+
def __init__(self, save_dir=Path("."), plot=False, names={}) -> None:
|
831
829
|
"""Initialize a DetMetrics instance with a save directory, plot flag, callback function, and class names."""
|
832
830
|
self.save_dir = save_dir
|
833
831
|
self.plot = plot
|
834
|
-
self.on_plot = on_plot
|
835
832
|
self.names = names
|
836
833
|
self.box = Metric()
|
837
834
|
self.speed = {"preprocess": 0.0, "inference": 0.0, "loss": 0.0, "postprocess": 0.0}
|
838
835
|
self.task = "detect"
|
839
836
|
|
840
|
-
def process(self, tp, conf, pred_cls, target_cls):
|
837
|
+
def process(self, tp, conf, pred_cls, target_cls, on_plot=None):
|
841
838
|
"""Process predicted results for object detection and update metrics."""
|
842
839
|
results = ap_per_class(
|
843
840
|
tp,
|
@@ -847,7 +844,7 @@ class DetMetrics(SimpleClass):
|
|
847
844
|
plot=self.plot,
|
848
845
|
save_dir=self.save_dir,
|
849
846
|
names=self.names,
|
850
|
-
on_plot=
|
847
|
+
on_plot=on_plot,
|
851
848
|
)[2:]
|
852
849
|
self.box.nc = len(self.names)
|
853
850
|
self.box.update(results)
|
@@ -903,13 +900,11 @@ class SegmentMetrics(SimpleClass):
|
|
903
900
|
Args:
|
904
901
|
save_dir (Path): Path to the directory where the output plots should be saved. Default is the current directory.
|
905
902
|
plot (bool): Whether to save the detection and segmentation plots. Default is False.
|
906
|
-
on_plot (func): An optional callback to pass plots path and data when they are rendered. Defaults to None.
|
907
903
|
names (list): List of class names. Default is an empty list.
|
908
904
|
|
909
905
|
Attributes:
|
910
906
|
save_dir (Path): Path to the directory where the output plots should be saved.
|
911
907
|
plot (bool): Whether to save the detection and segmentation plots.
|
912
|
-
on_plot (func): An optional callback to pass plots path and data when they are rendered.
|
913
908
|
names (list): List of class names.
|
914
909
|
box (Metric): An instance of the Metric class to calculate box detection metrics.
|
915
910
|
seg (Metric): An instance of the Metric class to calculate mask segmentation metrics.
|
@@ -925,18 +920,17 @@ class SegmentMetrics(SimpleClass):
|
|
925
920
|
results_dict: Returns the dictionary containing all the detection and segmentation metrics and fitness score.
|
926
921
|
"""
|
927
922
|
|
928
|
-
def __init__(self, save_dir=Path("."), plot=False,
|
923
|
+
def __init__(self, save_dir=Path("."), plot=False, names=()) -> None:
|
929
924
|
"""Initialize a SegmentMetrics instance with a save directory, plot flag, callback function, and class names."""
|
930
925
|
self.save_dir = save_dir
|
931
926
|
self.plot = plot
|
932
|
-
self.on_plot = on_plot
|
933
927
|
self.names = names
|
934
928
|
self.box = Metric()
|
935
929
|
self.seg = Metric()
|
936
930
|
self.speed = {"preprocess": 0.0, "inference": 0.0, "loss": 0.0, "postprocess": 0.0}
|
937
931
|
self.task = "segment"
|
938
932
|
|
939
|
-
def process(self, tp, tp_m, conf, pred_cls, target_cls):
|
933
|
+
def process(self, tp, tp_m, conf, pred_cls, target_cls, on_plot=None):
|
940
934
|
"""
|
941
935
|
Processes the detection and segmentation metrics over the given set of predictions.
|
942
936
|
|
@@ -946,6 +940,7 @@ class SegmentMetrics(SimpleClass):
|
|
946
940
|
conf (list): List of confidence scores.
|
947
941
|
pred_cls (list): List of predicted classes.
|
948
942
|
target_cls (list): List of target classes.
|
943
|
+
on_plot (func): An optional callback to pass plots path and data when they are rendered. Defaults to None.
|
949
944
|
"""
|
950
945
|
results_mask = ap_per_class(
|
951
946
|
tp_m,
|
@@ -953,7 +948,7 @@ class SegmentMetrics(SimpleClass):
|
|
953
948
|
pred_cls,
|
954
949
|
target_cls,
|
955
950
|
plot=self.plot,
|
956
|
-
on_plot=
|
951
|
+
on_plot=on_plot,
|
957
952
|
save_dir=self.save_dir,
|
958
953
|
names=self.names,
|
959
954
|
prefix="Mask",
|
@@ -966,7 +961,7 @@ class SegmentMetrics(SimpleClass):
|
|
966
961
|
pred_cls,
|
967
962
|
target_cls,
|
968
963
|
plot=self.plot,
|
969
|
-
on_plot=
|
964
|
+
on_plot=on_plot,
|
970
965
|
save_dir=self.save_dir,
|
971
966
|
names=self.names,
|
972
967
|
prefix="Box",
|
@@ -1043,13 +1038,11 @@ class PoseMetrics(SegmentMetrics):
|
|
1043
1038
|
Args:
|
1044
1039
|
save_dir (Path): Path to the directory where the output plots should be saved. Default is the current directory.
|
1045
1040
|
plot (bool): Whether to save the detection and segmentation plots. Default is False.
|
1046
|
-
on_plot (func): An optional callback to pass plots path and data when they are rendered. Defaults to None.
|
1047
1041
|
names (list): List of class names. Default is an empty list.
|
1048
1042
|
|
1049
1043
|
Attributes:
|
1050
1044
|
save_dir (Path): Path to the directory where the output plots should be saved.
|
1051
1045
|
plot (bool): Whether to save the detection and segmentation plots.
|
1052
|
-
on_plot (func): An optional callback to pass plots path and data when they are rendered.
|
1053
1046
|
names (list): List of class names.
|
1054
1047
|
box (Metric): An instance of the Metric class to calculate box detection metrics.
|
1055
1048
|
pose (Metric): An instance of the Metric class to calculate mask segmentation metrics.
|
@@ -1065,19 +1058,18 @@ class PoseMetrics(SegmentMetrics):
|
|
1065
1058
|
results_dict: Returns the dictionary containing all the detection and segmentation metrics and fitness score.
|
1066
1059
|
"""
|
1067
1060
|
|
1068
|
-
def __init__(self, save_dir=Path("."), plot=False,
|
1061
|
+
def __init__(self, save_dir=Path("."), plot=False, names=()) -> None:
|
1069
1062
|
"""Initialize the PoseMetrics class with directory path, class names, and plotting options."""
|
1070
1063
|
super().__init__(save_dir, plot, names)
|
1071
1064
|
self.save_dir = save_dir
|
1072
1065
|
self.plot = plot
|
1073
|
-
self.on_plot = on_plot
|
1074
1066
|
self.names = names
|
1075
1067
|
self.box = Metric()
|
1076
1068
|
self.pose = Metric()
|
1077
1069
|
self.speed = {"preprocess": 0.0, "inference": 0.0, "loss": 0.0, "postprocess": 0.0}
|
1078
1070
|
self.task = "pose"
|
1079
1071
|
|
1080
|
-
def process(self, tp, tp_p, conf, pred_cls, target_cls):
|
1072
|
+
def process(self, tp, tp_p, conf, pred_cls, target_cls, on_plot=None):
|
1081
1073
|
"""
|
1082
1074
|
Processes the detection and pose metrics over the given set of predictions.
|
1083
1075
|
|
@@ -1087,6 +1079,7 @@ class PoseMetrics(SegmentMetrics):
|
|
1087
1079
|
conf (list): List of confidence scores.
|
1088
1080
|
pred_cls (list): List of predicted classes.
|
1089
1081
|
target_cls (list): List of target classes.
|
1082
|
+
on_plot (func): An optional callback to pass plots path and data when they are rendered. Defaults to None.
|
1090
1083
|
"""
|
1091
1084
|
results_pose = ap_per_class(
|
1092
1085
|
tp_p,
|
@@ -1094,7 +1087,7 @@ class PoseMetrics(SegmentMetrics):
|
|
1094
1087
|
pred_cls,
|
1095
1088
|
target_cls,
|
1096
1089
|
plot=self.plot,
|
1097
|
-
on_plot=
|
1090
|
+
on_plot=on_plot,
|
1098
1091
|
save_dir=self.save_dir,
|
1099
1092
|
names=self.names,
|
1100
1093
|
prefix="Pose",
|
@@ -1107,7 +1100,7 @@ class PoseMetrics(SegmentMetrics):
|
|
1107
1100
|
pred_cls,
|
1108
1101
|
target_cls,
|
1109
1102
|
plot=self.plot,
|
1110
|
-
on_plot=
|
1103
|
+
on_plot=on_plot,
|
1111
1104
|
save_dir=self.save_dir,
|
1112
1105
|
names=self.names,
|
1113
1106
|
prefix="Box",
|
@@ -1226,16 +1219,15 @@ class ClassifyMetrics(SimpleClass):
|
|
1226
1219
|
class OBBMetrics(SimpleClass):
|
1227
1220
|
"""Metrics for evaluating oriented bounding box (OBB) detection, see https://arxiv.org/pdf/2106.06072.pdf."""
|
1228
1221
|
|
1229
|
-
def __init__(self, save_dir=Path("."), plot=False,
|
1222
|
+
def __init__(self, save_dir=Path("."), plot=False, names=()) -> None:
|
1230
1223
|
"""Initialize an OBBMetrics instance with directory, plotting, callback, and class names."""
|
1231
1224
|
self.save_dir = save_dir
|
1232
1225
|
self.plot = plot
|
1233
|
-
self.on_plot = on_plot
|
1234
1226
|
self.names = names
|
1235
1227
|
self.box = Metric()
|
1236
1228
|
self.speed = {"preprocess": 0.0, "inference": 0.0, "loss": 0.0, "postprocess": 0.0}
|
1237
1229
|
|
1238
|
-
def process(self, tp, conf, pred_cls, target_cls):
|
1230
|
+
def process(self, tp, conf, pred_cls, target_cls, on_plot=None):
|
1239
1231
|
"""Process predicted results for object detection and update metrics."""
|
1240
1232
|
results = ap_per_class(
|
1241
1233
|
tp,
|
@@ -1245,7 +1237,7 @@ class OBBMetrics(SimpleClass):
|
|
1245
1237
|
plot=self.plot,
|
1246
1238
|
save_dir=self.save_dir,
|
1247
1239
|
names=self.names,
|
1248
|
-
on_plot=
|
1240
|
+
on_plot=on_plot,
|
1249
1241
|
)[2:]
|
1250
1242
|
self.box.nc = len(self.names)
|
1251
1243
|
self.box.update(results)
|
ultralytics/utils/ops.py
CHANGED
@@ -799,10 +799,11 @@ def regularize_rboxes(rboxes):
|
|
799
799
|
(torch.Tensor): The regularized boxes.
|
800
800
|
"""
|
801
801
|
x, y, w, h, t = rboxes.unbind(dim=-1)
|
802
|
-
# Swap edge
|
803
|
-
|
804
|
-
|
805
|
-
|
802
|
+
# Swap edge if t >= pi/2 while not being symmetrically opposite
|
803
|
+
swap = t % math.pi >= math.pi / 2
|
804
|
+
w_ = torch.where(swap, h, w)
|
805
|
+
h_ = torch.where(swap, w, h)
|
806
|
+
t = t % (math.pi / 2)
|
806
807
|
return torch.stack([x, y, w_, h_, t], dim=-1) # regularized boxes
|
807
808
|
|
808
809
|
|
ultralytics/utils/plotting.py
CHANGED
@@ -29,6 +29,10 @@ class Colors:
|
|
29
29
|
n (int): The number of colors in the palette.
|
30
30
|
pose_palette (np.ndarray): A specific color palette array with dtype np.uint8.
|
31
31
|
|
32
|
+
Examples:
|
33
|
+
>>> from ultralytics.utils.plotting import Colors
|
34
|
+
>>> color = Colors(5, True) # ff6fdd or (255, 111, 221)
|
35
|
+
|
32
36
|
## Ultralytics Color Palette
|
33
37
|
|
34
38
|
| Index | Color | HEX | RGB |
|
@@ -162,6 +166,11 @@ class Annotator:
|
|
162
166
|
skeleton (List[List[int]]): Skeleton structure for keypoints.
|
163
167
|
limb_color (List[int]): Color palette for limbs.
|
164
168
|
kpt_color (List[int]): Color palette for keypoints.
|
169
|
+
|
170
|
+
Examples:
|
171
|
+
>>> from ultralytics.utils.plotting import Annotator
|
172
|
+
>>> im0 = cv2.imread("test.png")
|
173
|
+
>>> annotator = Annotator(im0, line_width=10)
|
165
174
|
"""
|
166
175
|
|
167
176
|
def __init__(self, im, line_width=None, font_size=None, font="Arial.ttf", pil=False, example="abc"):
|
@@ -247,6 +256,12 @@ class Annotator:
|
|
247
256
|
|
248
257
|
Returns:
|
249
258
|
txt_color (tuple): Text color for label
|
259
|
+
|
260
|
+
Examples:
|
261
|
+
>>> from ultralytics.utils.plotting import Annotator
|
262
|
+
>>> im0 = cv2.imread("test.png")
|
263
|
+
>>> annotator = Annotator(im0, line_width=10)
|
264
|
+
>>> annotator.get_txt_color(color=(104, 31, 17)) # return (255, 255, 255)
|
250
265
|
"""
|
251
266
|
if color in self.dark_colors:
|
252
267
|
return 104, 31, 17
|
@@ -343,6 +358,12 @@ class Annotator:
|
|
343
358
|
color (tuple, optional): The background color of the rectangle (B, G, R).
|
344
359
|
txt_color (tuple, optional): The color of the text (R, G, B).
|
345
360
|
rotated (bool, optional): Variable used to check if task is OBB
|
361
|
+
|
362
|
+
Examples:
|
363
|
+
>>> from ultralytics.utils.plotting import Annotator
|
364
|
+
>>> im0 = cv2.imread("test.png")
|
365
|
+
>>> annotator = Annotator(im0, line_width=10)
|
366
|
+
>>> annotator.box_label(box=[10, 20, 30, 40], label="person")
|
346
367
|
"""
|
347
368
|
txt_color = self.get_txt_color(color, txt_color)
|
348
369
|
if isinstance(box, torch.Tensor):
|
@@ -557,6 +578,12 @@ class Annotator:
|
|
557
578
|
width (float): Width of the bounding box.
|
558
579
|
height (float): Height of the bounding box.
|
559
580
|
area (float): Area enclosed by the bounding box.
|
581
|
+
|
582
|
+
Examples:
|
583
|
+
>>> from ultralytics.utils.plotting import Annotator
|
584
|
+
>>> im0 = cv2.imread("test.png")
|
585
|
+
>>> annotator = Annotator(im0, line_width=10)
|
586
|
+
>>> annotator.get_bbox_dimension(bbox=[10, 20, 30, 40])
|
560
587
|
"""
|
561
588
|
x_min, y_min, x_max, y_max = bbox
|
562
589
|
width = x_max - x_min
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ultralytics
|
3
|
-
Version: 8.3.
|
3
|
+
Version: 8.3.81
|
4
4
|
Summary: Ultralytics YOLO 🚀 for SOTA object detection, multi-object tracking, instance segmentation, pose estimation and image classification.
|
5
5
|
Author-email: Glenn Jocher <glenn.jocher@ultralytics.com>, Jing Qiu <jing.qiu@ultralytics.com>
|
6
6
|
Maintainer-email: Ultralytics <hello@ultralytics.com>
|
@@ -63,7 +63,7 @@ Provides-Extra: export
|
|
63
63
|
Requires-Dist: onnx>=1.12.0; extra == "export"
|
64
64
|
Requires-Dist: coremltools>=7.0; (platform_system != "Windows" and python_version <= "3.11") and extra == "export"
|
65
65
|
Requires-Dist: scikit-learn>=1.3.2; (platform_system != "Windows" and python_version <= "3.11") and extra == "export"
|
66
|
-
Requires-Dist: openvino
|
66
|
+
Requires-Dist: openvino<2025.0.0,>=2024.0.0; extra == "export"
|
67
67
|
Requires-Dist: tensorflow>=2.0.0; extra == "export"
|
68
68
|
Requires-Dist: tensorflowjs>=3.9.0; extra == "export"
|
69
69
|
Requires-Dist: tensorstore>=0.1.63; (platform_machine == "aarch64" and python_version >= "3.9") and extra == "export"
|
@@ -3,14 +3,14 @@ tests/conftest.py,sha256=DE4-5JqWhsQPyDhU5hHqRevz971yPBQORs3LitLc6Fo,3010
|
|
3
3
|
tests/test_cli.py,sha256=b9pPCu6x_MejPw-G7TI3wxSZnaMmutcXW7aCzMzz4ig,5076
|
4
4
|
tests/test_cuda.py,sha256=inPe0f_L0GutDxYLbe49BPEmjMevaS9XXCWX1Lfjo2g,5971
|
5
5
|
tests/test_engine.py,sha256=aGqZ8P7QO5C_nOa1b4FOyk92Ysdk5WiP-ST310Vyxys,4962
|
6
|
-
tests/test_exports.py,sha256=
|
6
|
+
tests/test_exports.py,sha256=ehuGi1M1aOOnMgnOcOMLgE3kpf6SjpK5rRY_K60Vxsk,9303
|
7
7
|
tests/test_integrations.py,sha256=p3DMnnPMKsV0Qm82JVJUIY1UZ67xRgF9E8AaL76TEHE,6154
|
8
8
|
tests/test_python.py,sha256=tW-EFJC2rjl_DvAa8khXGWYdypseQjrLjGHhe2p9r9A,23238
|
9
9
|
tests/test_solutions.py,sha256=aY0G3vNzXGCENG9FD76MfUp7jgzeESPsUvbvQYBUvH0,4205
|
10
|
-
ultralytics/__init__.py,sha256
|
10
|
+
ultralytics/__init__.py,sha256=-NZ32aHUn4plibg5MrjXMsxJx4BvsLzNIsfeUF2ZGfA,709
|
11
11
|
ultralytics/assets/bus.jpg,sha256=wCAZxJecGR63Od3ZRERe9Aja1Weayrb9Ug751DS_vGM,137419
|
12
12
|
ultralytics/assets/zidane.jpg,sha256=Ftc4aeMmen1O0A3o6GCDO9FlfBslLpTAw0gnetx7bts,50427
|
13
|
-
ultralytics/cfg/__init__.py,sha256=
|
13
|
+
ultralytics/cfg/__init__.py,sha256=C5MkWVKf71g5ajkNp1H4DLsbKkkx9iaWCV02tjoL2ds,39795
|
14
14
|
ultralytics/cfg/default.yaml,sha256=tHE_VB_tzq5K1BntCCukmFIViwiRv0R-H6ZNucCnYsY,8469
|
15
15
|
ultralytics/cfg/datasets/Argoverse.yaml,sha256=W225bp0LpIKbn8qrApX4W0jGUJc5tPKQNJjVdkInzJo,3163
|
16
16
|
ultralytics/cfg/datasets/DOTAv1.5.yaml,sha256=SHND_CFkojxw5iQD5Mcgju2kCZIl0gW2ajuzv1cqoL0,1224
|
@@ -98,16 +98,16 @@ ultralytics/cfg/trackers/botsort.yaml,sha256=D9doE5GQUe6HrAFzr7OfQFIGPFk0M_vJ0B_
|
|
98
98
|
ultralytics/cfg/trackers/bytetrack.yaml,sha256=6u-tiZlk16EqEwkNXaMrza6PAQmWj_ypgv26LGCtPDg,886
|
99
99
|
ultralytics/data/__init__.py,sha256=nAXaL1puCc7z_NjzQNlJnhbVhT9Fla2u7Dsqo7q1dAc,644
|
100
100
|
ultralytics/data/annotator.py,sha256=whx_3sdKGRsECYLKyJMNGQ-d9g-f8020O6kvl5M1c_I,3067
|
101
|
-
ultralytics/data/augment.py,sha256=
|
101
|
+
ultralytics/data/augment.py,sha256=O00CKxKkzjn0v5BUktzbVghz7vUEve4LFwviIc9Knwk,121318
|
102
102
|
ultralytics/data/base.py,sha256=NTNdn-Emgx3Z2vats8i8oEe-9yosPmHd53v1A0xz0EU,15196
|
103
103
|
ultralytics/data/build.py,sha256=gOU5SNABBNxwo5012N--WhjEnLK2ewycXIryMpbHg6U,7685
|
104
104
|
ultralytics/data/converter.py,sha256=M7LvBpdYiDA_YEuef3oCXhGPFTjtyJjSbSwqn-F6d7I,24473
|
105
105
|
ultralytics/data/dataset.py,sha256=lxtH3JytNu6nsiPAIhe0uGuGGpkZ4ZRqvXM6eJw9rXU,23244
|
106
106
|
ultralytics/data/loaders.py,sha256=JOwXbz-dxgG2bx0_cQHp-olz5FleoCX8EzrUvZ77vvg,28534
|
107
107
|
ultralytics/data/split_dota.py,sha256=YI-i2MqdiBt06W67TJnBXQHJrqTnkJDJ3zzoL0UZVro,10733
|
108
|
-
ultralytics/data/utils.py,sha256=
|
108
|
+
ultralytics/data/utils.py,sha256=GgsexyPYoyAz-felAuMEfI-C-aeU2jy9VlzbmVdlAQw,33839
|
109
109
|
ultralytics/engine/__init__.py,sha256=lm6MckFYCPTbqIoX7w0s_daxdjNeBeKW6DXppv1-QUM,70
|
110
|
-
ultralytics/engine/exporter.py,sha256=
|
110
|
+
ultralytics/engine/exporter.py,sha256=DslfLk7H44ly4-kCY0u6SLSRjdx7NO5lzfnnD1_c7wI,77015
|
111
111
|
ultralytics/engine/model.py,sha256=s8HsSBvdRgSbnKGULr7YW-ZWJKJsQpOoHd9Aih_nMt0,53427
|
112
112
|
ultralytics/engine/predictor.py,sha256=jiYDAjupOlRUpPvw9tu7or9PjXtLm-YCRiawANtWxj0,17881
|
113
113
|
ultralytics/engine/results.py,sha256=hWlO2e58BPUJ5R4Jl4iirBPaZ8BypcNu_cNQ2NHpUqM,78111
|
@@ -124,9 +124,9 @@ ultralytics/models/fastsam/__init__.py,sha256=HGJ8EKlBAsdF-e2aIwQLjSDAFI_r0yHR0A
|
|
124
124
|
ultralytics/models/fastsam/model.py,sha256=8QGYWPUFDww8IG6S6dkGHl6STELap0gAsxu4H2xefnc,2036
|
125
125
|
ultralytics/models/fastsam/predict.py,sha256=IqdetKBwkrrLnUWRf37vjiNFkudqVd_OPEwZu8vpLt8,7512
|
126
126
|
ultralytics/models/fastsam/utils.py,sha256=Sl6vXHzK3G6SD-NdxmsiiHM4chlyaHl0pjSkU3Wb3UU,742
|
127
|
-
ultralytics/models/fastsam/val.py,sha256=
|
127
|
+
ultralytics/models/fastsam/val.py,sha256=76paG_tnhX0TgVPd-uDmNfTIupJNW2VI6U_tIW5a8VA,1973
|
128
128
|
ultralytics/models/nas/__init__.py,sha256=wybeHZuAXMNeXMjKTbK55FZmXJkA4K9IozDeFM9OB-s,207
|
129
|
-
ultralytics/models/nas/model.py,sha256=
|
129
|
+
ultralytics/models/nas/model.py,sha256=slVlIe-44BS6L1AJkfyin4E2V5aBQEkBBd6nRAXcAoQ,3390
|
130
130
|
ultralytics/models/nas/predict.py,sha256=nzVGTdUb0E_IjmWksX_T61q80hbrjEovihTzTJ1rfmA,2124
|
131
131
|
ultralytics/models/nas/val.py,sha256=CSqmcuAcuJ5SQ7mo364RdXLGeu2XATyRY8Z84VGGX5o,1497
|
132
132
|
ultralytics/models/rtdetr/__init__.py,sha256=_jEHmOjI_QP_nT3XJXLgYHQ6bXG4EL8Gnvn1y_eev1g,225
|
@@ -160,24 +160,24 @@ ultralytics/models/yolo/classify/val.py,sha256=VUYkqGtKnZPig1XE5Qrtqoqm-Y9dDgr5Y
|
|
160
160
|
ultralytics/models/yolo/detect/__init__.py,sha256=GIRsLYR-kT4JJx7lh4ZZAFGBZj0aebokuU0A7JbjDVA,257
|
161
161
|
ultralytics/models/yolo/detect/predict.py,sha256=_RrKS3h-tRR4uJyTOPSIp4HapxXC-c8Ao9yDeAM835I,2852
|
162
162
|
ultralytics/models/yolo/detect/train.py,sha256=Y2SYjywenBLg8j-r4bC_sWqle1DJGQtDL5O6koeqm9U,6738
|
163
|
-
ultralytics/models/yolo/detect/val.py,sha256=
|
163
|
+
ultralytics/models/yolo/detect/val.py,sha256=yxYvkLW8yTCjACRQ9LH7w_fz5Z2IpcVR1r2FYNK2YBA,15231
|
164
164
|
ultralytics/models/yolo/obb/__init__.py,sha256=tQmpG8wVHsajWkZdmD6cjGohJ4ki64iSXQT8JY_dydo,221
|
165
165
|
ultralytics/models/yolo/obb/predict.py,sha256=SUgLzsxg1O77KxIeCj9IlSiqB9SfIwcoRtNZViqPS2E,1880
|
166
166
|
ultralytics/models/yolo/obb/train.py,sha256=7LJ04dYENfjdt1Jet0Cxh0nyIpmgIUtmz425ZEuZSn8,1550
|
167
|
-
ultralytics/models/yolo/obb/val.py,sha256=
|
167
|
+
ultralytics/models/yolo/obb/val.py,sha256=8zCTDx56dsJe3_2KNcZmLCP4rYpJVih_8gf2QqF-tGo,8901
|
168
168
|
ultralytics/models/yolo/pose/__init__.py,sha256=63xmuHZLNzV8I76HhVXAq4f2W0KTk8Oi9eL-Y204LyQ,227
|
169
169
|
ultralytics/models/yolo/pose/predict.py,sha256=O-LI_acPh_xoXd7ZcxpxAUbIzfj5FkrwEXLuN16Rl7c,2120
|
170
170
|
ultralytics/models/yolo/pose/train.py,sha256=472BgOjvDdNXe9GN68zO1ddRh5Cbmfg5m9_JZyHrTxY,2954
|
171
|
-
ultralytics/models/yolo/pose/val.py,sha256=
|
171
|
+
ultralytics/models/yolo/pose/val.py,sha256=3-A--EwOOC1ZzXBQPViUPVyItXsDs1NaIrNJe73N9i0,11946
|
172
172
|
ultralytics/models/yolo/segment/__init__.py,sha256=3IThhZ1wlkY9FvmWm9cE-5-ZyE6F1FgzAtQ6jOOFzzw,275
|
173
173
|
ultralytics/models/yolo/segment/predict.py,sha256=p5bLdex_74bfk7pMr_NLAGISi6YOj8pMmUKF7aZ7lxk,3417
|
174
174
|
ultralytics/models/yolo/segment/train.py,sha256=2PGirZ7cvAsK2LxrEKC0HisOqPw6hyUCAPMkYmqQkIY,2326
|
175
|
-
ultralytics/models/yolo/segment/val.py,sha256=
|
175
|
+
ultralytics/models/yolo/segment/val.py,sha256=PBhlLW4XoCypGwrA3nO_U7BedqLlW4bNHO7ekP4y_kk,13786
|
176
176
|
ultralytics/models/yolo/world/__init__.py,sha256=nlh8I6t8hMGz_vZg8QSlsUW1R-2eKvn9CGUoPPQEGhA,131
|
177
177
|
ultralytics/models/yolo/world/train.py,sha256=6PVmQ0G-22OOPPwP_rqSobe2LM6e2b_lC7lJCdW3UIk,3714
|
178
178
|
ultralytics/models/yolo/world/train_world.py,sha256=sCtg4Hnq9Y7amYjlQsdvTHXH8cKSooipvcXu_1Iyb2k,4885
|
179
179
|
ultralytics/nn/__init__.py,sha256=rjociYD9lo_K-d-1s6TbdWklPLjTcEHk7OIlRDJstIE,615
|
180
|
-
ultralytics/nn/autobackend.py,sha256=
|
180
|
+
ultralytics/nn/autobackend.py,sha256=WyvIsfba4eN4tAtvuuy089-UDLpsvXfO4fTBdPnUPP8,37379
|
181
181
|
ultralytics/nn/tasks.py,sha256=rKyTShwk1RtWBnbHObcSamxXoCUiwzl0K5QFYaw56Hw,49030
|
182
182
|
ultralytics/nn/modules/__init__.py,sha256=pVV5SSu6ktOusdVFr1kHK_WOkVLjCLO2W5XaLH-NF8w,2737
|
183
183
|
ultralytics/nn/modules/activation.py,sha256=oRkhMdqlNpIxQb35pTSUeHV-h0VyLl96GOqvIZ4OvT8,923
|
@@ -212,17 +212,17 @@ ultralytics/trackers/utils/matching.py,sha256=64PKHGoETwXhuZ9udE217hbjJHygLOPaYA
|
|
212
212
|
ultralytics/utils/__init__.py,sha256=7_Kh3l2IBHLE_cM1BXPHgjasa-sRIpqnf_eicQw2RTk,49908
|
213
213
|
ultralytics/utils/autobatch.py,sha256=zc81HlAMArPASEbExty0E_zpITF8PVwin7w-xBFFZ5w,5048
|
214
214
|
ultralytics/utils/benchmarks.py,sha256=enf8emMQ7OcZa6RokvwrNm4ZfW-XS7SBKp57staqGRM,26751
|
215
|
-
ultralytics/utils/checks.py,sha256=
|
215
|
+
ultralytics/utils/checks.py,sha256=WIQPdWtD2NhdKgrHTnqun6FDr73l4ejp0nsLtya_iOs,31038
|
216
216
|
ultralytics/utils/dist.py,sha256=fuiJQEnyyL-SighlI3hUlZPaaSreUl4Q39snF6OhQtI,2386
|
217
217
|
ultralytics/utils/downloads.py,sha256=5B1uwRr6Urb5ShZAAni5_tq9a-3o0fSAH3xNCULktFY,22100
|
218
218
|
ultralytics/utils/errors.py,sha256=sXKDEd8ws3L-yIfG_-P_h86axbm37sJNha7kFBJbQMQ,844
|
219
219
|
ultralytics/utils/files.py,sha256=c85NRofjGPMcpkV-yUo1Cwk8ZVquBGCEKlzbSVtXkQA,8252
|
220
220
|
ultralytics/utils/instance.py,sha256=z1oyyvz7wnCSUW_bvi0TbgAL0VxJtAWWXV9KWCoyJ_k,16887
|
221
221
|
ultralytics/utils/loss.py,sha256=paRY8K7R4pcUGJfApVzZx-m_iFzzMbHm5GgiaixfDuU,34179
|
222
|
-
ultralytics/utils/metrics.py,sha256=
|
223
|
-
ultralytics/utils/ops.py,sha256=
|
222
|
+
ultralytics/utils/metrics.py,sha256=6VfTtPzPppuX2RfXr84GoI_ABPfHPhXbbMKkH2HvUVc,53672
|
223
|
+
ultralytics/utils/ops.py,sha256=e7HNeufSrOnaHaie8w-QHNnyaClcHuiGZvr3CXRABsU,34621
|
224
224
|
ultralytics/utils/patches.py,sha256=ARR89dP4YKq7Dd3g2eU-ukbnc2lo3BELukL_1c_d854,3298
|
225
|
-
ultralytics/utils/plotting.py,sha256=
|
225
|
+
ultralytics/utils/plotting.py,sha256=Q-Usm14v8SG-6wya8EKr0WlpWqtZzQy9nlUzxjES9Rc,64089
|
226
226
|
ultralytics/utils/tal.py,sha256=DO-c006HEI62pcrNRpmt4lpqJPC5yu3veRDOvUuExno,18498
|
227
227
|
ultralytics/utils/torch_utils.py,sha256=h1aWTJ71NX5Q_L5ZAj-4Yljht5S_6YEhE2XUm2Apt2M,34039
|
228
228
|
ultralytics/utils/triton.py,sha256=2L1_rZ8xCJEjexRVj75g9YU-u4tQln_DJ5N1Yr_0bSs,4071
|
@@ -238,9 +238,9 @@ ultralytics/utils/callbacks/neptune.py,sha256=waZ_bRu0-qBKujTLuqonC2gx2DkgBuVnfq
|
|
238
238
|
ultralytics/utils/callbacks/raytune.py,sha256=A_NVWjyPNf2m6iB-mbW7SMpyqM9QBvpbPa-MCMFMtdk,727
|
239
239
|
ultralytics/utils/callbacks/tensorboard.py,sha256=JHOEVlNQ5dYJPd4Z-EvqbXowuK5uA0p8wPgyyaIUQs0,4194
|
240
240
|
ultralytics/utils/callbacks/wb.py,sha256=ayhT2y62AcSOacnawshATU0rWrlSFQ77mrGgBdRl3W4,7086
|
241
|
-
ultralytics-8.3.
|
242
|
-
ultralytics-8.3.
|
243
|
-
ultralytics-8.3.
|
244
|
-
ultralytics-8.3.
|
245
|
-
ultralytics-8.3.
|
246
|
-
ultralytics-8.3.
|
241
|
+
ultralytics-8.3.81.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
|
242
|
+
ultralytics-8.3.81.dist-info/METADATA,sha256=Y30dxhRo-PW9WwcRADI1xxLzjbN2j8ltuNltC_C2Xmo,35168
|
243
|
+
ultralytics-8.3.81.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
244
|
+
ultralytics-8.3.81.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
|
245
|
+
ultralytics-8.3.81.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
|
246
|
+
ultralytics-8.3.81.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|