dgenerate-ultralytics-headless 8.3.194__py3-none-any.whl → 8.3.195__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 (97) hide show
  1. {dgenerate_ultralytics_headless-8.3.194.dist-info → dgenerate_ultralytics_headless-8.3.195.dist-info}/METADATA +1 -2
  2. {dgenerate_ultralytics_headless-8.3.194.dist-info → dgenerate_ultralytics_headless-8.3.195.dist-info}/RECORD +97 -96
  3. tests/test_python.py +1 -1
  4. ultralytics/__init__.py +1 -1
  5. ultralytics/cfg/__init__.py +8 -8
  6. ultralytics/data/annotator.py +1 -1
  7. ultralytics/data/augment.py +75 -75
  8. ultralytics/data/base.py +12 -12
  9. ultralytics/data/converter.py +4 -4
  10. ultralytics/data/dataset.py +7 -7
  11. ultralytics/data/loaders.py +15 -15
  12. ultralytics/data/split_dota.py +10 -10
  13. ultralytics/data/utils.py +12 -12
  14. ultralytics/engine/model.py +13 -13
  15. ultralytics/engine/predictor.py +13 -13
  16. ultralytics/engine/results.py +21 -21
  17. ultralytics/hub/google/__init__.py +2 -2
  18. ultralytics/hub/session.py +7 -7
  19. ultralytics/models/fastsam/model.py +5 -5
  20. ultralytics/models/fastsam/predict.py +11 -11
  21. ultralytics/models/nas/model.py +1 -1
  22. ultralytics/models/rtdetr/predict.py +2 -2
  23. ultralytics/models/rtdetr/val.py +4 -4
  24. ultralytics/models/sam/amg.py +6 -6
  25. ultralytics/models/sam/build.py +9 -9
  26. ultralytics/models/sam/model.py +7 -7
  27. ultralytics/models/sam/modules/blocks.py +6 -6
  28. ultralytics/models/sam/modules/decoders.py +1 -1
  29. ultralytics/models/sam/modules/encoders.py +27 -27
  30. ultralytics/models/sam/modules/sam.py +4 -4
  31. ultralytics/models/sam/modules/tiny_encoder.py +18 -18
  32. ultralytics/models/sam/modules/utils.py +8 -8
  33. ultralytics/models/sam/predict.py +63 -63
  34. ultralytics/models/utils/loss.py +22 -22
  35. ultralytics/models/utils/ops.py +8 -8
  36. ultralytics/models/yolo/classify/predict.py +2 -2
  37. ultralytics/models/yolo/classify/train.py +8 -8
  38. ultralytics/models/yolo/classify/val.py +4 -4
  39. ultralytics/models/yolo/detect/predict.py +3 -3
  40. ultralytics/models/yolo/detect/train.py +6 -6
  41. ultralytics/models/yolo/detect/val.py +32 -32
  42. ultralytics/models/yolo/model.py +6 -6
  43. ultralytics/models/yolo/obb/train.py +1 -1
  44. ultralytics/models/yolo/obb/val.py +13 -13
  45. ultralytics/models/yolo/pose/val.py +11 -11
  46. ultralytics/models/yolo/segment/predict.py +4 -4
  47. ultralytics/models/yolo/segment/train.py +1 -1
  48. ultralytics/models/yolo/segment/val.py +14 -14
  49. ultralytics/models/yolo/world/train.py +9 -9
  50. ultralytics/models/yolo/world/train_world.py +1 -1
  51. ultralytics/models/yolo/yoloe/predict.py +4 -4
  52. ultralytics/models/yolo/yoloe/train.py +4 -4
  53. ultralytics/nn/autobackend.py +2 -2
  54. ultralytics/nn/modules/block.py +6 -6
  55. ultralytics/nn/modules/conv.py +2 -2
  56. ultralytics/nn/modules/head.py +4 -4
  57. ultralytics/nn/tasks.py +13 -13
  58. ultralytics/nn/text_model.py +3 -3
  59. ultralytics/solutions/ai_gym.py +2 -2
  60. ultralytics/solutions/analytics.py +3 -3
  61. ultralytics/solutions/config.py +5 -5
  62. ultralytics/solutions/distance_calculation.py +2 -2
  63. ultralytics/solutions/heatmap.py +1 -1
  64. ultralytics/solutions/instance_segmentation.py +4 -4
  65. ultralytics/solutions/object_counter.py +4 -4
  66. ultralytics/solutions/parking_management.py +7 -7
  67. ultralytics/solutions/queue_management.py +3 -3
  68. ultralytics/solutions/region_counter.py +4 -4
  69. ultralytics/solutions/similarity_search.py +2 -2
  70. ultralytics/solutions/solutions.py +48 -48
  71. ultralytics/solutions/streamlit_inference.py +1 -1
  72. ultralytics/solutions/trackzone.py +4 -4
  73. ultralytics/solutions/vision_eye.py +1 -1
  74. ultralytics/trackers/byte_tracker.py +11 -11
  75. ultralytics/trackers/utils/gmc.py +3 -3
  76. ultralytics/trackers/utils/matching.py +5 -5
  77. ultralytics/utils/autodevice.py +2 -2
  78. ultralytics/utils/benchmarks.py +10 -10
  79. ultralytics/utils/callbacks/clearml.py +1 -1
  80. ultralytics/utils/callbacks/comet.py +5 -5
  81. ultralytics/utils/checks.py +5 -5
  82. ultralytics/utils/cpu.py +90 -0
  83. ultralytics/utils/dist.py +1 -1
  84. ultralytics/utils/downloads.py +2 -2
  85. ultralytics/utils/export.py +5 -5
  86. ultralytics/utils/instance.py +2 -2
  87. ultralytics/utils/metrics.py +35 -35
  88. ultralytics/utils/nms.py +4 -4
  89. ultralytics/utils/ops.py +1 -1
  90. ultralytics/utils/patches.py +2 -2
  91. ultralytics/utils/plotting.py +9 -9
  92. ultralytics/utils/torch_utils.py +2 -6
  93. ultralytics/utils/triton.py +5 -5
  94. {dgenerate_ultralytics_headless-8.3.194.dist-info → dgenerate_ultralytics_headless-8.3.195.dist-info}/WHEEL +0 -0
  95. {dgenerate_ultralytics_headless-8.3.194.dist-info → dgenerate_ultralytics_headless-8.3.195.dist-info}/entry_points.txt +0 -0
  96. {dgenerate_ultralytics_headless-8.3.194.dist-info → dgenerate_ultralytics_headless-8.3.195.dist-info}/licenses/LICENSE +0 -0
  97. {dgenerate_ultralytics_headless-8.3.194.dist-info → dgenerate_ultralytics_headless-8.3.195.dist-info}/top_level.txt +0 -0
