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
@@ -30,31 +30,31 @@ class BaseSolution:
30
30
  Polygon: Class for creating polygon geometries from shapely.
31
31
  Point: Class for creating point geometries from shapely.
32
32
  prep: Prepared geometry function from shapely for optimized spatial operations.
33
- CFG (Dict[str, Any]): Configuration dictionary loaded from YAML file and updated with kwargs.
33
+ CFG (dict[str, Any]): Configuration dictionary loaded from YAML file and updated with kwargs.
34
34
  LOGGER: Logger instance for solution-specific logging.
35
35
  annotator: Annotator instance for drawing on images.
36
36
  tracks: YOLO tracking results from the latest inference.
37
37
  track_data: Extracted tracking data (boxes or OBB) from tracks.
38
- boxes (List): Bounding box coordinates from tracking results.
39
- clss (List[int]): Class indices from tracking results.
40
- track_ids (List[int]): Track IDs from tracking results.
41
- confs (List[float]): Confidence scores from tracking results.
38
+ boxes (list): Bounding box coordinates from tracking results.
39
+ clss (list[int]): Class indices from tracking results.
40
+ track_ids (list[int]): Track IDs from tracking results.
41
+ confs (list[float]): Confidence scores from tracking results.
42
42
  track_line: Current track line for storing tracking history.
43
43
  masks: Segmentation masks from tracking results.
44
44
  r_s: Region or line geometry object for spatial operations.
45
45
  frame_no (int): Current frame number for logging purposes.
46
- region (List[Tuple[int, int]]): List of coordinate tuples defining region of interest.
46
+ region (list[tuple[int, int]]): List of coordinate tuples defining region of interest.
47
47
  line_width (int): Width of lines used in visualizations.
48
48
  model (YOLO): Loaded YOLO model instance.
49
- names (Dict[int, str]): Dictionary mapping class indices to class names.
50
- classes (List[int]): List of class indices to track.
49
+ names (dict[int, str]): Dictionary mapping class indices to class names.
50
+ classes (list[int]): List of class indices to track.
51
51
  show_conf (bool): Flag to show confidence scores in annotations.
52
52
  show_labels (bool): Flag to show class labels in annotations.
53
53
  device (str): Device for model inference.
54
- track_add_args (Dict[str, Any]): Additional arguments for tracking configuration.
54
+ track_add_args (dict[str, Any]): Additional arguments for tracking configuration.
55
55
  env_check (bool): Flag indicating whether environment supports image display.
56
56
  track_history (defaultdict): Dictionary storing tracking history for each object.
57
- profilers (Tuple): Profiler instances for performance monitoring.
57
+ profilers (tuple): Profiler instances for performance monitoring.
58
58
 
59
59
  Methods:
60
60
  adjust_box_label: Generate formatted label for bounding box.
@@ -193,7 +193,7 @@ class BaseSolution:
193
193
 
194
194
  Args:
195
195
  track_id (int): The unique identifier for the tracked object.
196
- box (List[float]): The bounding box coordinates of the object in the format [x1, y1, x2, y2].
196
+ box (list[float]): The bounding box coordinates of the object in the format [x1, y1, x2, y2].
197
197
 
198
198
  Examples:
199
199
  >>> solution = BaseSolution()
@@ -333,8 +333,8 @@ class SolutionAnnotator(Annotator):
333
333
  Draw a region or line on the image.
334
334
 
335
335
  Args:
336
- reg_pts (List[Tuple[int, int]], optional): Region points (for line 2 points, for region 4+ points).
337
- color (Tuple[int, int, int]): RGB color value for the region.
336
+ reg_pts (list[tuple[int, int]], optional): Region points (for line 2 points, for region 4+ points).
337
+ color (tuple[int, int, int]): RGB color value for the region.
338
338
  thickness (int): Line thickness for drawing the region.
339
339
  """
340
340
  cv2.polylines(self.im, [np.array(reg_pts, dtype=np.int32)], isClosed=True, color=color, thickness=thickness)
@@ -355,9 +355,9 @@ class SolutionAnnotator(Annotator):
355
355
 
356
356
  Args:
357
357
  label (str): Queue counts label.
358
- points (List[Tuple[int, int]], optional): Region points for center point calculation to display text.
359
- region_color (Tuple[int, int, int]): RGB queue region color.
360
- txt_color (Tuple[int, int, int]): RGB text display color.
358
+ points (list[tuple[int, int]], optional): Region points for center point calculation to display text.
359
+ region_color (tuple[int, int, int]): RGB queue region color.
360
+ txt_color (tuple[int, int, int]): RGB text display color.
361
361
  """
362
362
  x_values = [point[0] for point in points]
