ultralytics 8.3.87__py3-none-any.whl → 8.3.89__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 (69) hide show
  1. tests/test_solutions.py +34 -45
  2. ultralytics/__init__.py +1 -1
  3. ultralytics/cfg/__init__.py +46 -39
  4. ultralytics/data/augment.py +2 -2
  5. ultralytics/data/base.py +7 -9
  6. ultralytics/data/converter.py +30 -29
  7. ultralytics/data/utils.py +20 -28
  8. ultralytics/engine/model.py +2 -2
  9. ultralytics/engine/tuner.py +11 -21
  10. ultralytics/hub/__init__.py +13 -17
  11. ultralytics/models/fastsam/model.py +4 -7
  12. ultralytics/models/nas/model.py +8 -14
  13. ultralytics/models/nas/predict.py +7 -9
  14. ultralytics/models/nas/val.py +7 -9
  15. ultralytics/models/rtdetr/predict.py +6 -9
  16. ultralytics/models/rtdetr/train.py +5 -8
  17. ultralytics/models/rtdetr/val.py +5 -8
  18. ultralytics/models/yolo/classify/predict.py +6 -9
  19. ultralytics/models/yolo/classify/train.py +5 -8
  20. ultralytics/models/yolo/classify/val.py +5 -8
  21. ultralytics/models/yolo/detect/predict.py +6 -9
  22. ultralytics/models/yolo/detect/train.py +5 -8
  23. ultralytics/models/yolo/detect/val.py +5 -8
  24. ultralytics/models/yolo/obb/predict.py +6 -9
  25. ultralytics/models/yolo/obb/train.py +5 -8
  26. ultralytics/models/yolo/obb/val.py +10 -15
  27. ultralytics/models/yolo/pose/predict.py +6 -9
  28. ultralytics/models/yolo/pose/train.py +5 -8
  29. ultralytics/models/yolo/pose/val.py +12 -17
  30. ultralytics/models/yolo/segment/predict.py +6 -9
  31. ultralytics/models/yolo/segment/train.py +5 -8
  32. ultralytics/models/yolo/segment/val.py +10 -15
  33. ultralytics/models/yolo/world/train.py +5 -8
  34. ultralytics/models/yolo/world/train_world.py +21 -25
  35. ultralytics/nn/modules/__init__.py +9 -12
  36. ultralytics/nn/tasks.py +7 -12
  37. ultralytics/solutions/__init__.py +14 -6
  38. ultralytics/solutions/ai_gym.py +39 -28
  39. ultralytics/solutions/analytics.py +22 -18
  40. ultralytics/solutions/distance_calculation.py +25 -25
  41. ultralytics/solutions/heatmap.py +40 -38
  42. ultralytics/solutions/instance_segmentation.py +69 -0
  43. ultralytics/solutions/object_blurrer.py +89 -0
  44. ultralytics/solutions/object_counter.py +35 -33
  45. ultralytics/solutions/object_cropper.py +84 -0
  46. ultralytics/solutions/parking_management.py +21 -9
  47. ultralytics/solutions/queue_management.py +20 -39
  48. ultralytics/solutions/region_counter.py +54 -51
  49. ultralytics/solutions/security_alarm.py +40 -30
  50. ultralytics/solutions/solutions.py +594 -16
  51. ultralytics/solutions/speed_estimation.py +34 -31
  52. ultralytics/solutions/streamlit_inference.py +34 -28
  53. ultralytics/solutions/trackzone.py +29 -18
  54. ultralytics/solutions/vision_eye.py +69 -0
  55. ultralytics/trackers/utils/kalman_filter.py +23 -23
  56. ultralytics/utils/__init__.py +5 -8
  57. ultralytics/utils/checks.py +25 -35
  58. ultralytics/utils/downloads.py +25 -48
  59. ultralytics/utils/instance.py +9 -11
  60. ultralytics/utils/ops.py +5 -9
  61. ultralytics/utils/plotting.py +8 -428
  62. ultralytics/utils/torch_utils.py +23 -33
  63. ultralytics/utils/tuner.py +5 -9
  64. {ultralytics-8.3.87.dist-info → ultralytics-8.3.89.dist-info}/METADATA +2 -2
  65. {ultralytics-8.3.87.dist-info → ultralytics-8.3.89.dist-info}/RECORD +69 -65
  66. {ultralytics-8.3.87.dist-info → ultralytics-8.3.89.dist-info}/LICENSE +0 -0
  67. {ultralytics-8.3.87.dist-info → ultralytics-8.3.89.dist-info}/WHEEL +0 -0
  68. {ultralytics-8.3.87.dist-info → ultralytics-8.3.89.dist-info}/entry_points.txt +0 -0
  69. {ultralytics-8.3.87.dist-info → ultralytics-8.3.89.dist-info}/top_level.txt +0 -0