ultralytics/utils/dist.py CHANGED
@@ -85,7 +85,7 @@ def generate_ddp_command(world_size: int, trainer):
85
85
  trainer (ultralytics.engine.trainer.BaseTrainer): The trainer containing configuration for distributed training.
86
86
 
87
87
  Returns:
88
- cmd (List[str]): The command to execute for distributed training.
88
+ cmd (list[str]): The command to execute for distributed training.
89
89
  file (str): Path to the temporary file created for DDP training.
90
90
  """
91
91
  import __main__ # noqa local import to avoid https://github.com/Lightning-AI/pytorch-lightning/issues/15218
@@ -411,7 +411,7 @@ def get_github_assets(
411
411
 
412
412
  Returns:
413
413
  tag (str): The release tag.
414
- assets (List[str]): A list of asset names.
414
+ assets (list[str]): A list of asset names.
415
415
 
416
416
  Examples:
417
417
  >>> tag, assets = get_github_assets(repo="ultralytics/assets", version="latest")
@@ -503,7 +503,7 @@ def download(
503
503
  Supports concurrent downloads if multiple threads are specified.
504
504
 
505
505
  Args:
506
- url (str | List[str]): The URL or list of URLs of the files to be downloaded.
506
+ url (str | list[str]): The URL or list of URLs of the files to be downloaded.
507
507
  dir (Path, optional): The directory where the files will be saved.
508
508
  unzip (bool, optional): Flag to unzip the files after downloading.
509
509
  delete (bool, optional): Flag to delete the zip files after extraction.
@@ -27,9 +27,9 @@ def export_onnx(
27
27
  im (torch.Tensor): Example input tensor for the model.
28
28
  onnx_file (str): Path to save the exported ONNX file.
29
29
  opset (int): ONNX opset version to use for export.
30
- input_names (List[str]): List of input tensor names.
31
- output_names (List[str]): List of output tensor names.
32
- dynamic (bool | Dict, optional): Whether to enable dynamic axes.
30
+ input_names (list[str]): List of input tensor names.
31
+ output_names (list[str]): List of output tensor names.
32
+ dynamic (bool | dict, optional): Whether to enable dynamic axes.
33
33
 
34
34
  Notes:
35
35
  Setting `do_constant_folding=True` may cause issues with DNN inference for torch>=1.12.
@@ -71,10 +71,10 @@ def export_engine(
71
71
  half (bool, optional): Enable FP16 precision.
72
72
  int8 (bool, optional): Enable INT8 precision.
73
73
  dynamic (bool, optional): Enable dynamic input shapes.
74
- shape (Tuple[int, int, int, int], optional): Input shape (batch, channels, height, width).
74
+ shape (tuple[int, int, int, int], optional): Input shape (batch, channels, height, width).
75
75
  dla (int, optional): DLA core to use (Jetson devices only).
76
76
  dataset (ultralytics.data.build.InfiniteDataLoader, optional): Dataset for INT8 calibration.
77
- metadata (Dict, optional): Metadata to include in the engine file.
77
+ metadata (dict, optional): Metadata to include in the engine file.
78
78
  verbose (bool, optional): Enable verbose logging.
79
79
  prefix (str, optional): Prefix for log messages.
80
80
 
@@ -146,7 +146,7 @@ class Bboxes:
146
146
  Concatenate a list of Bboxes objects into a single Bboxes object.
147
147
 
148
148
  Args:
149
- boxes_list (List[Bboxes]): A list of Bboxes objects to concatenate.
149
+ boxes_list (list[Bboxes]): A list of Bboxes objects to concatenate.
150
150
  axis (int, optional): The axis along which to concatenate the bounding boxes.
151
151
 
152
152
  Returns:
@@ -458,7 +458,7 @@ class Instances:
458
458
  Concatenate a list of Instances objects into a single Instances object.
459
459
 
460
460
  Args:
461
- instances_list (List[Instances]): A list of Instances objects to concatenate.
461
+ instances_list (list[Instances]): A list of Instances objects to concatenate.
462
462
  axis (int, optional): The axis along which the arrays will be concatenated.
463
463
 
464
464
  Returns:
@@ -318,7 +318,7 @@ class ConfusionMatrix(DataExportMixin):
318
318
  task (str): The type of task, either 'detect' or 'classify'.
319
319
  matrix (np.ndarray): The confusion matrix, with dimensions depending on the task.
320
320
  nc (int): The number of category.
321
- names (List[str]): The names of the classes, used as labels on the plot.
321
+ names (list[str]): The names of the classes, used as labels on the plot.
322
322
  matches (dict): Contains the indices of ground truths and predictions categorized into TP, FP and FN.
323
323
  """