363
363
  y_values = [point[1] for point in points]
@@ -402,9 +402,9 @@ class SolutionAnnotator(Annotator):
402
402
 
403
403
  Args:
404
404
  im0 (np.ndarray): Inference image.
405
- text (Dict[str, Any]): Labels dictionary.
406
- txt_color (Tuple[int, int, int]): Display color for text foreground.
407
- bg_color (Tuple[int, int, int]): Display color for text background.
405
+ text (dict[str, Any]): Labels dictionary.
406
+ txt_color (tuple[int, int, int]): Display color for text foreground.
407
+ bg_color (tuple[int, int, int]): Display color for text background.
408
408
  margin (int): Gap between text and rectangle for better display.
409
409
  """
410
410
  horizontal_gap = int(im0.shape[1] * 0.02)
@@ -432,9 +432,9 @@ class SolutionAnnotator(Annotator):
432
432
  Calculate the angle between three points for workout monitoring.
433
433
 
434
434
  Args:
435
- a (List[float]): The coordinates of the first point.
436
- b (List[float]): The coordinates of the second point (vertex).
437
- c (List[float]): The coordinates of the third point.
435
+ a (list[float]): The coordinates of the first point.
436
+ b (list[float]): The coordinates of the second point (vertex).
437
+ c (list[float]): The coordinates of the third point.
438
438
 
439
439
  Returns:
440
440
  (float): The angle in degrees between the three points.
@@ -454,8 +454,8 @@ class SolutionAnnotator(Annotator):
454
454
  Draw specific keypoints for gym steps counting.
455
455
 
456
456
  Args:
457
- keypoints (List[List[float]]): Keypoints data to be plotted, each in format [x, y, confidence].
458
- indices (List[int], optional): Keypoint indices to be plotted.
457
+ keypoints (list[list[float]]): Keypoints data to be plotted, each in format [x, y, confidence].
458
+ indices (list[int], optional): Keypoint indices to be plotted.
459
459
  radius (int): Keypoint radius.
460
460
  conf_thresh (float): Confidence threshold for keypoints.
461
461
 
@@ -491,9 +491,9 @@ class SolutionAnnotator(Annotator):
491
491
 
492
492
  Args:
493
493
  display_text (str): The text to be displayed.
494
- position (Tuple[int, int]): Coordinates (x, y) on the image where the text will be placed.
495
- color (Tuple[int, int, int]): Text background color.
496
- txt_color (Tuple[int, int, int]): Text foreground color.
494
+ position (tuple[int, int]): Coordinates (x, y) on the image where the text will be placed.
495
+ color (tuple[int, int, int]): Text background color.
496
+ txt_color (tuple[int, int, int]): Text foreground color.
497
497
 
498
498
  Returns:
499
499
  (int): The height of the text.
@@ -529,9 +529,9 @@ class SolutionAnnotator(Annotator):
529
529
  angle_text (str): Angle value for workout monitoring.
530
530
  count_text (str): Counts value for workout monitoring.
531
531
  stage_text (str): Stage decision for workout monitoring.
532
- center_kpt (List[int]): Centroid pose index for workout monitoring.
533
- color (Tuple[int, int, int]): Text background color.
534
- txt_color (Tuple[int, int, int]): Text foreground color.
532
+ center_kpt (list[int]): Centroid pose index for workout monitoring.
533
+ color (tuple[int, int, int]): Text background color.
534
+ txt_color (tuple[int, int, int]): Text foreground color.
535
535
  """
536
536
  # Format text
537
537
  angle_text, count_text, stage_text = f" {angle_text:.2f}", f"Steps : {count_text}", f" {stage_text}"
@@ -559,9 +559,9 @@ class SolutionAnnotator(Annotator):
559
559
 
560
560
  Args:
561
561
  pixels_distance (float): Pixels distance between two bbox centroids.