@@ -60,12 +60,9 @@ def parse_requirements(file_path=ROOT.parent / "requirements.txt", package=""):
60
60
  Returns:
61
61
  (List[Dict[str, str]]): List of parsed requirements as dictionaries with `name` and `specifier` keys.
62
62
 
63
- Example:
64
- ```python
65
- from ultralytics.utils.checks import parse_requirements
66
-
67
- parse_requirements(package="ultralytics")
68
- ```
63
+ Examples:
64
+ >>> from ultralytics.utils.checks import parse_requirements
65
+ >>> parse_requirements(package="ultralytics")
69
66
  """
70
67
  if package:
71
68
  requires = [x for x in metadata.distribution(package).requires if "extra == " not in x]
@@ -194,20 +191,18 @@ def check_version(
194
191
  Returns:
195
192
  (bool): True if requirement is met, False otherwise.
196
193
 
197
- Example:
198
- ```python
199
- # Check if current version is exactly 22.04
200
- check_version(current="22.04", required="==22.04")
194
+ Examples:
195
+ Check if current version is exactly 22.04
196
+ >>> check_version(current="22.04", required="==22.04")
201
197
 
202
- # Check if current version is greater than or equal to 22.04
203
- check_version(current="22.10", required="22.04") # assumes '>=' inequality if none passed
198
+ Check if current version is greater than or equal to 22.04
199
+ >>> check_version(current="22.10", required="22.04") # assumes '>=' inequality if none passed
204
200
 
205
- # Check if current version is less than or equal to 22.04
206
- check_version(current="22.04", required="<=22.04")
201
+ Check if current version is less than or equal to 22.04
202
+ >>> check_version(current="22.04", required="<=22.04")
207
203
 
208
- # Check if current version is between 20.04 (inclusive) and 22.04 (exclusive)
209
- check_version(current="21.10", required=">20.04,<22.04")
210
- ```
204
+ Check if current version is between 20.04 (inclusive) and 22.04 (exclusive)
205
+ >>> check_version(current="21.10", required=">20.04,<22.04")
211
206
  """
212
207
  if not current: # if current is '' or None
213
208
  LOGGER.warning(f"WARNING ⚠️ invalid check_version({current}, {required}) requested, please check values.")