324
324
 
@@ -327,7 +327,7 @@ class ConfusionMatrix(DataExportMixin):
327
327
  Initialize a ConfusionMatrix instance.
328
328
 
329
329
  Args:
330
- names (Dict[int, str], optional): Names of classes, used as labels on the plot.
330
+ names (dict[int, str], optional): Names of classes, used as labels on the plot.
331
331
  task (str, optional): Type of task, either 'detect' or 'classify'.
332
332
  save_matches (bool, optional): Save the indices of GTs, TPs, FPs, FNs for visualization.
333
333
  """
@@ -346,7 +346,7 @@ class ConfusionMatrix(DataExportMixin):
346
346
 
347
347
  Args:
348
348
  mtype (str): Match type identifier ('TP', 'FP', 'FN' or 'GT').
349
- batch (Dict[str, Any]): Batch data containing detection results with keys
349
+ batch (dict[str, Any]): Batch data containing detection results with keys
350
350
  like 'bboxes', 'cls', 'conf', 'keypoints', 'masks'.
351
351
  idx (int): Index of the specific detection to append from the batch.
352
352
 
@@ -368,8 +368,8 @@ class ConfusionMatrix(DataExportMixin):
368
368
  Update confusion matrix for classification task.
369
369
 
370
370
  Args:
371
- preds (List[N, min(nc,5)]): Predicted class labels.
372
- targets (List[N, 1]): Ground truth class labels.
371
+ preds (list[N, min(nc,5)]): Predicted class labels.
372
+ targets (list[N, 1]): Ground truth class labels.
373
373
  """
374
374
  preds, targets = torch.cat(preds)[:, 0], torch.cat(targets)
375
375
  for p, t in zip(preds.cpu().numpy(), targets.cpu().numpy()):
@@ -386,10 +386,10 @@ class ConfusionMatrix(DataExportMixin):
386
386
  Update confusion matrix for object detection task.
387
387
 
388
388
  Args:
389
- detections (Dict[str, torch.Tensor]): Dictionary containing detected bounding boxes and their associated information.
389
+ detections (dict[str, torch.Tensor]): Dictionary containing detected bounding boxes and their associated information.
390
390
  Should contain 'cls', 'conf', and 'bboxes' keys, where 'bboxes' can be
391
391
  Array[N, 4] for regular boxes or Array[N, 5] for OBB with angle.
392
- batch (Dict[str, Any]): Batch dictionary containing ground truth data with 'bboxes' (Array[M, 4]| Array[M, 5]) and
392
+ batch (dict[str, Any]): Batch dictionary containing ground truth data with 'bboxes' (Array[M, 4]| Array[M, 5]) and
393
393
  'cls' (Array[M]) keys, where M is the number of ground truth objects.