562
- centroids (List[Tuple[int, int]]): Bounding box centroids data.
563
- line_color (Tuple[int, int, int]): Distance line color.
564
- centroid_color (Tuple[int, int, int]): Bounding box centroid color.
562
+ centroids (list[tuple[int, int]]): Bounding box centroids data.
563
+ line_color (tuple[int, int, int]): Distance line color.
564
+ centroid_color (tuple[int, int, int]): Bounding box centroid color.
565
565
  """
566
566
  # Get the text size
567
567
  text = f"Pixels Distance: {pixels_distance:.2f}"
@@ -603,8 +603,8 @@ class SolutionAnnotator(Annotator):
603
603
  Args:
604
604
  im0 (np.ndarray): Inference image.
605
605
  text (str): Object/class name.
606
- txt_color (Tuple[int, int, int]): Display color for text foreground.
607
- bg_color (Tuple[int, int, int]): Display color for text background.
606
+ txt_color (tuple[int, int, int]): Display color for text foreground.
607
+ bg_color (tuple[int, int, int]): Display color for text background.
608
608
  x_center (float): The x position center point for bounding box.
609
609
  y_center (float): The y position center point for bounding box.
610
610
  margin (int): The gap between text and rectangle for better display.
@@ -651,8 +651,8 @@ class SolutionAnnotator(Annotator):
651
651
  line_x (int): The x-coordinate of the sweep line.
652
652
  line_y (int): The y-coordinate limit of the sweep line.
653
653
  label (str, optional): Text label to be drawn in center of sweep line. If None, no label is drawn.
654
- color (Tuple[int, int, int]): RGB color for the line and label background.
655
- txt_color (Tuple[int, int, int]): RGB color for the label text.
654
+ color (tuple[int, int, int]): RGB color for the line and label background.
655
+ txt_color (tuple[int, int, int]): RGB color for the label text.
656
656
  """
657
657
  # Draw the sweep line
658
658
  cv2.line(self.im, (line_x, 0), (line_x, line_y), color, self.tf * 2)
@@ -688,10 +688,10 @@ class SolutionAnnotator(Annotator):
688
688
  Perform pinpoint human-vision eye mapping and plotting.
689
689
 
690
690
  Args:
691
- box (List[float]): Bounding box coordinates in format [x1, y1, x2, y2].
692
- center_point (Tuple[int, int]): Center point for vision eye view.
693
- color (Tuple[int, int, int]): Object centroid and line color.
694
- pin_color (Tuple[int, int, int]): Visioneye point color.
691
+ box (list[float]): Bounding box coordinates in format [x1, y1, x2, y2].
692
+ center_point (tuple[int, int]): Center point for vision eye view.
693
+ color (tuple[int, int, int]): Object centroid and line color.
694
+ pin_color (tuple[int, int, int]): Visioneye point color.
695
695
  """
696
696
  center_bbox = int((box[0] + box[2]) / 2), int((box[1] + box[3]) / 2)
697
697
  cv2.circle(self.im, center_point, self.tf * 2, pin_color, -1)
@@ -711,10 +711,10 @@ class SolutionAnnotator(Annotator):
711
711
  Draw a label with a background rectangle or circle centered within a given bounding box.
712
712
 
713
713
  Args:
714
- box (Tuple[float, float, float, float]): The bounding box coordinates (x1, y1, x2, y2).
714
+ box (tuple[float, float, float, float]): The bounding box coordinates (x1, y1, x2, y2).
715
715
  label (str): The text label to be displayed.
716
- color (Tuple[int, int, int]): The background color of the rectangle (B, G, R).
717
- txt_color (Tuple[int, int, int]): The color of the text (R, G, B).
716
+ color (tuple[int, int, int]): The background color of the rectangle (B, G, R).
717
+ txt_color (tuple[int, int, int]): The color of the text (R, G, B).
718
718
  shape (str): The shape of the label i.e "circle" or "rect"
719
719
  margin (int): The margin between the text and the rectangle border.
720
720
  """
@@ -768,7 +768,7 @@ class SolutionResults:
768
768
  plot_im (np.ndarray): Processed image with counts, blurred, or other effects from solutions.
769
769
  in_count (int): The total number of "in" counts in a video stream.
770
770
  out_count (int): The total number of "out" counts in a video stream.
771
- classwise_count (Dict[str, int]): A dictionary containing counts of objects categorized by class.
771
+ classwise_count (dict[str, int]): A dictionary containing counts of objects categorized by class.
772
772
  queue_count (int): The count of objects in a queue or waiting area.
773
773
  workout_count (int): The count of workout repetitions.
774
774
  workout_angle (float): The angle calculated during a workout exercise.
@@ -778,10 +778,10 @@ class SolutionResults:
778
778
  filled_slots (int): The number of filled slots in a monitored area.
779
779
  email_sent (bool): A flag indicating whether an email notification was sent.
780
780
  total_tracks (int): The total number of tracked objects.
781
- region_counts (Dict[str, int]): The count of objects within a specific region.
782
- speed_dict (Dict[str, float]): A dictionary containing speed information for tracked objects.
781
+ region_counts (dict[str, int]): The count of objects within a specific region.
782
+ speed_dict (dict[str, float]): A dictionary containing speed information for tracked objects.
783
783
  total_crop_objects (int): Total number of cropped objects using ObjectCropper class.
784
- speed (Dict[str, float]): Performance timing information for tracking and solution processing.
784
+ speed (dict[str, float]): Performance timing information for tracking and solution processing.
785
785
  """
786
786
 
787
787
  def __init__(self, **kwargs):
@@ -34,7 +34,7 @@ class Inference:
34
34
  org_frame (Any): Container for the original frame to be displayed.
35
35
  ann_frame (Any): Container for the annotated frame to be displayed.
36
36
  vid_file_name (str | int): Name of the uploaded video file or webcam index.
37
- selected_ind (List[int]): List of selected class indices for detection.
37
+ selected_ind (list[int]): List of selected class indices for detection.
38
38
 
39
39
  Methods:
40
40
  web_ui: Set up the Streamlit web interface with custom HTML elements.
@@ -19,10 +19,10 @@ class TrackZone(BaseSolution):
19
19
  Attributes:
20
20
  region (np.ndarray): The polygonal region for tracking, represented as a convex hull of points.
21
21
  line_width (int): Width of the lines used for drawing bounding boxes and region boundaries.
22
- names (List[str]): List of class names that the model can detect.
23
- boxes (List[np.ndarray]): Bounding boxes of tracked objects.
24
- track_ids (List[int]): Unique identifiers for each tracked object.
25
- clss (List[int]): Class indices of tracked objects.
22
+ names (list[str]): List of class names that the model can detect.
23
+ boxes (list[np.ndarray]): Bounding boxes of tracked objects.
24
+ track_ids (list[int]): Unique identifiers for each tracked object.
25
+ clss (list[int]): Class indices of tracked objects.
26
26
 
27
27
  Methods:
28
28
  process: Process each frame of the video, applying region-based tracking.
@@ -14,7 +14,7 @@ class VisionEye(BaseSolution):
14
14
  mapping vision points, and annotating results with bounding boxes and labels.
15
15
 
16
16
  Attributes:
17
- vision_point (Tuple[int, int]): Coordinates (x, y) where vision will view objects and draw tracks.
17
+ vision_point (tuple[int, int]): Coordinates (x, y) where vision will view objects and draw tracks.
18
18
 
19
19
  Methods:
20
20
  process: Process the input image to detect objects, annotate them, and apply vision mapping.
@@ -58,7 +58,7 @@ class STrack(BaseTrack):
58
58
  Initialize a new STrack instance.
59
59
 
60
60
  Args:
61
- xywh (List[float]): Bounding box coordinates and dimensions in the format (x, y, w, h, [a], idx), where
61
+ xywh (list[float]): Bounding box coordinates and dimensions in the format (x, y, w, h, [a], idx), where
62
62
  (x, y) is the center, (w, h) are width and height, [a] is optional aspect ratio, and idx is the id.
63
63
  score (float): Confidence score of the detection.
64
64
  cls (Any): Class label for the detected object.
@@ -246,9 +246,9 @@ class BYTETracker:
246
246
  predicting the new object locations, and performs data association.
247
247
 
248
248
  Attributes:
249
- tracked_stracks (List[STrack]): List of successfully activated tracks.
250
- lost_stracks (List[STrack]): List of lost tracks.
251
- removed_stracks (List[STrack]): List of removed tracks.
249
+ tracked_stracks (list[STrack]): List of successfully activated tracks.
250
+ lost_stracks (list[STrack]): List of lost tracks.
251
+ removed_stracks (list[STrack]): List of removed tracks.
252
252
  frame_id (int): The current frame ID.
253
253
  args (Namespace): Command-line arguments.
254
254
  max_time_lost (int): The maximum frames for a track to be considered as 'lost'.
@@ -286,9 +286,9 @@ class BYTETracker:
286
286
  >>> args = Namespace(track_buffer=30)
287
287
  >>> tracker = BYTETracker(args, frame_rate=30)
288
288
  """
289
- self.tracked_stracks = [] # type: List[STrack]
290
- self.lost_stracks = [] # type: List[STrack]
291
- self.removed_stracks = [] # type: List[STrack]
289
+ self.tracked_stracks = [] # type: list[STrack]
290
+ self.lost_stracks = [] # type: list[STrack]
291
+ self.removed_stracks = [] # type: list[STrack]
292
292
 
293
293
  self.frame_id = 0
294
294
  self.args = args
@@ -320,7 +320,7 @@ class BYTETracker:
320
320
  detections = self.init_track(results, feats_keep)
321
321
  # Add newly detected tracklets to tracked_stracks
322
322
  unconfirmed = []
323
- tracked_stracks = [] # type: List[STrack]
323
+ tracked_stracks = [] # type: list[STrack]
324
324
  for track in self.tracked_stracks:
325
325
  if not track.is_activated:
326
326
  unconfirmed.append(track)
@@ -439,9 +439,9 @@ class BYTETracker:
439
439
 
440
440
  def reset(self):
441
441
  """Reset the tracker by clearing all tracked, lost, and removed tracks and reinitializing the Kalman filter."""
442
- self.tracked_stracks = [] # type: List[STrack]
443
- self.lost_stracks = [] # type: List[STrack]
444
- self.removed_stracks = [] # type: List[STrack]
442
+ self.tracked_stracks = [] # type: list[STrack]
443
+ self.lost_stracks = [] # type: list[STrack]
444
+ self.removed_stracks = [] # type: list[STrack]
445
445
  self.frame_id = 0
446
446
  self.kalman_filter = self.get_kalmanfilter()
447
447
  self.reset_id()
@@ -21,7 +21,7 @@ class GMC:
21
21
  method (str): The tracking method to use. Options include 'orb', 'sift', 'ecc', 'sparseOptFlow', 'none'.
22
22
  downscale (int): Factor by which to downscale the frames for processing.
23
23
  prevFrame (np.ndarray): Previous frame for tracking.
24
- prevKeyPoints (List): Keypoints from the previous frame.
24
+ prevKeyPoints (list): Keypoints from the previous frame.
25
25
  prevDescriptors (np.ndarray): Descriptors from the previous frame.
26
26
  initializedFirstFrame (bool): Flag indicating if the first frame has been processed.
27
27
 
@@ -96,7 +96,7 @@ class GMC:
96
96
 
97
97
  Args:
98
98
  raw_frame (np.ndarray): The raw frame to be processed, with shape (H, W, C).
99
- detections (List, optional): List of detections to be used in the processing.
99
+ detections (list, optional): List of detections to be used in the processing.
100
100
 
101
101
  Returns:
102
102
  (np.ndarray): Transformation matrix with shape (2, 3).
@@ -163,7 +163,7 @@ class GMC:
163
163
 
164
164
  Args:
165
165
  raw_frame (np.ndarray): The raw frame to be processed, with shape (H, W, C).
166
- detections (List, optional): List of detections to be used in the processing.
166
+ detections (list, optional): List of detections to be used in the processing.
167
167
 
168
168
  Returns:
169
169
  (np.ndarray): Transformation matrix with shape (2, 3).
@@ -66,8 +66,8 @@ def iou_distance(atracks: list, btracks: list) -> np.ndarray:
66
66
  Compute cost based on Intersection over Union (IoU) between tracks.
67
67
 
68
68
  Args:
69
- atracks (List[STrack] | List[np.ndarray]): List of tracks 'a' or bounding boxes.
70
- btracks (List[STrack] | List[np.ndarray]): List of tracks 'b' or bounding boxes.
69
+ atracks (list[STrack] | list[np.ndarray]): List of tracks 'a' or bounding boxes.
70
+ btracks (list[STrack] | list[np.ndarray]): List of tracks 'b' or bounding boxes.
71
71
 
72
72
  Returns:
73
73
  (np.ndarray): Cost matrix computed based on IoU with shape (len(atracks), len(btracks)).
@@ -106,8 +106,8 @@ def embedding_distance(tracks: list, detections: list, metric: str = "cosine") -
106
106
  Compute distance between tracks and detections based on embeddings.
107
107
 
108
108
  Args:
109
- tracks (List[STrack]): List of tracks, where each track contains embedding features.
110
- detections (List[BaseTrack]): List of detections, where each detection contains embedding features.
109
+ tracks (list[STrack]): List of tracks, where each track contains embedding features.
110
+ detections (list[BaseTrack]): List of detections, where each detection contains embedding features.
111
111
  metric (str): Metric for distance computation. Supported metrics include 'cosine', 'euclidean', etc.
112
112
 
113
113
  Returns:
@@ -137,7 +137,7 @@ def fuse_score(cost_matrix: np.ndarray, detections: list) -> np.ndarray:
137
137
 
138
138
  Args:
139
139
  cost_matrix (np.ndarray): The matrix containing cost values for assignments, with shape (N, M).
140
- detections (List[BaseTrack]): List of detections, each containing a score attribute.
140
+ detections (list[BaseTrack]): List of detections, each containing a score attribute.
141
141
 
142
142
  Returns:
143
143
  (np.ndarray): Fused similarity matrix with shape (N, M).
@@ -23,7 +23,7 @@ class GPUInfo:
23
23
  pynvml (module | None): The `pynvml` module if successfully imported and initialized, otherwise `None`.
24
24
  nvml_available (bool): Indicates if `pynvml` is ready for use. True if import and `nvmlInit()` succeeded,
25
25
  False otherwise.
26
- gpu_stats (List[Dict[str, Any]]): A list of dictionaries, each holding stats for one GPU. Populated on
26
+ gpu_stats (list[dict[str, Any]]): A list of dictionaries, each holding stats for one GPU. Populated on
27
27
  initialization and by `refresh_stats()`. Keys include: 'index', 'name', 'utilization' (%),
28
28
  'memory_used' (MiB), 'memory_total' (MiB), 'memory_free' (MiB), 'temperature' (C), 'power_draw' (W),
29
29
  'power_limit' (W or 'N/A'). Empty if NVML is unavailable or queries fail.
@@ -146,7 +146,7 @@ class GPUInfo:
146
146
  min_util_fraction (float): Minimum free utilization rate required from 0.0 - 1.0.
147
147
 
148
148
  Returns:
149
- (List[int]): Indices of the selected GPUs, sorted by idleness (lowest utilization first).
149
+ (list[int]): Indices of the selected GPUs, sorted by idleness (lowest utilization first).
150
150
 
151
151
  Notes:
152
152
  Returns fewer than 'count' if not enough qualify or exist.
@@ -226,10 +226,10 @@ class RF100Benchmark:
226
226
  This class provides functionality to benchmark YOLO models on the RF100 dataset collection.
227
227
 
228
228
  Attributes:
229
- ds_names (List[str]): Names of datasets used for benchmarking.
230
- ds_cfg_list (List[Path]): List of paths to dataset configuration files.
229
+ ds_names (list[str]): Names of datasets used for benchmarking.
230
+ ds_cfg_list (list[Path]): List of paths to dataset configuration files.
231
231
  rf (Roboflow): Roboflow instance for accessing datasets.
232
- val_metrics (List[str]): Metrics used for validation.
232
+ val_metrics (list[str]): Metrics used for validation.
233
233
 
234
234
  Methods:
235
235
  set_key: Set Roboflow API key for accessing datasets.
@@ -270,8 +270,8 @@ class RF100Benchmark:
270
270
  ds_link_txt (str): Path to the file containing dataset links.
271
271
 
272
272
  Returns:
273
- ds_names (List[str]): List of dataset names.
274
- ds_cfg_list (List[Path]): List of paths to dataset configuration files.
273
+ ds_names (list[str]): List of dataset names.
274
+ ds_cfg_list (list[Path]): List of paths to dataset configuration files.
275
275
 
276
276
  Examples:
277
277
  >>> benchmark = RF100Benchmark()
@@ -372,7 +372,7 @@ class ProfileModels:
372
372
  This class profiles the performance of different models, returning results such as model speed and FLOPs.
373
373
 
374
374
  Attributes:
375
- paths (List[str]): Paths of the models to profile.
375
+ paths (list[str]): Paths of the models to profile.
376
376
  num_timed_runs (int): Number of timed runs for the profiling.
377
377
  num_warmup_runs (int): Number of warmup runs before profiling.
378
378
  min_time (float): Minimum number of seconds to profile for.
@@ -414,7 +414,7 @@ class ProfileModels:
414
414
  Initialize the ProfileModels class for profiling models.
415
415
 
416
416
  Args:
417
- paths (List[str]): List of paths of the models to be profiled.
417
+ paths (list[str]): List of paths of the models to be profiled.
418
418
  num_timed_runs (int): Number of timed runs for the profiling.
419
419
  num_warmup_runs (int): Number of warmup runs before the actual profiling starts.
420
420
  min_time (float): Minimum time in seconds for profiling a model.
@@ -446,7 +446,7 @@ class ProfileModels:
446
446
  Profile YOLO models for speed and accuracy across various formats including ONNX and TensorRT.
447
447
 
448
448
  Returns:
449
- (List[dict]): List of dictionaries containing profiling results for each model.
449
+ (list[dict]): List of dictionaries containing profiling results for each model.
450
450
 
451
451
  Examples:
452
452
  Profile models and print results
@@ -501,7 +501,7 @@ class ProfileModels:
501
501
  Return a list of paths for all relevant model files given by the user.
502
502
 
503
503
  Returns:
504
- (List[Path]): List of Path objects for the model files.
504
+ (list[Path]): List of Path objects for the model files.
505
505
  """
506
506
  files = []
507
507
  for path in self.paths:
@@ -707,7 +707,7 @@ class ProfileModels:
707
707
  Print a formatted table of model profiling results.
708
708
 
709
709
  Args:
710
- table_rows (List[str]): List of formatted table row strings.
710
+ table_rows (list[str]): List of formatted table row strings.
711
711
  """
712
712
  gpu = torch.cuda.get_device_name(0) if torch.cuda.is_available() else "GPU"
713
713
  headers = [
@@ -19,7 +19,7 @@ def _log_debug_samples(files, title: str = "Debug Samples") -> None:
19
19
  Log files (images) as debug samples in the ClearML task.
20
20
 
21
21
  Args:
22
- files (List[Path]): A list of file paths in PosixPath format.
22
+ files (list[Path]): A list of file paths in PosixPath format.
23
23
  title (str): A title that groups together images with the same values.
24
24
  """
25
25
  import re
@@ -163,7 +163,7 @@ def _scale_bounding_box_to_original_image_shape(
163
163
  ratio_pad (tuple): Ratio and padding information for scaling.
164
164
 
165
165
  Returns:
166
- (List[float]): Scaled bounding box coordinates in xywh format with top-left corner adjustment.
166
+ (list[float]): Scaled bounding box coordinates in xywh format with top-left corner adjustment.
167
167
  """
168
168
  resized_image_height, resized_image_width = resized_image_shape
169
169
 
@@ -297,7 +297,7 @@ def _extract_segmentation_annotation(segmentation_raw: str, decode: Callable) ->
297
297
  decode (Callable): Function to decode the compressed segmentation data.
298
298
 
299
299
  Returns:
300
- (List[List[Any]] | None): List of polygon points or None if extraction fails.
300
+ (list[list[Any]] | None): List of polygon points or None if extraction fails.
301
301
  """
302
302
  try:
303
303
  mask = decode(segmentation_raw)
@@ -322,7 +322,7 @@ def _fetch_annotations(img_idx, image_path, batch, prediction_metadata_map, clas
322
322
  class_map (dict): Additional class mapping for label conversion.
323
323
 
324
324
  Returns:
325
- (List | None): List of annotation dictionaries or None if no annotations exist.
325
+ (list | None): List of annotation dictionaries or None if no annotations exist.
326
326
  """
327
327
  ground_truth_annotations = _format_ground_truth_annotations_for_detection(
328
328
  img_idx, image_path, batch, class_label_map
@@ -365,9 +365,9 @@ def _log_images(experiment, image_paths, curr_step: int | None, annotations=None
365
365
 
366
366
  Args:
367
367
  experiment (comet_ml.CometExperiment): The Comet ML experiment to log images to.
368
- image_paths (List[Path]): List of paths to images that will be logged.
368
+ image_paths (list[Path]): List of paths to images that will be logged.
369
369
  curr_step (int): Current training step/iteration for tracking in the experiment timeline.
370
- annotations (List[List[dict]], optional): Nested list of annotation dictionaries for each image. Each
370
+ annotations (list[list[dict]], optional): Nested list of annotation dictionaries for each image. Each
371
371
  annotation contains visualization data like bounding boxes, labels, and confidence scores.
372
372
  """
373
373
  if annotations:
@@ -60,7 +60,7 @@ def parse_requirements(file_path=ROOT.parent / "requirements.txt", package=""):
60
60
  package (str, optional): Python package to use instead of requirements.txt file.
61
61
 
62
62
  Returns:
63
- requirements (List[SimpleNamespace]): List of parsed requirements as SimpleNamespace objects with `name` and
63
+ requirements (list[SimpleNamespace]): List of parsed requirements as SimpleNamespace objects with `name` and
64
64
  `specifier` attributes.
65
65
 
66
66
  Examples:
@@ -120,14 +120,14 @@ def check_imgsz(imgsz, stride=32, min_dim=1, max_dim=2, floor=0):
120
120
  stride, update it to the nearest multiple of the stride that is greater than or equal to the given floor value.
121
121
 
122
122
  Args:
123
- imgsz (int | List[int]): Image size.
123
+ imgsz (int | list[int]): Image size.
124
124
  stride (int): Stride value.
125
125
  min_dim (int): Minimum number of dimensions.
126
126
  max_dim (int): Maximum number of dimensions.
127
127
  floor (int): Minimum allowed value for image size.
128
128
 
129
129
  Returns:
130
- (List[int] | int): Updated image size.
130
+ (list[int] | int): Updated image size.
131
131
  """
132
132
  # Convert stride to integer if it is a tensor
133
133
  stride = int(stride.max() if isinstance(stride, torch.Tensor) else stride)
@@ -363,7 +363,7 @@ def check_requirements(requirements=ROOT.parent / "requirements.txt", exclude=()
363
363
  Check if installed dependencies meet Ultralytics YOLO models requirements and attempt to auto-update if needed.
364
364
 
365
365
  Args:
366
- requirements (Path | str | List[str]): Path to a requirements.txt file, a single package requirement as a
366
+ requirements (Path | str | list[str]): Path to a requirements.txt file, a single package requirement as a
367
367
  string, or a list of package requirements as strings.
368
368
  exclude (tuple): Tuple of package names to exclude from checking.
369
369
  install (bool): If True, attempt to auto-update packages that don't meet requirements.
@@ -483,7 +483,7 @@ def check_suffix(file="yolo11n.pt", suffix=".pt", msg=""):
483
483
  Check file(s) for acceptable suffix.
484
484
 
485
485
  Args:
486
- file (str | List[str]): File or list of files to check.
486
+ file (str | list[str]): File or list of files to check.
487
487
  suffix (str | tuple): Acceptable suffix or tuple of suffixes.
488
488
  msg (str): Additional message to display in case of error.
489
489
  """
@@ -0,0 +1,90 @@
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ from __future__ import annotations
4
+
5
+ import platform
6
+ import re
7
+ import subprocess
8
+ import sys
9
+ from pathlib import Path
10
+
11
+
12
+ class CPUInfo:
13
+ """
14
+ Provide cross-platform CPU brand and model information.
15
+
16
+ Query platform-specific sources to retrieve a human-readable CPU descriptor and normalize it for consistent
17
+ presentation across macOS, Linux, and Windows. If platform-specific probing fails, generic platform identifiers are
18
+ used to ensure a stable string is always returned.
19
+
20
+ Methods:
21
+ name: Return the normalized CPU name using platform-specific sources with robust fallbacks.
22
+ _clean: Normalize and prettify common vendor brand strings and frequency patterns.
23
+ __str__: Return the normalized CPU name for string contexts.
24
+
25
+ Examples:
26
+ >>> CPUInfo.name()
27
+ 'Apple M4 Pro'
28
+ >>> str(CPUInfo())
29
+ 'Intel Core i7-9750H 2.60GHz'
30
+ """
31
+
32
+ @staticmethod
33
+ def name() -> str:
34
+ """Return a normalized CPU model string from platform-specific sources."""
35
+ try:
36
+ if sys.platform == "darwin":
37
+ # Query macOS sysctl for the CPU brand string
38
+ s = subprocess.run(
39
+ ["sysctl", "-n", "machdep.cpu.brand_string"], capture_output=True, text=True
40
+ ).stdout.strip()
41
+ if s:
42
+ return CPUInfo._clean(s)
43
+ elif sys.platform.startswith("linux"):
44
+ # Parse /proc/cpuinfo for the first "model name" entry
45
+ p = Path("/proc/cpuinfo")
46
+ if p.exists():
47
+ for line in p.read_text(errors="ignore").splitlines():
48
+ if "model name" in line:
49
+ return CPUInfo._clean(line.split(":", 1)[1])
50
+ elif sys.platform.startswith("win"):
51
+ try:
52
+ import winreg as wr
53
+
54
+ with wr.OpenKey(wr.HKEY_LOCAL_MACHINE, r"HARDWARE\DESCRIPTION\System\CentralProcessor\0") as k:
55
+ val, _ = wr.QueryValueEx(k, "ProcessorNameString")
56
+ if val:
57
+ return CPUInfo._clean(val)
58
+ except Exception:
59
+ # Fall through to generic platform fallbacks on Windows registry access failure
60
+ pass
61
+ # Generic platform fallbacks
62
+ s = platform.processor() or getattr(platform.uname(), "processor", "") or platform.machine()
63
+ return CPUInfo._clean(s or "Unknown CPU")
64
+ except Exception:
65
+ # Ensure a string is always returned even on unexpected failures
66
+ s = platform.processor() or platform.machine() or ""
67
+ return CPUInfo._clean(s or "Unknown CPU")
68
+
69
+ @staticmethod
70
+ def _clean(s: str) -> str:
71
+ """Normalize and prettify a raw CPU descriptor string."""
72
+ s = re.sub(r"\s+", " ", s.strip())
73
+ s = s.replace("(TM)", "").replace("(tm)", "").replace("(R)", "").replace("(r)", "").strip()
74
+ # Normalize common Intel pattern to 'Model Freq'
75
+ m = re.search(r"(Intel.*?i\d[\w-]*) CPU @ ([\d.]+GHz)", s, re.I)
76
+ if m:
77
+ return f"{m.group(1)} {m.group(2)}"
78
+ # Normalize common AMD Ryzen pattern to 'Model Freq'
79
+ m = re.search(r"(AMD.*?Ryzen.*?[\w-]*) CPU @ ([\d.]+GHz)", s, re.I)
80
+ if m:
81
+ return f"{m.group(1)} {m.group(2)}"
82
+ return s
83
+
84
+ def __str__(self) -> str:
85
+ """Return the normalized CPU name."""
86
+ return self.name()
87
+
88
+
89
+ if __name__ == "__main__":
90
+ print(CPUInfo.name())