@@ -362,19 +357,17 @@ def check_requirements(requirements=ROOT.parent / "requirements.txt", exclude=()
362
357
  install (bool): If True, attempt to auto-update packages that don't meet requirements.
363
358
  cmds (str): Additional commands to pass to the pip install command when auto-updating.
364
359
 
365
- Example:
366
- ```python
367
- from ultralytics.utils.checks import check_requirements
360
+ Examples:
361
+ >>> from ultralytics.utils.checks import check_requirements
368
362
 
369
- # Check a requirements.txt file
370
- check_requirements("path/to/requirements.txt")
363
+ Check a requirements.txt file
364
+ >>> check_requirements("path/to/requirements.txt")
371
365
 
372
- # Check a single package
373
- check_requirements("ultralytics>=8.0.0")
366
+ Check a single package
367
+ >>> check_requirements("ultralytics>=8.0.0")
374
368
 
375
- # Check multiple packages
376
- check_requirements(["numpy", "ultralytics>=8.0.0"])
377
- ```
369
+ Check multiple packages
370
+ >>> check_requirements(["numpy", "ultralytics>=8.0.0"])
378
371
  """
379
372
  prefix = colorstr("red", "bold", "requirements:")
380
373
  if isinstance(requirements, Path): # requirements.txt file
@@ -657,14 +650,11 @@ def check_amp(model):
657
650
  Args:
658
651
  model (nn.Module): A YOLO11 model instance.
659
652
 
660
- Example:
661
- ```python
662
- from ultralytics import YOLO
663
- from ultralytics.utils.checks import check_amp
664
-
665
- model = YOLO("yolo11n.pt").model.cuda()
666
- check_amp(model)
667
- ```
653
+ Examples:
654
+ >>> from ultralytics import YOLO
655
+ >>> from ultralytics.utils.checks import check_amp
656
+ >>> model = YOLO("yolo11n.pt").model.cuda()
657
+ >>> check_amp(model)
668
658
 
669
659
  Returns:
670
660
  (bool): Returns True if the AMP functionality works correctly with YOLO11 model, else False.
@@ -48,10 +48,8 @@ def is_url(url, check=False):
48
48
  (bool): Returns True for a valid URL. If 'check' is True, also returns True if the URL exists online.
49
49
  Returns False otherwise.
50
50
 
51
- Example:
52
- ```python
53
- valid = is_url("https://www.example.com")
54
- ```
51
+ Examples:
52
+ >>> valid = is_url("https://www.example.com")
55
53
  """
56
54
  try:
57
55
  url = str(url)
@@ -73,12 +71,9 @@ def delete_dsstore(path, files_to_delete=(".DS_Store", "__MACOSX")):
73
71
  path (str, optional): The directory path where the ".DS_store" files should be deleted.
74
72
  files_to_delete (tuple): The files to be deleted.
75
73
 
76
- Example:
77
- ```python
78
- from ultralytics.utils.downloads import delete_dsstore
79
-
80
- delete_dsstore("path/to/dir")
81
- ```
74
+ Examples:
75
+ >>> from ultralytics.utils.downloads import delete_dsstore
76
+ >>> delete_dsstore("path/to/dir")
82
77
 
83
78
  Note:
84
79
  ".DS_store" files are created by the Apple operating system and contain metadata about folders and files. They
@@ -105,12 +100,9 @@ def zip_directory(directory, compress=True, exclude=(".DS_Store", "__MACOSX"), p
105
100
  Returns:
106
101
  (Path): The path to the resulting zip file.
107
102
 
108
- Example:
109
- ```python
110
- from ultralytics.utils.downloads import zip_directory
111
-
112
- file = zip_directory("path/to/dir")
113
- ```
103
+ Examples:
104
+ >>> from ultralytics.utils.downloads import zip_directory
105
+ >>> file = zip_directory("path/to/dir")
114
106
  """
115
107
  from zipfile import ZIP_DEFLATED, ZIP_STORED, ZipFile
116
108
 
@@ -151,12 +143,9 @@ def unzip_file(file, path=None, exclude=(".DS_Store", "__MACOSX"), exist_ok=Fals
151
143
  Returns:
152
144
  (Path): The path to the directory where the zipfile was extracted.
153
145
 
154
- Example:
155
- ```python
156
- from ultralytics.utils.downloads import unzip_file
157
-
158
- dir = unzip_file("path/to/file.zip")
159
- ```
146
+ Examples:
147
+ >>> from ultralytics.utils.downloads import unzip_file
148
+ >>> directory = unzip_file("path/to/file.zip")
160
149
  """
161
150
  from zipfile import BadZipFile, ZipFile, is_zipfile
162
151
 
@@ -245,13 +234,10 @@ def get_google_drive_file_info(link):
245
234
  (str): Direct download URL for the Google Drive file.
246
235
  (str): Original filename of the Google Drive file. If filename extraction fails, returns None.
247
236
 
248
- Example:
249
- ```python
250
- from ultralytics.utils.downloads import get_google_drive_file_info
251
-
252
- link = "https://drive.google.com/file/d/1cqT-cJgANNrhIHCrEufUYhQ4RqiWG_lJ/view?usp=drive_link"
253
- url, filename = get_google_drive_file_info(link)
254
- ```
237
+ Examples:
238
+ >>> from ultralytics.utils.downloads import get_google_drive_file_info
239
+ >>> link = "https://drive.google.com/file/d/1cqT-cJgANNrhIHCrEufUYhQ4RqiWG_lJ/view?usp=drive_link"
240
+ >>> url, filename = get_google_drive_file_info(link)
255
241
  """
256
242
  file_id = link.split("/d/")[1].split("/view")[0]
257
243
  drive_url = f"https://drive.google.com/uc?export=download&id={file_id}"
@@ -305,13 +291,10 @@ def safe_download(
305
291
  exist_ok (bool, optional): Whether to overwrite existing contents during unzipping. Defaults to False.
306
292
  progress (bool, optional): Whether to display a progress bar during the download. Default: True.
307
293
 
308
- Example:
309
- ```python
310
- from ultralytics.utils.downloads import safe_download
311
-
312
- link = "https://ultralytics.com/assets/bus.jpg"
313
- path = safe_download(link)
314
- ```
294
+ Examples:
295
+ >>> from ultralytics.utils.downloads import safe_download
296
+ >>> link = "https://ultralytics.com/assets/bus.jpg"
297
+ >>> path = safe_download(link)
315
298
  """
316
299
  gdrive = url.startswith("https://drive.google.com/") # check if the URL is a Google Drive link
317
300
  if gdrive:
@@ -391,10 +374,8 @@ def get_github_assets(repo="ultralytics/assets", version="latest", retry=False):
391
374
  Returns:
392
375
  (tuple): A tuple containing the release tag and a list of asset names.
393
376
 
394
- Example:
395
- ```python
396
- tag, assets = get_github_assets(repo="ultralytics/assets", version="latest")
397
- ```
377
+ Examples:
378
+ >>> tag, assets = get_github_assets(repo="ultralytics/assets", version="latest")
398
379
  """
399
380
  if version != "latest":
400
381
  version = f"tags/{version}" # i.e. tags/v6.2
@@ -423,10 +404,8 @@ def attempt_download_asset(file, repo="ultralytics/assets", release="v8.3.0", **
423
404
  Returns:
424
405
  (str): The path to the downloaded file.
425
406
 
426
- Example:
427
- ```python
428
- file_path = attempt_download_asset("yolo11n.pt", repo="ultralytics/assets", release="latest")
429
- ```
407
+ Examples:
408
+ >>> file_path = attempt_download_asset("yolo11n.pt", repo="ultralytics/assets", release="latest")
430
409
  """
431
410
  from ultralytics.utils import SETTINGS # scoped for circular import
432
411
 
@@ -478,10 +457,8 @@ def download(url, dir=Path.cwd(), unzip=True, delete=False, curl=False, threads=
478
457
  retry (int, optional): Number of retries in case of download failure. Defaults to 3.
479
458
  exist_ok (bool, optional): Whether to overwrite existing contents during unzipping. Defaults to False.
480
459
 
481
- Example:
482
- ```python
483
- download("https://ultralytics.com/assets/example.zip", dir="path/to/dir", unzip=True)
484
- ```
460
+ Examples:
461
+ >>> download("https://ultralytics.com/assets/example.zip", dir="path/to/dir", unzip=True)
485
462
  """
486
463
  dir = Path(dir)
487
464
  dir.mkdir(parents=True, exist_ok=True) # make directory
@@ -188,26 +188,24 @@ class Instances:
188
188
 
189
189
  Attributes:
190
190
  _bboxes (Bboxes): Internal object for handling bounding box operations.
191
- keypoints (ndarray): keypoints(x, y, visible) with shape [N, 17, 3]. Default is None.
191
+ keypoints (np.ndarray): keypoints(x, y, visible) with shape [N, 17, 3]. Default is None.
192
192
  normalized (bool): Flag indicating whether the bounding box coordinates are normalized.
193
- segments (ndarray): Segments array with shape [N, 1000, 2] after resampling.
193
+ segments (np.ndarray): Segments array with shape [N, 1000, 2] after resampling.
194
194
 
195
195
  Args:
196
- bboxes (ndarray): An array of bounding boxes with shape [N, 4].
196
+ bboxes (np.ndarray): An array of bounding boxes with shape [N, 4].
197
197
  segments (list | ndarray, optional): A list or array of object segments. Default is None.
198
198
  keypoints (ndarray, optional): An array of keypoints with shape [N, 17, 3]. Default is None.
199
199
  bbox_format (str, optional): The format of bounding boxes ('xywh' or 'xyxy'). Default is 'xywh'.
200
200
  normalized (bool, optional): Whether the bounding box coordinates are normalized. Default is True.
201
201
 
202
202
  Examples:
203
- ```python
204
- # Create an Instances object
205
- instances = Instances(
206
- bboxes=np.array([[10, 10, 30, 30], [20, 20, 40, 40]]),
207
- segments=[np.array([[5, 5], [10, 10]]), np.array([[15, 15], [20, 20]])],
208
- keypoints=np.array([[[5, 5, 1], [10, 10, 1]], [[15, 15, 1], [20, 20, 1]]]),
209
- )
210
- ```
203
+ Create an Instances object
204
+ >>> instances = Instances(
205
+ ... bboxes=np.array([[10, 10, 30, 30], [20, 20, 40, 40]]),
206
+ ... segments=[np.array([[5, 5], [10, 10]]), np.array([[15, 15], [20, 20]])],
207
+ ... keypoints=np.array([[[5, 5, 1], [10, 10, 1]], [[15, 15, 1], [20, 20, 1]]]),
208
+ ... )
211
209
 
212
210
  Note:
213
211
  The bounding box format is either 'xywh' or 'xyxy', and is determined by the `bbox_format` argument.
ultralytics/utils/ops.py CHANGED
@@ -18,15 +18,11 @@ class Profile(contextlib.ContextDecorator):
18
18
  """
19
19
  YOLOv8 Profile class. Use as a decorator with @Profile() or as a context manager with 'with Profile():'.
20
20
 
21
- Example:
22
- ```python
23
- from ultralytics.utils.ops import Profile
24
-
25
- with Profile(device=device) as dt:
26
- pass # slow operation here
27
-
28
- print(dt) # prints "Elapsed time is 9.5367431640625e-07 s"
29
- ```
21
+ Examples:
22
+ >>> from ultralytics.utils.ops import Profile
23
+ >>> with Profile(device=device) as dt:
24
+ ... pass # slow operation here
25
+ >>> print(dt) # prints "Elapsed time is 9.5367431640625e-07 s"
30
26
  """
31
27
 
32
28
  def __init__(self, t=0.0, device: torch.device = None):