394
394
  conf (float, optional): Confidence threshold for detections.
395
395
  iou_thres (float, optional): IoU threshold for matching detections to ground truth.
@@ -599,7 +599,7 @@ class ConfusionMatrix(DataExportMixin):
599
599
  decimals (int): Number of decimal places to round the output values to.
600
600
 
601
601
  Returns:
602
- (List[Dict[str, float]]): A list of dictionaries, each representing one predicted class with corresponding values for all actual classes.
602
+ (list[dict[str, float]]): A list of dictionaries, each representing one predicted class with corresponding values for all actual classes.
603
603
 
604
604
  Examples:
605
605
  >>> results = model.val(data="coco8.yaml", plots=True)
@@ -651,7 +651,7 @@ def plot_pr_curve(
651
651
  py (np.ndarray): Y values for the PR curve.
652
652
  ap (np.ndarray): Average precision values.
653
653
  save_dir (Path, optional): Path to save the plot.
654
- names (Dict[int, str], optional): Dictionary mapping class indices to class names.
654
+ names (dict[int, str], optional): Dictionary mapping class indices to class names.
655
655
  on_plot (callable, optional): Function to call after plot is saved.
656
656
  """
657
657
  import matplotlib.pyplot as plt # scope for faster 'import ultralytics'
@@ -695,7 +695,7 @@ def plot_mc_curve(
695
695
  px (np.ndarray): X values for the metric-confidence curve.
696
696
  py (np.ndarray): Y values for the metric-confidence curve.
697
697
  save_dir (Path, optional): Path to save the plot.
698
- names (Dict[int, str], optional): Dictionary mapping class indices to class names.
698
+ names (dict[int, str], optional): Dictionary mapping class indices to class names.
699
699
  xlabel (str, optional): X-axis label.
700
700
  ylabel (str, optional): Y-axis label.
701
701
  on_plot (callable, optional): Function to call after plot is saved.
@@ -780,7 +780,7 @@ def ap_per_class(
780
780
  plot (bool, optional): Whether to plot PR curves or not.
781
781
  on_plot (callable, optional): A callback to pass plots path and data when they are rendered.
782
782
  save_dir (Path, optional): Directory to save the PR curves.
783
- names (Dict[int, str], optional): Dictionary of class names to plot PR curves.
783
+ names (dict[int, str], optional): Dictionary of class names to plot PR curves.
784
784
  eps (float, optional): A small value to avoid division by zero.
785
785
  prefix (str, optional): A prefix string for saving the plot files.
786
786
 
@@ -1034,11 +1034,11 @@ class DetMetrics(SimpleClass, DataExportMixin):
1034
1034
  Utility class for computing detection metrics such as precision, recall, and mean average precision (mAP).
1035
1035
 
1036
1036
  Attributes:
1037
- names (Dict[int, str]): A dictionary of class names.
1037
+ names (dict[int, str]): A dictionary of class names.
1038
1038
  box (Metric): An instance of the Metric class for storing detection results.
1039
- speed (Dict[str, float]): A dictionary for storing execution times of different parts of the detection process.
1039
+ speed (dict[str, float]): A dictionary for storing execution times of different parts of the detection process.
1040
1040
  task (str): The task type, set to 'detect'.
1041
- stats (Dict[str, List]): A dictionary containing lists for true positives, confidence scores, predicted classes, target classes, and target images.
1041
+ stats (dict[str, list]): A dictionary containing lists for true positives, confidence scores, predicted classes, target classes, and target images.
1042
1042
  nt_per_class: Number of targets per class.
1043
1043
  nt_per_image: Number of targets per image.
1044
1044
 
@@ -1063,7 +1063,7 @@ class DetMetrics(SimpleClass, DataExportMixin):
1063
1063
  Initialize a DetMetrics instance with a save directory, plot flag, and class names.
1064
1064
 
1065
1065
  Args:
1066
- names (Dict[int, str], optional): Dictionary of class names.
1066
+ names (dict[int, str], optional): Dictionary of class names.
1067
1067
  """
1068
1068
  self.names = names
1069
1069
  self.box = Metric()
@@ -1078,7 +1078,7 @@ class DetMetrics(SimpleClass, DataExportMixin):
1078
1078
  Update statistics by appending new values to existing stat collections.
1079
1079
 
1080
1080
  Args:
1081
- stat (Dict[str, any]): Dictionary containing new statistical values to append.
1081
+ stat (dict[str, any]): Dictionary containing new statistical values to append.
1082
1082
  Keys should match existing keys in self.stats.
1083
1083
  """
1084
1084
  for k in self.stats.keys():
@@ -1094,7 +1094,7 @@ class DetMetrics(SimpleClass, DataExportMixin):
1094
1094
  on_plot (callable, optional): Function to call after plots are generated. Defaults to None.
1095
1095
 
1096
1096
  Returns:
1097
- (Dict[str, np.ndarray]): Dictionary containing concatenated statistics arrays.
1097
+ (dict[str, np.ndarray]): Dictionary containing concatenated statistics arrays.
1098
1098
  """
1099
1099
  stats = {k: np.concatenate(v, 0) for k, v in self.stats.items()} # to numpy
1100
1100
  if not stats:
@@ -1176,7 +1176,7 @@ class DetMetrics(SimpleClass, DataExportMixin):
1176
1176
  decimals (int): Number of decimal places to round the metrics values to.
1177
1177
 
1178
1178
  Returns:
1179
- (List[Dict[str, Any]]): A list of dictionaries, each representing one class with corresponding metric values.
1179
+ (list[dict[str, Any]]): A list of dictionaries, each representing one class with corresponding metric values.
1180
1180
 
1181
1181
  Examples:
1182
1182
  >>> results = model.val(data="coco8.yaml")
@@ -1206,12 +1206,12 @@ class SegmentMetrics(DetMetrics):
1206
1206
  Calculate and aggregate detection and segmentation metrics over a given set of classes.
1207
1207
 
1208
1208
  Attributes:
1209
- names (Dict[int, str]): Dictionary of class names.
1209
+ names (dict[int, str]): Dictionary of class names.
1210
1210
  box (Metric): An instance of the Metric class for storing detection results.
1211
1211
  seg (Metric): An instance of the Metric class to calculate mask segmentation metrics.
1212
- speed (Dict[str, float]): A dictionary for storing execution times of different parts of the detection process.
1212
+ speed (dict[str, float]): A dictionary for storing execution times of different parts of the detection process.
1213
1213
  task (str): The task type, set to 'segment'.
1214
- stats (Dict[str, List]): A dictionary containing lists for true positives, confidence scores, predicted classes, target classes, and target images.
1214
+ stats (dict[str, list]): A dictionary containing lists for true positives, confidence scores, predicted classes, target classes, and target images.
1215
1215
  nt_per_class: Number of targets per class.
1216
1216
  nt_per_image: Number of targets per image.
1217
1217
 
@@ -1232,7 +1232,7 @@ class SegmentMetrics(DetMetrics):
1232
1232
  Initialize a SegmentMetrics instance with a save directory, plot flag, and class names.
1233
1233
 
1234
1234
  Args:
1235
- names (Dict[int, str], optional): Dictionary of class names.
1235
+ names (dict[int, str], optional): Dictionary of class names.
1236
1236
  """
1237
1237
  DetMetrics.__init__(self, names)
1238
1238
  self.seg = Metric()
@@ -1249,7 +1249,7 @@ class SegmentMetrics(DetMetrics):
1249
1249
  on_plot (callable, optional): Function to call after plots are generated. Defaults to None.
1250
1250
 
1251
1251
  Returns:
1252
- (Dict[str, np.ndarray]): Dictionary containing concatenated statistics arrays.
1252
+ (dict[str, np.ndarray]): Dictionary containing concatenated statistics arrays.
1253
1253
  """
1254
1254
  stats = DetMetrics.process(self, save_dir, plot, on_plot=on_plot) # process box stats
1255
1255
  results_mask = ap_per_class(
@@ -1320,7 +1320,7 @@ class SegmentMetrics(DetMetrics):
1320
1320
  decimals (int): Number of decimal places to round the metrics values to.
1321
1321
 
1322
1322
  Returns:
1323
- (List[Dict[str, Any]]): A list of dictionaries, each representing one class with corresponding metric values.
1323
+ (list[dict[str, Any]]): A list of dictionaries, each representing one class with corresponding metric values.
1324
1324
 
1325
1325
  Examples:
1326
1326
  >>> results = model.val(data="coco8-seg.yaml")
@@ -1343,12 +1343,12 @@ class PoseMetrics(DetMetrics):
1343
1343
  Calculate and aggregate detection and pose metrics over a given set of classes.
1344
1344
 
1345
1345
  Attributes:
1346
- names (Dict[int, str]): Dictionary of class names.
1346
+ names (dict[int, str]): Dictionary of class names.
1347
1347
  pose (Metric): An instance of the Metric class to calculate pose metrics.
1348
1348
  box (Metric): An instance of the Metric class for storing detection results.
1349
- speed (Dict[str, float]): A dictionary for storing execution times of different parts of the detection process.
1349
+ speed (dict[str, float]): A dictionary for storing execution times of different parts of the detection process.
1350
1350
  task (str): The task type, set to 'pose'.
1351
- stats (Dict[str, List]): A dictionary containing lists for true positives, confidence scores, predicted classes, target classes, and target images.
1351
+ stats (dict[str, list]): A dictionary containing lists for true positives, confidence scores, predicted classes, target classes, and target images.
1352
1352
  nt_per_class: Number of targets per class.
1353
1353
  nt_per_image: Number of targets per image.
1354
1354
 
@@ -1369,7 +1369,7 @@ class PoseMetrics(DetMetrics):
1369
1369
  Initialize the PoseMetrics class with directory path, class names, and plotting options.
1370
1370
 
1371
1371
  Args:
1372
- names (Dict[int, str], optional): Dictionary of class names.
1372
+ names (dict[int, str], optional): Dictionary of class names.
1373
1373
  """
1374
1374
  super().__init__(names)
1375
1375
  self.pose = Metric()
@@ -1386,7 +1386,7 @@ class PoseMetrics(DetMetrics):
1386
1386
  on_plot (callable, optional): Function to call after plots are generated.
1387
1387
 
1388
1388
  Returns:
1389
- (Dict[str, np.ndarray]): Dictionary containing concatenated statistics arrays.
1389
+ (dict[str, np.ndarray]): Dictionary containing concatenated statistics arrays.
1390
1390
  """
1391
1391
  stats = DetMetrics.process(self, save_dir, plot, on_plot=on_plot) # process box stats
1392
1392
  results_pose = ap_per_class(
@@ -1461,7 +1461,7 @@ class PoseMetrics(DetMetrics):
1461
1461
  decimals (int): Number of decimal places to round the metrics values to.
1462
1462
 
1463
1463
  Returns:
1464
- (List[Dict[str, Any]]): A list of dictionaries, each representing one class with corresponding metric values.
1464
+ (list[dict[str, Any]]): A list of dictionaries, each representing one class with corresponding metric values.
1465
1465
 
1466
1466
  Examples:
1467
1467
  >>> results = model.val(data="coco8-pose.yaml")
@@ -1553,7 +1553,7 @@ class ClassifyMetrics(SimpleClass, DataExportMixin):
1553
1553
  decimals (int): Number of decimal places to round the metrics values to.
1554
1554
 
1555
1555
  Returns:
1556
- (List[Dict[str, float]]): A list with one dictionary containing Top-1 and Top-5 classification accuracy.
1556
+ (list[dict[str, float]]): A list with one dictionary containing Top-1 and Top-5 classification accuracy.
1557
1557
 
1558
1558
  Examples:
1559
1559
  >>> results = model.val(data="imagenet10")
@@ -1568,11 +1568,11 @@ class OBBMetrics(DetMetrics):
1568
1568
  Metrics for evaluating oriented bounding box (OBB) detection.
1569
1569
 
1570
1570
  Attributes:
1571
- names (Dict[int, str]): Dictionary of class names.
1571
+ names (dict[int, str]): Dictionary of class names.
1572
1572
  box (Metric): An instance of the Metric class for storing detection results.
1573
- speed (Dict[str, float]): A dictionary for storing execution times of different parts of the detection process.
1573
+ speed (dict[str, float]): A dictionary for storing execution times of different parts of the detection process.
1574
1574
  task (str): The task type, set to 'obb'.
1575
- stats (Dict[str, List]): A dictionary containing lists for true positives, confidence scores, predicted classes, target classes, and target images.
1575
+ stats (dict[str, list]): A dictionary containing lists for true positives, confidence scores, predicted classes, target classes, and target images.
1576
1576
  nt_per_class: Number of targets per class.
1577
1577
  nt_per_image: Number of targets per image.
1578
1578
 
@@ -1585,7 +1585,7 @@ class OBBMetrics(DetMetrics):
1585
1585
  Initialize an OBBMetrics instance with directory, plotting, and class names.
1586
1586
 
1587
1587
  Args:
1588
- names (Dict[int, str], optional): Dictionary of class names.
1588
+ names (dict[int, str], optional): Dictionary of class names.
1589
1589
  """
1590
1590
  DetMetrics.__init__(self, names)
1591
1591
  # TODO: probably remove task as well
ultralytics/utils/nms.py CHANGED
@@ -38,10 +38,10 @@ def non_max_suppression(
38
38
  containing boxes, classes, and optional masks.
39
39
  conf_thres (float): Confidence threshold for filtering detections. Valid values are between 0.0 and 1.0.
40
40
  iou_thres (float): IoU threshold for NMS filtering. Valid values are between 0.0 and 1.0.
41
- classes (List[int], optional): List of class indices to consider. If None, all classes are considered.
41
+ classes (list[int], optional): List of class indices to consider. If None, all classes are considered.
42
42
  agnostic (bool): Whether to perform class-agnostic NMS.
43
43
  multi_label (bool): Whether each box can have multiple labels.
44
- labels (List[List[Union[int, float, torch.Tensor]]]): A priori labels for each image.
44
+ labels (list[list[Union[int, float, torch.Tensor]]]): A priori labels for each image.
45
45
  max_det (int): Maximum number of detections to keep per image.
46
46
  nc (int): Number of classes. Indices after this are considered masks.
47
47
  max_time_img (float): Maximum time in seconds for processing one image.
@@ -52,9 +52,9 @@ def non_max_suppression(
52
52
  return_idxs (bool): Whether to return the indices of kept detections.
53
53
 
54
54
  Returns:
55
- output (List[torch.Tensor]): List of detections per image with shape (num_boxes, 6 + num_masks)
55
+ output (list[torch.Tensor]): List of detections per image with shape (num_boxes, 6 + num_masks)
56
56
  containing (x1, y1, x2, y2, confidence, class, mask1, mask2, ...).
57
- keepi (List[torch.Tensor]): Indices of kept detections if return_idxs=True.
57
+ keepi (list[torch.Tensor]): Indices of kept detections if return_idxs=True.
58
58
  """
59
59
  # Checks
60
60
  assert 0 <= conf_thres <= 1, f"Invalid Confidence threshold {conf_thres}, valid values are between 0.0 and 1.0"
ultralytics/utils/ops.py CHANGED
@@ -135,7 +135,7 @@ def scale_boxes(img1_shape, boxes, img0_shape, ratio_pad=None, padding: bool = T
135
135
  boxes[..., 2] -= pad_x # x padding
136
136
  boxes[..., 3] -= pad_y # y padding
137
137
  boxes[..., :4] /= gain
138
- return clip_boxes(boxes, img0_shape)
138
+ return boxes if xywh else clip_boxes(boxes, img0_shape)
139
139
 
140
140
 
141
141
  def make_divisible(x: int, divisor):
@@ -51,7 +51,7 @@ def imwrite(filename: str, img: np.ndarray, params: list[int] | None = None) ->
51
51
  Args:
52
52
  filename (str): Path to the file to write.
53
53
  img (np.ndarray): Image to write.
54
- params (List[int], optional): Additional parameters for image encoding.
54
+ params (list[int], optional): Additional parameters for image encoding.
55
55
 
56
56
  Returns:
57
57
  (bool): True if the file was written successfully, False otherwise.
@@ -172,7 +172,7 @@ def override_configs(args, overrides: dict[str, Any] | None = None):
172
172
 
173
173
  Args:
174
174
  args (IterableSimpleNamespace): Original configuration arguments.
175
- overrides (Dict[str, Any]): Dictionary of overrides to apply.
175
+ overrides (dict[str, Any]): Dictionary of overrides to apply.
176
176
 
177
177
  Yields:
178
178
  (IterableSimpleNamespace): Configuration arguments with overrides applied.
@@ -26,7 +26,7 @@ class Colors:
26
26
  RGB values and accessing predefined color schemes for object detection and pose estimation.
27
27
 
28
28
  Attributes:
29
- palette (List[tuple]): List of RGB color tuples for general use.
29
+ palette (list[tuple]): List of RGB color tuples for general use.
30
30
  n (int): The number of colors in the palette.
31
31
  pose_palette (np.ndarray): A specific color palette array for pose estimation with dtype np.uint8.
32
32
 
@@ -176,9 +176,9 @@ class Annotator:
176
176
  pil (bool): Whether to use PIL or cv2 for drawing annotations.
177
177
  font (ImageFont.truetype | ImageFont.load_default): Font used for text annotations.
178
178
  lw (float): Line width for drawing.
179
- skeleton (List[List[int]]): Skeleton structure for keypoints.
180
- limb_color (List[int]): Color palette for limbs.
181
- kpt_color (List[int]): Color palette for keypoints.
179
+ skeleton (list[list[int]]): Skeleton structure for keypoints.
180
+ limb_color (list[int]): Color palette for limbs.
181
+ kpt_color (list[int]): Color palette for keypoints.
182
182
  dark_colors (set): Set of colors considered dark for text contrast.
183
183
  light_colors (set): Set of colors considered light for text contrast.
184
184
 
@@ -369,7 +369,7 @@ class Annotator:
369
369
 
370
370
  Args:
371
371
  masks (torch.Tensor | np.ndarray): Predicted masks with shape: [n, h, w]
372
- colors (List[List[int]]): Colors for predicted masks, [[r, g, b] * n]
372
+ colors (list[list[int]]): Colors for predicted masks, [[r, g, b] * n]
373
373
  im_gpu (torch.Tensor | None): Image is in cuda, shape: [3, h, w], range: [0, 1]
374
374
  alpha (float, optional): Mask transparency: 0.0 fully transparent, 1.0 opaque.
375
375
  retina_masks (bool, optional): Whether to use high resolution masks or not.
@@ -484,7 +484,7 @@ class Annotator:
484
484
  Add text to an image using PIL or cv2.
485
485
 
486
486
  Args:
487
- xy (List[int]): Top-left coordinates for text placement.
487
+ xy (list[int]): Top-left coordinates for text placement.
488
488
  text (str): Text to be drawn.
489
489
  txt_color (tuple, optional): Text color (R, G, B).
490
490
  anchor (str, optional): Text anchor position ('top' or 'bottom').
@@ -695,11 +695,11 @@ def plot_images(
695
695
  Plot image grid with labels, bounding boxes, masks, and keypoints.
696
696
 
697
697
  Args:
698
- labels (Dict[str, Any]): Dictionary containing detection data with keys like 'cls', 'bboxes', 'conf', 'masks', 'keypoints', 'batch_idx', 'img'.
698
+ labels (dict[str, Any]): Dictionary containing detection data with keys like 'cls', 'bboxes', 'conf', 'masks', 'keypoints', 'batch_idx', 'img'.
699
699
  images (torch.Tensor | np.ndarray]): Batch of images to plot. Shape: (batch_size, channels, height, width).
700
- paths (Optional[List[str]]): List of file paths for each image in the batch.
700
+ paths (Optional[list[str]]): List of file paths for each image in the batch.
701
701
  fname (str): Output filename for the plotted image grid.
702
- names (Optional[Dict[int, str]]): Dictionary mapping class indices to class names.
702
+ names (Optional[dict[int, str]]): Dictionary mapping class indices to class names.
703
703
  on_plot (Optional[Callable]): Optional callback function to be called after saving the plot.
704
704
  max_size (int): Maximum size of the output image grid.
705
705
  max_subplots (int): Maximum number of subplots in the image grid.
@@ -33,6 +33,7 @@ from ultralytics.utils import (
33
33
  colorstr,
34
34
  )
35
35
  from ultralytics.utils.checks import check_version
36
+ from ultralytics.utils.cpu import CPUInfo
36
37
  from ultralytics.utils.patches import torch_load
37
38
 
38
39
  # Version checks (all default to version>=min_version)
@@ -113,12 +114,7 @@ def get_cpu_info():
113
114
 
114
115
  if "cpu_info" not in PERSISTENT_CACHE:
115
116
  try:
116
- import cpuinfo # pip install py-cpuinfo
117
-
118
- k = "brand_raw", "hardware_raw", "arch_string_raw" # keys sorted by preference
119
- info = cpuinfo.get_cpu_info() # info dict
120
- string = info.get(k[0] if k[0] in info else k[1] if k[1] in info else k[2], "unknown")
121
- PERSISTENT_CACHE["cpu_info"] = string.replace("(R)", "").replace("CPU ", "").replace("@ ", "")
117
+ PERSISTENT_CACHE["cpu_info"] = CPUInfo.name()
122
118
  except Exception:
123
119
  pass
124
120
  return PERSISTENT_CACHE.get("cpu_info", "unknown")
@@ -20,10 +20,10 @@ class TritonRemoteModel:
20
20
  triton_client: The Triton client (either HTTP or gRPC).
21
21
  InferInput: The input class for the Triton client.
22
22
  InferRequestedOutput: The output request class for the Triton client.
23
- input_formats (List[str]): The data types of the model inputs.
24
- np_input_formats (List[type]): The numpy data types of the model inputs.
25
- input_names (List[str]): The names of the model inputs.
26
- output_names (List[str]): The names of the model outputs.
23
+ input_formats (list[str]): The data types of the model inputs.
24
+ np_input_formats (list[type]): The numpy data types of the model inputs.
25
+ input_names (list[str]): The names of the model inputs.
26
+ output_names (list[str]): The names of the model outputs.
27
27
  metadata: The metadata associated with the model.
28
28
 
29
29
  Methods:
@@ -96,7 +96,7 @@ class TritonRemoteModel:
96
96
  for the corresponding model input.
97
97
 
98
98
  Returns:
99
- (List[np.ndarray]): Model outputs with the same dtype as the input. Each element in the list
99
+ (list[np.ndarray]): Model outputs with the same dtype as the input. Each element in the list
100
100
  corresponds to one of the model's output tensors.
101
101
 
102
102
  Examples: