ultralytics 8.2.71__py3-none-any.whl → 8.2.73__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.

Potentially problematic release.


This version of ultralytics might be problematic. Click here for more details.

Files changed (35) hide show
  1. tests/test_cli.py +3 -0
  2. ultralytics/__init__.py +2 -3
  3. ultralytics/models/__init__.py +1 -2
  4. ultralytics/models/sam/__init__.py +2 -2
  5. ultralytics/models/sam/amg.py +27 -21
  6. ultralytics/models/sam/build.py +200 -9
  7. ultralytics/models/sam/model.py +86 -34
  8. ultralytics/models/sam/modules/blocks.py +1131 -0
  9. ultralytics/models/sam/modules/decoders.py +390 -23
  10. ultralytics/models/sam/modules/encoders.py +508 -323
  11. ultralytics/models/{sam2 → sam}/modules/memory_attention.py +73 -6
  12. ultralytics/models/sam/modules/sam.py +887 -16
  13. ultralytics/models/sam/modules/tiny_encoder.py +376 -126
  14. ultralytics/models/sam/modules/transformer.py +155 -54
  15. ultralytics/models/{sam2 → sam}/modules/utils.py +105 -3
  16. ultralytics/models/sam/predict.py +382 -92
  17. ultralytics/nn/modules/transformer.py +2 -2
  18. ultralytics/utils/downloads.py +2 -2
  19. ultralytics/utils/ops.py +2 -2
  20. ultralytics/utils/plotting.py +3 -3
  21. {ultralytics-8.2.71.dist-info → ultralytics-8.2.73.dist-info}/METADATA +44 -44
  22. {ultralytics-8.2.71.dist-info → ultralytics-8.2.73.dist-info}/RECORD +26 -34
  23. ultralytics/models/sam2/__init__.py +0 -6
  24. ultralytics/models/sam2/build.py +0 -156
  25. ultralytics/models/sam2/model.py +0 -97
  26. ultralytics/models/sam2/modules/__init__.py +0 -1
  27. ultralytics/models/sam2/modules/decoders.py +0 -305
  28. ultralytics/models/sam2/modules/encoders.py +0 -332
  29. ultralytics/models/sam2/modules/sam2.py +0 -804
  30. ultralytics/models/sam2/modules/sam2_blocks.py +0 -715
  31. ultralytics/models/sam2/predict.py +0 -182
  32. {ultralytics-8.2.71.dist-info → ultralytics-8.2.73.dist-info}/LICENSE +0 -0
  33. {ultralytics-8.2.71.dist-info → ultralytics-8.2.73.dist-info}/WHEEL +0 -0
  34. {ultralytics-8.2.71.dist-info → ultralytics-8.2.73.dist-info}/entry_points.txt +0 -0
  35. {ultralytics-8.2.71.dist-info → ultralytics-8.2.73.dist-info}/top_level.txt +0 -0
@@ -41,7 +41,7 @@ def is_url(url, check=False):
41
41
  Args:
42
42
  url (str): The string to be validated as a URL.
43
43
  check (bool, optional): If True, performs an additional check to see if the URL exists online.
44
- Defaults to True.
44
+ Defaults to False.
45
45
 
46
46
  Returns:
47
47
  (bool): Returns True for a valid URL. If 'check' is True, also returns True if the URL exists online.
@@ -201,7 +201,7 @@ def check_disk_space(url="https://ultralytics.com/assets/coco8.zip", path=Path.c
201
201
  Args:
202
202
  url (str, optional): The URL to the file. Defaults to 'https://ultralytics.com/assets/coco8.zip'.
203
203
  path (str | Path, optional): The path or drive to check the available free space on.
204
- sf (float, optional): Safety factor, the multiplier for the required free space. Defaults to 2.0.
204
+ sf (float, optional): Safety factor, the multiplier for the required free space. Defaults to 1.5.
205
205
  hard (bool, optional): Whether to throw an error or not on insufficient disk space. Defaults to True.
206
206
 
207
207
  Returns:
ultralytics/utils/ops.py CHANGED
@@ -528,7 +528,7 @@ def ltwh2xywh(x):
528
528
  def xyxyxyxy2xywhr(x):
529
529
  """
530
530
  Convert batched Oriented Bounding Boxes (OBB) from [xy1, xy2, xy3, xy4] to [xywh, rotation]. Rotation values are
531
- expected in degrees from 0 to 90.
531
+ returned in radians from 0 to pi/2.
532
532
 
533
533
  Args:
534
534
  x (numpy.ndarray | torch.Tensor): Input box corners [xy1, xy2, xy3, xy4] of shape (n, 8).
@@ -551,7 +551,7 @@ def xyxyxyxy2xywhr(x):
551
551
  def xywhr2xyxyxyxy(x):
552
552
  """
553
553
  Convert batched Oriented Bounding Boxes (OBB) from [xywh, rotation] to [xy1, xy2, xy3, xy4]. Rotation values should
554
- be in degrees from 0 to 90.
554
+ be in radians from 0 to pi/2.
555
555
 
556
556
  Args:
557
557
  x (numpy.ndarray | torch.Tensor): Boxes in [cx, cy, w, h, rotation] format of shape (n, 5) or (b, n, 5).
@@ -195,12 +195,12 @@ class Annotator:
195
195
 
196
196
  def circle_label(self, box, label="", color=(128, 128, 128), txt_color=(255, 255, 255), margin=2):
197
197
  """
198
- Draws a label with a background rectangle centered within a given bounding box.
198
+ Draws a label with a background circle centered within a given bounding box.
199
199
 
200
200
  Args:
201
201
  box (tuple): The bounding box coordinates (x1, y1, x2, y2).
202
202
  label (str): The text label to be displayed.
203
- color (tuple, optional): The background color of the rectangle (R, G, B).
203
+ color (tuple, optional): The background color of the rectangle (B, G, R).
204
204
  txt_color (tuple, optional): The color of the text (R, G, B).
205
205
  margin (int, optional): The margin between the text and the rectangle border.
206
206
  """
@@ -242,7 +242,7 @@ class Annotator:
242
242
  Args:
243
243
  box (tuple): The bounding box coordinates (x1, y1, x2, y2).
244
244
  label (str): The text label to be displayed.
245
- color (tuple, optional): The background color of the rectangle (R, G, B).
245
+ color (tuple, optional): The background color of the rectangle (B, G, R).
246
246
  txt_color (tuple, optional): The color of the text (R, G, B).
247
247
  margin (int, optional): The margin between the text and the rectangle border.
248
248
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ultralytics
3
- Version: 8.2.71
3
+ Version: 8.2.73
4
4
  Summary: Ultralytics YOLOv8 for SOTA object detection, multi-object tracking, instance segmentation, pose estimation and image classification.
5
5
  Author: Glenn Jocher, Ayush Chaurasia, Jing Qiu
6
6
  Maintainer: Glenn Jocher, Ayush Chaurasia, Jing Qiu
@@ -30,56 +30,56 @@ Classifier: Operating System :: Microsoft :: Windows
30
30
  Requires-Python: >=3.8
31
31
  Description-Content-Type: text/markdown
32
32
  License-File: LICENSE
33
- Requires-Dist: numpy <2.0.0,>=1.23.0
34
- Requires-Dist: matplotlib >=3.3.0
35
- Requires-Dist: opencv-python >=4.6.0
36
- Requires-Dist: pillow >=7.1.2
37
- Requires-Dist: pyyaml >=5.3.1
38
- Requires-Dist: requests >=2.23.0
39
- Requires-Dist: scipy >=1.4.1
40
- Requires-Dist: torch >=1.8.0
41
- Requires-Dist: torchvision >=0.9.0
42
- Requires-Dist: tqdm >=4.64.0
33
+ Requires-Dist: numpy<2.0.0,>=1.23.0
34
+ Requires-Dist: matplotlib>=3.3.0
35
+ Requires-Dist: opencv-python>=4.6.0
36
+ Requires-Dist: pillow>=7.1.2
37
+ Requires-Dist: pyyaml>=5.3.1
38
+ Requires-Dist: requests>=2.23.0
39
+ Requires-Dist: scipy>=1.4.1
40
+ Requires-Dist: torch>=1.8.0
41
+ Requires-Dist: torchvision>=0.9.0
42
+ Requires-Dist: tqdm>=4.64.0
43
43
  Requires-Dist: psutil
44
44
  Requires-Dist: py-cpuinfo
45
- Requires-Dist: pandas >=1.1.4
46
- Requires-Dist: seaborn >=0.11.0
47
- Requires-Dist: ultralytics-thop >=2.0.0
45
+ Requires-Dist: pandas>=1.1.4
46
+ Requires-Dist: seaborn>=0.11.0
47
+ Requires-Dist: ultralytics-thop>=2.0.0
48
48
  Provides-Extra: dev
49
- Requires-Dist: ipython ; extra == 'dev'
50
- Requires-Dist: pytest ; extra == 'dev'
51
- Requires-Dist: pytest-cov ; extra == 'dev'
52
- Requires-Dist: coverage[toml] ; extra == 'dev'
53
- Requires-Dist: mkdocs >=1.6.0 ; extra == 'dev'
54
- Requires-Dist: mkdocs-material >=9.5.9 ; extra == 'dev'
55
- Requires-Dist: mkdocstrings[python] ; extra == 'dev'
56
- Requires-Dist: mkdocs-jupyter ; extra == 'dev'
57
- Requires-Dist: mkdocs-redirects ; extra == 'dev'
58
- Requires-Dist: mkdocs-ultralytics-plugin >=0.0.49 ; extra == 'dev'
49
+ Requires-Dist: ipython; extra == "dev"
50
+ Requires-Dist: pytest; extra == "dev"
51
+ Requires-Dist: pytest-cov; extra == "dev"
52
+ Requires-Dist: coverage[toml]; extra == "dev"
53
+ Requires-Dist: mkdocs>=1.6.0; extra == "dev"
54
+ Requires-Dist: mkdocs-material>=9.5.9; extra == "dev"
55
+ Requires-Dist: mkdocstrings[python]; extra == "dev"
56
+ Requires-Dist: mkdocs-jupyter; extra == "dev"
57
+ Requires-Dist: mkdocs-redirects; extra == "dev"
58
+ Requires-Dist: mkdocs-ultralytics-plugin>=0.0.49; extra == "dev"
59
59
  Provides-Extra: explorer
60
- Requires-Dist: lancedb ; extra == 'explorer'
61
- Requires-Dist: duckdb <=0.9.2 ; extra == 'explorer'
62
- Requires-Dist: streamlit ; extra == 'explorer'
60
+ Requires-Dist: lancedb; extra == "explorer"
61
+ Requires-Dist: duckdb<=0.9.2; extra == "explorer"
62
+ Requires-Dist: streamlit; extra == "explorer"
63
63
  Provides-Extra: export
64
- Requires-Dist: onnx >=1.12.0 ; extra == 'export'
65
- Requires-Dist: openvino >=2024.0.0 ; extra == 'export'
66
- Requires-Dist: tensorflow >=2.0.0 ; extra == 'export'
67
- Requires-Dist: tensorflowjs >=3.9.0 ; extra == 'export'
68
- Requires-Dist: keras ; extra == 'export'
69
- Requires-Dist: flatbuffers <100,>=23.5.26 ; (platform_machine == "aarch64") and extra == 'export'
70
- Requires-Dist: numpy ==1.23.5 ; (platform_machine == "aarch64") and extra == 'export'
71
- Requires-Dist: h5py !=3.11.0 ; (platform_machine == "aarch64") and extra == 'export'
72
- Requires-Dist: tensorstore >=0.1.63 ; (platform_machine == "aarch64" and python_version >= "3.9") and extra == 'export'
73
- Requires-Dist: coremltools >=7.0 ; (platform_system != "Windows" and python_version <= "3.11") and extra == 'export'
64
+ Requires-Dist: onnx>=1.12.0; extra == "export"
65
+ Requires-Dist: openvino>=2024.0.0; extra == "export"
66
+ Requires-Dist: tensorflow>=2.0.0; extra == "export"
67
+ Requires-Dist: tensorflowjs>=3.9.0; extra == "export"
68
+ Requires-Dist: keras; extra == "export"
69
+ Requires-Dist: flatbuffers<100,>=23.5.26; platform_machine == "aarch64" and extra == "export"
70
+ Requires-Dist: numpy==1.23.5; platform_machine == "aarch64" and extra == "export"
71
+ Requires-Dist: h5py!=3.11.0; platform_machine == "aarch64" and extra == "export"
72
+ Requires-Dist: tensorstore>=0.1.63; (platform_machine == "aarch64" and python_version >= "3.9") and extra == "export"
73
+ Requires-Dist: coremltools>=7.0; (platform_system != "Windows" and python_version <= "3.11") and extra == "export"
74
74
  Provides-Extra: extra
75
- Requires-Dist: hub-sdk >=0.0.8 ; extra == 'extra'
76
- Requires-Dist: ipython ; extra == 'extra'
77
- Requires-Dist: albumentations >=1.4.6 ; extra == 'extra'
78
- Requires-Dist: pycocotools >=2.0.7 ; extra == 'extra'
75
+ Requires-Dist: hub-sdk>=0.0.8; extra == "extra"
76
+ Requires-Dist: ipython; extra == "extra"
77
+ Requires-Dist: albumentations>=1.4.6; extra == "extra"
78
+ Requires-Dist: pycocotools>=2.0.7; extra == "extra"
79
79
  Provides-Extra: logging
80
- Requires-Dist: comet ; extra == 'logging'
81
- Requires-Dist: tensorboard >=2.13.0 ; extra == 'logging'
82
- Requires-Dist: dvclive >=2.12.0 ; extra == 'logging'
80
+ Requires-Dist: comet; extra == "logging"
81
+ Requires-Dist: tensorboard>=2.13.0; extra == "logging"
82
+ Requires-Dist: dvclive>=2.12.0; extra == "logging"
83
83
 
84
84
  <div align="center">
85
85
  <p>
@@ -1,6 +1,6 @@
1
1
  tests/__init__.py,sha256=9evx3lOdKZeY1iWXvH-FkMkgf8jLucWICoabzeD6aYg,626
2
2
  tests/conftest.py,sha256=3ZtD4VlMKK5jVJwIPCrNAcG63vywJzdLq7U2AfYR2VI,2919
3
- tests/test_cli.py,sha256=PqZVSKBjLeHwQzh_hVKucQibqTFtP-2ZS6ndZRpqUDI,4654
3
+ tests/test_cli.py,sha256=9NvLZhhy8er8A_OXZ1iVUAm0uvtT0phZFmUPO-YBZEs,4842
4
4
  tests/test_cuda.py,sha256=uD-ddNEcBMFQmQ9iE4fIGh0EIcGwEoDEUNVCEHicaWE,5133
5
5
  tests/test_engine.py,sha256=xW-UT9_9xZp-7-hSnbJgMw_ezTk6NqTOIiA59XZDmxA,4934
6
6
  tests/test_explorer.py,sha256=NcxSJeB6FxwkN09hQl7nnQL--HjfHB_WcZk0mEmBNHI,2215
@@ -8,7 +8,7 @@ tests/test_exports.py,sha256=Uezf3OatpPHlo5qoPw-2kqkZxuMCF9L4XF2riD4vmII,8225
8
8
  tests/test_integrations.py,sha256=xglcfMPjfVh346PV8WTpk6tBxraCXEFJEQyyJMr5tyU,6064
9
9
  tests/test_python.py,sha256=cLK8dyRf_4H_znFIm-krnOFMydwkxKlVZvHwl9vbck8,21780
10
10
  tests/test_solutions.py,sha256=EACnPXbeJe2aVTOKfqMk5jclKKCWCVgFEzjpR6y7Sh8,3304
11
- ultralytics/__init__.py,sha256=sV3uzVV5yg9sqZSe7JS8hxO873wlJUProzRIeVii45U,712
11
+ ultralytics/__init__.py,sha256=5cxnbY1PhiHP67saaLWbIANK95U6YlAw7I0nUZrVt7A,694
12
12
  ultralytics/assets/bus.jpg,sha256=wCAZxJecGR63Od3ZRERe9Aja1Weayrb9Ug751DS_vGM,137419
13
13
  ultralytics/assets/zidane.jpg,sha256=Ftc4aeMmen1O0A3o6GCDO9FlfBslLpTAw0gnetx7bts,50427
14
14
  ultralytics/cfg/__init__.py,sha256=7ce3_bhi7pDw5ZAbSqYR6e3_IYD2JCLCy7fkl5d1WyI,33064
@@ -110,7 +110,7 @@ ultralytics/hub/auth.py,sha256=FID58NE6fh7Op_B45QOpWBw1qoBN0ponL16uvyb2dZ8,5399
110
110
  ultralytics/hub/session.py,sha256=UF_aVwyxnbP-OzpzKXGGhi4i6KGWjjhoj5Qsn46dFpE,16257
111
111
  ultralytics/hub/utils.py,sha256=tXfM3QbXBcf4Y6StgHI1pktT4OM7Ic9eF3xiBFHGlhY,9721
112
112
  ultralytics/hub/google/__init__.py,sha256=qyvvpGP-4NAtrn7GLqfqxP_aWuRP1T0OvJYafWKvL2Q,7512
113
- ultralytics/models/__init__.py,sha256=AlVStwxv5pMrYaPL8dLhu4sY2c2JgqmuK__RlEDKrEo,296
113
+ ultralytics/models/__init__.py,sha256=TT9iLCL_n9Y80dcUq0Fo-p-GRZCSU2vrWXM3CoMwqqE,265
114
114
  ultralytics/models/fastsam/__init__.py,sha256=W0rRSJM3vdxcsneuiN6_ajkUw86k6-opUKdLxVhKOoQ,203
115
115
  ultralytics/models/fastsam/model.py,sha256=r5VZj-KLKaqZtEKTZxQik8vQI2N9uOF4xpV_gA-P8h0,2101
116
116
  ultralytics/models/fastsam/predict.py,sha256=z5j2IMwf4MURuROKeqNXW1WvOSj91UdJa7dLRqN_OFc,7370
@@ -125,28 +125,20 @@ ultralytics/models/rtdetr/model.py,sha256=2VkppF1_581XmQ0UI7lo8fX7MqhAJPXVMr2jyM
125
125
  ultralytics/models/rtdetr/predict.py,sha256=GmeNiFszDajq9YNPi0jW89CqP0MRD5Gtmokh9z0JAQc,3568
126
126
  ultralytics/models/rtdetr/train.py,sha256=20AFYVW9NPxw0-cp-sRdIovWidFL0IIhJRv2oZjkPlM,3685
127
127
  ultralytics/models/rtdetr/val.py,sha256=4QQArdaGEY8rJsJuvyJ032f8GGVGdV2jURHK2EdMxyk,5566
128
- ultralytics/models/sam/__init__.py,sha256=9A1iyfPN_ncqq3TMExe_-uPoARjEX3psoHEI1xMG2VE,144
129
- ultralytics/models/sam/amg.py,sha256=He2c4nIoZ__F_pL18rRl278R8iBjWXBM2Z_vxfuVOkk,7971
130
- ultralytics/models/sam/build.py,sha256=BSpRgDIQb-kgxaQtSq0C7Zb2UsqkfkFRmErC_bzKYIg,4954
131
- ultralytics/models/sam/model.py,sha256=MVO7WqF41Sq1-qbsN8O8Fophe8anYVY67yp17Sudp0k,4979
132
- ultralytics/models/sam/predict.py,sha256=GoR8xCwt3VJdBX5wUUhJ-3qY87LoG-R1eG8SziTDLP0,23755
128
+ ultralytics/models/sam/__init__.py,sha256=o4_D6y8YJlOXIK7Lwo9RHnIJJ9xoFNi4zK99QSc1kdM,176
129
+ ultralytics/models/sam/amg.py,sha256=GrmO_8YfIDt_QkPEMF_WFjPZkhwhf7iwx7ig8JgOUnE,8709
130
+ ultralytics/models/sam/build.py,sha256=zNQbrgSHUgz1gyXQwLKGTpa6CSEjeaevcP3w1Z1l3mo,12233
131
+ ultralytics/models/sam/model.py,sha256=uOm5xEPX9PJYu6ag5T5iHzl4Uq8huwPyoaYo9imf9HQ,7374
132
+ ultralytics/models/sam/predict.py,sha256=ILPx2O4pj4hmMG1KGwHjMYBM3pD-4mZLPNqIczk6_S0,37744
133
133
  ultralytics/models/sam/modules/__init__.py,sha256=mHtJuK4hwF8cuV-VHDc7tp6u6D1gHz2Z7JI8grmQDTs,42
134
- ultralytics/models/sam/modules/decoders.py,sha256=SkVdfsFwy8g4rOJYXi2rWg2zI5HEttsQJi6E4Uwxs9o,6307
135
- ultralytics/models/sam/modules/encoders.py,sha256=JHot5dRyr_d3wAzz7jgc_SOWOWibWKRWOt-IGBXPhW8,24894
136
- ultralytics/models/sam/modules/sam.py,sha256=lyB-edOBr85gACTaVqG0WiSIS4FyohTtLqkNMKDwVM0,2695
137
- ultralytics/models/sam/modules/tiny_encoder.py,sha256=rAY9JuyxUpFivFUUPVjK2aUYlsXEZ0JGKVoEWDGf0Eo,29228
138
- ultralytics/models/sam/modules/transformer.py,sha256=a2jsS_J76MvrIKIERb_0flliYFMjpBbwVL4UnsNnoyE,11232
139
- ultralytics/models/sam2/__init__.py,sha256=_xqQHLZTLgEdK278YETYR-Fts2hsvXP5q9ddUbuuFvc,154
140
- ultralytics/models/sam2/build.py,sha256=m6hv82VKn3Lct_7nztUqdzJzCV9Nbr5mvqpI8nkReQM,5422
141
- ultralytics/models/sam2/model.py,sha256=PS-eV78DVNrGZmUq7L7gJHgrGjxnySM1TTHkwfrQM7E,3408
142
- ultralytics/models/sam2/predict.py,sha256=gvKf6qcStFiT9SLzo8Ol25suIh-QRVcOcdbyeuM2ORw,8894
143
- ultralytics/models/sam2/modules/__init__.py,sha256=mHtJuK4hwF8cuV-VHDc7tp6u6D1gHz2Z7JI8grmQDTs,42
144
- ultralytics/models/sam2/modules/decoders.py,sha256=t4SR-0g3HQstk-agiapCsVYTMZBFc2vz24zfgBwZUkw,15376
145
- ultralytics/models/sam2/modules/encoders.py,sha256=0VRK2wdl0vZzKA3528_j-Vyn4Iy8XlNHp2ftQRn-aGE,13313
146
- ultralytics/models/sam2/modules/memory_attention.py,sha256=4zdvm8_ANM0r8QSN_xBGi9l-9Ugjt3gxBsHv2cHczjc,6214
147
- ultralytics/models/sam2/modules/sam2.py,sha256=CgCBrfjhKDHI2n8iM6AIJmXeCEgf2_qUz7rzZT31fB0,44255
148
- ultralytics/models/sam2/modules/sam2_blocks.py,sha256=7HmuZTFw8VVdAVDsIStWByxyUHBqytnfgvQMaCNr1GU,28379
149
- ultralytics/models/sam2/modules/utils.py,sha256=2H5C3sjBnYoPuoJqflH3AmGeBJoKrhHea136jgwIq_I,8320
134
+ ultralytics/models/sam/modules/blocks.py,sha256=qXCXMqkQG0fpAvCkA9TrtimfOLDtyJfCx3bDfh3bJUs,45974
135
+ ultralytics/models/sam/modules/decoders.py,sha256=d02t-55eTUBXEUtaDbcLm4VLgfqsW478CpJouMkMK-g,25874
136
+ ultralytics/models/sam/modules/encoders.py,sha256=KvQFAtqfGvCAr4kcMXxnJvjwIhaQ0a3Wwp0KhSSG_oA,34615
137
+ ultralytics/models/sam/modules/memory_attention.py,sha256=XilWBnRfH8wZxIoL2-yEk-dRypCsS0Jf_9t8WJxXKg0,9722
138
+ ultralytics/models/sam/modules/sam.py,sha256=1U2XGskHymvhZ8OFKYzTEfAI9zJuqWn-d1qonC57dfQ,49397
139
+ ultralytics/models/sam/modules/tiny_encoder.py,sha256=yFbrPMuFuA9LIMFVhA2VvkhwE-JOKdrg5euTkgilPIk,40437
140
+ ultralytics/models/sam/modules/transformer.py,sha256=cUxCPOBfsl3GNhuhC1b9l4j5FuJTb3_e7jD4td5TFhU,16156
141
+ ultralytics/models/sam/modules/utils.py,sha256=HVQiV5P_a1JH_9hZ71Cc0yAkCjw2iML20b_CPErahlE,12315
150
142
  ultralytics/models/utils/__init__.py,sha256=mHtJuK4hwF8cuV-VHDc7tp6u6D1gHz2Z7JI8grmQDTs,42
151
143
  ultralytics/models/utils/loss.py,sha256=PmlKDe4xQTiYkPSCdNUabxJC7bh43zGxiKVIxsXBVGE,15135
152
144
  ultralytics/models/utils/ops.py,sha256=sAeD_koytXDzHibIvQLLAx3vOpGdhdAiQhMiNFUnn5U,13255
@@ -183,7 +175,7 @@ ultralytics/nn/modules/activation.py,sha256=RS0DRDm9r56tojN79X8UBVtiktde9Wasw7GI
183
175
  ultralytics/nn/modules/block.py,sha256=jLXQerl4nXfr4MEGMp9S3YgdTqOJzas1GBxryyXyLV0,34582
184
176
  ultralytics/nn/modules/conv.py,sha256=Ywe87IhuaS22mR2JJ9xjnW8Sb-m7WTjxuqIxV_Dv8lI,12722
185
177
  ultralytics/nn/modules/head.py,sha256=vlp3rMa54kjiuPqP32_RdgOb9KrHItiJx0ih1SFzQec,26853
186
- ultralytics/nn/modules/transformer.py,sha256=8ux2-0ObrafMTYCLucLLVmqk9XWz74bwmWtJGDmgF6Q,18028
178
+ ultralytics/nn/modules/transformer.py,sha256=Lu4WAoIsb8ncM_1-04KSgxFf7oOlQU7RgNfSSmsehr0,18070
187
179
  ultralytics/nn/modules/utils.py,sha256=779QnnKp9v8jv251ESduTXJ0ol8HkIOLbGQWwEGQjhU,3196
188
180
  ultralytics/solutions/__init__.py,sha256=O_G9jh34NnFsHKSA8zcJH0CHtg1Q01JEiRWGwX3vGJY,631
189
181
  ultralytics/solutions/ai_gym.py,sha256=KQdx0RP9t9y1MqYMVlYUSn09SVJSUwKvgxPri_DhczM,4721
@@ -209,15 +201,15 @@ ultralytics/utils/autobatch.py,sha256=POJb9f8dioI7lPGnCc7bdxt0ncftXZa0bvOkip-XoW
209
201
  ultralytics/utils/benchmarks.py,sha256=6tdNcBLATllWpmAMUC6TW7DiCx1VKHhnQN4vkoqN3sE,23866
210
202
  ultralytics/utils/checks.py,sha256=hBkhOinWRzhpA5SbY1v-wCMdFeOemORRlmKBXgwoHYo,28498
211
203
  ultralytics/utils/dist.py,sha256=NDFga-uKxkBX2zLxFHSene_cCiGQJoyOeCXcN9JIOIk,2358
212
- ultralytics/utils/downloads.py,sha256=NB9UDas5f8Rzxt_PS1vDKkSgCxcJ0R_-pjNyZ8E3OUM,21897
204
+ ultralytics/utils/downloads.py,sha256=1ZO23RgotSRP-qo5RVlHkSMCNQnV7UZj0Gm1UqvjTcQ,21898
213
205
  ultralytics/utils/errors.py,sha256=GqP_Jgj_n0paxn8OMhn3DTCgoNkB2WjUcUaqs-M6SQk,816
214
206
  ultralytics/utils/files.py,sha256=TVfY0Wi5IsUc4YdsDzC0dAg-jAP5exYvwqB3VmXhDLY,6761
215
207
  ultralytics/utils/instance.py,sha256=5daM5nkxBv9hr5QzyII8zmuFj24hHuNtcr4EMCHAtpY,15654
216
208
  ultralytics/utils/loss.py,sha256=mDHGmF-gjggAUVhI1dkCm7TtfZHCwz25XKm4M2xJKLs,33916
217
209
  ultralytics/utils/metrics.py,sha256=UXMhBnTtMcpTANxmQqcYkVnj8NeAt39gZez0g6jbrW0,53786
218
- ultralytics/utils/ops.py,sha256=WJHyjyTH8xl5bRkBX0JB3K1sHAGONHx_joubUewE0A8,32709
210
+ ultralytics/utils/ops.py,sha256=hLXY4Nk-dckRvUwT5Jwmc_n5abQimYLuAunFZfuSpy8,32713
219
211
  ultralytics/utils/patches.py,sha256=Oo3DkP7MbXnNGvPfoFSocAkVvaPh9kwMT_9RQUfjVhI,3594
220
- ultralytics/utils/plotting.py,sha256=Bc-8SPs6R1BKMW1V8oVeD-ajMsWP0knAydsoFrB_doU,55522
212
+ ultralytics/utils/plotting.py,sha256=3yFC7uDp7NOPHiLT4TUN7JcsgkPQE71XvhMhbWAmTfo,55519
221
213
  ultralytics/utils/tal.py,sha256=hia39MhWPFpDWOTAXC_5vz-9cUdiRHZs-UcTnxD4Dlo,16112
222
214
  ultralytics/utils/torch_utils.py,sha256=fvt3J2Oh1SgUcjUGSFK8sCKhCp826y6S7NBEiDGZpbI,28985
223
215
  ultralytics/utils/triton.py,sha256=gg1finxno_tY2Ge9PMhmu7PI9wvoFZoiicdT4Bhqv3w,3936
@@ -233,9 +225,9 @@ ultralytics/utils/callbacks/neptune.py,sha256=5Z3ua5YBTUS56FH8VQKQG1aaIo9fH8GEyz
233
225
  ultralytics/utils/callbacks/raytune.py,sha256=ODVYzy-CoM4Uge0zjkh3Hnh9nF2M0vhDrSenXnvcizw,705
234
226
  ultralytics/utils/callbacks/tensorboard.py,sha256=QEgOVhUqY9akOs5TJIwz1Rvn6l32xWLpOxlwEyWF0B8,4136
235
227
  ultralytics/utils/callbacks/wb.py,sha256=9-fjQIdLjr3b73DTE3rHO171KvbH1VweJ-bmbv-rqTw,6747
236
- ultralytics-8.2.71.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
237
- ultralytics-8.2.71.dist-info/METADATA,sha256=neVOnXCAh1rp6O9ps9cdZbw_Pns6ZW0v8_Va4Prqy8k,41337
238
- ultralytics-8.2.71.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
239
- ultralytics-8.2.71.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
240
- ultralytics-8.2.71.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
241
- ultralytics-8.2.71.dist-info/RECORD,,
228
+ ultralytics-8.2.73.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
229
+ ultralytics-8.2.73.dist-info/METADATA,sha256=SrVbNh9F_FEsdLNshgdAEjHXTA-oNYm1yR7VBTq9Igg,41270
230
+ ultralytics-8.2.73.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
231
+ ultralytics-8.2.73.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
232
+ ultralytics-8.2.73.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
233
+ ultralytics-8.2.73.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- # Ultralytics YOLO 🚀, AGPL-3.0 license
2
-
3
- from .model import SAM2
4
- from .predict import SAM2Predictor
5
-
6
- __all__ = "SAM2", "SAM2Predictor" # tuple or list
@@ -1,156 +0,0 @@
1
- # Ultralytics YOLO 🚀, AGPL-3.0 license
2
-
3
- import torch
4
-
5
- from ultralytics.utils.downloads import attempt_download_asset
6
-
7
- from .modules.encoders import FpnNeck, Hiera, ImageEncoder, MemoryEncoder
8
- from .modules.memory_attention import MemoryAttention, MemoryAttentionLayer
9
- from .modules.sam2 import SAM2Model
10
-
11
-
12
- def build_sam2_t(checkpoint=None):
13
- """Build and return a Segment Anything Model (SAM2) tiny-size model with specified architecture parameters."""
14
- return _build_sam2(
15
- encoder_embed_dim=96,
16
- encoder_stages=[1, 2, 7, 2],
17
- encoder_num_heads=1,
18
- encoder_global_att_blocks=[5, 7, 9],
19
- encoder_window_spec=[8, 4, 14, 7],
20
- encoder_backbone_channel_list=[768, 384, 192, 96],
21
- checkpoint=checkpoint,
22
- )
23
-
24
-
25
- def build_sam2_s(checkpoint=None):
26
- """Builds and returns a small-size Segment Anything Model (SAM2) with specified architecture parameters."""
27
- return _build_sam2(
28
- encoder_embed_dim=96,
29
- encoder_stages=[1, 2, 11, 2],
30
- encoder_num_heads=1,
31
- encoder_global_att_blocks=[7, 10, 13],
32
- encoder_window_spec=[8, 4, 14, 7],
33
- encoder_backbone_channel_list=[768, 384, 192, 96],
34
- checkpoint=checkpoint,
35
- )
36
-
37
-
38
- def build_sam2_b(checkpoint=None):
39
- """Builds and returns a Segment Anything Model (SAM2) base-size model with specified architecture parameters."""
40
- return _build_sam2(
41
- encoder_embed_dim=112,
42
- encoder_stages=[2, 3, 16, 3],
43
- encoder_num_heads=2,
44
- encoder_global_att_blocks=[12, 16, 20],
45
- encoder_window_spec=[8, 4, 14, 7],
46
- encoder_window_spatial_size=[14, 14],
47
- encoder_backbone_channel_list=[896, 448, 224, 112],
48
- checkpoint=checkpoint,
49
- )
50
-
51
-
52
- def build_sam2_l(checkpoint=None):
53
- """Build and return a Segment Anything Model (SAM2) large-size model with specified architecture parameters."""
54
- return _build_sam2(
55
- encoder_embed_dim=144,
56
- encoder_stages=[2, 6, 36, 4],
57
- encoder_num_heads=2,
58
- encoder_global_att_blocks=[23, 33, 43],
59
- encoder_window_spec=[8, 4, 16, 8],
60
- encoder_backbone_channel_list=[1152, 576, 288, 144],
61
- checkpoint=checkpoint,
62
- )
63
-
64
-
65
- def _build_sam2(
66
- encoder_embed_dim=1280,
67
- encoder_stages=[2, 6, 36, 4],
68
- encoder_num_heads=2,
69
- encoder_global_att_blocks=[7, 15, 23, 31],
70
- encoder_backbone_channel_list=[1152, 576, 288, 144],
71
- encoder_window_spatial_size=[7, 7],
72
- encoder_window_spec=[8, 4, 16, 8],
73
- checkpoint=None,
74
- ):
75
- """Builds a SAM2 model with specified architecture parameters and optional checkpoint loading."""
76
- image_encoder = ImageEncoder(
77
- trunk=Hiera(
78
- embed_dim=encoder_embed_dim,
79
- num_heads=encoder_num_heads,
80
- stages=encoder_stages,
81
- global_att_blocks=encoder_global_att_blocks,
82
- window_pos_embed_bkg_spatial_size=encoder_window_spatial_size,
83
- window_spec=encoder_window_spec,
84
- ),
85
- neck=FpnNeck(
86
- d_model=256,
87
- backbone_channel_list=encoder_backbone_channel_list,
88
- fpn_top_down_levels=[2, 3],
89
- fpn_interp_model="nearest",
90
- ),
91
- scalp=1,
92
- )
93
- memory_attention = MemoryAttention(d_model=256, pos_enc_at_input=True, num_layers=4, layer=MemoryAttentionLayer())
94
- memory_encoder = MemoryEncoder(out_dim=64)
95
-
96
- sam2 = SAM2Model(
97
- image_encoder=image_encoder,
98
- memory_attention=memory_attention,
99
- memory_encoder=memory_encoder,
100
- num_maskmem=7,
101
- image_size=1024,
102
- sigmoid_scale_for_mem_enc=20.0,
103
- sigmoid_bias_for_mem_enc=-10.0,
104
- use_mask_input_as_output_without_sam=True,
105
- directly_add_no_mem_embed=True,
106
- use_high_res_features_in_sam=True,
107
- multimask_output_in_sam=True,
108
- iou_prediction_use_sigmoid=True,
109
- use_obj_ptrs_in_encoder=True,
110
- add_tpos_enc_to_obj_ptrs=True,
111
- only_obj_ptrs_in_the_past_for_eval=True,
112
- pred_obj_scores=True,
113
- pred_obj_scores_mlp=True,
114
- fixed_no_obj_ptr=True,
115
- multimask_output_for_tracking=True,
116
- use_multimask_token_for_obj_ptr=True,
117
- multimask_min_pt_num=0,
118
- multimask_max_pt_num=1,
119
- use_mlp_for_obj_ptr_proj=True,
120
- compile_image_encoder=False,
121
- sam_mask_decoder_extra_args=dict(
122
- dynamic_multimask_via_stability=True,
123
- dynamic_multimask_stability_delta=0.05,
124
- dynamic_multimask_stability_thresh=0.98,
125
- ),
126
- )
127
-
128
- if checkpoint is not None:
129
- checkpoint = attempt_download_asset(checkpoint)
130
- with open(checkpoint, "rb") as f:
131
- state_dict = torch.load(f)["model"]
132
- sam2.load_state_dict(state_dict)
133
- sam2.eval()
134
- return sam2
135
-
136
-
137
- sam_model_map = {
138
- "sam2_t.pt": build_sam2_t,
139
- "sam2_s.pt": build_sam2_s,
140
- "sam2_b.pt": build_sam2_b,
141
- "sam2_l.pt": build_sam2_l,
142
- }
143
-
144
-
145
- def build_sam2(ckpt="sam_b.pt"):
146
- """Constructs a Segment Anything Model (SAM2) based on the specified checkpoint, with various size options."""
147
- model_builder = None
148
- ckpt = str(ckpt) # to allow Path ckpt types
149
- for k in sam_model_map.keys():
150
- if ckpt.endswith(k):
151
- model_builder = sam_model_map.get(k)
152
-
153
- if not model_builder:
154
- raise FileNotFoundError(f"{ckpt} is not a supported SAM model. Available models are: \n {sam_model_map.keys()}")
155
-
156
- return model_builder(ckpt)
@@ -1,97 +0,0 @@
1
- # Ultralytics YOLO 🚀, AGPL-3.0 license
2
- """
3
- SAM2 model interface.
4
-
5
- This module provides an interface to the Segment Anything Model (SAM2) from Ultralytics, designed for real-time image
6
- segmentation tasks. The SAM2 model allows for promptable segmentation with unparalleled versatility in image analysis,
7
- and has been trained on the SA-1B dataset. It features zero-shot performance capabilities, enabling it to adapt to new
8
- image distributions and tasks without prior knowledge.
9
-
10
- Key Features:
11
- - Promptable segmentation
12
- - Real-time performance
13
- - Zero-shot transfer capabilities
14
- - Trained on SA-1B dataset
15
- """
16
-
17
- from ultralytics.models.sam import SAM
18
-
19
- from .build import build_sam2
20
- from .predict import SAM2Predictor
21
-
22
-
23
- class SAM2(SAM):
24
- """
25
- SAM2 class for real-time image segmentation using the Segment Anything Model (SAM2).
26
-
27
- This class extends the SAM base class, providing an interface to the SAM2 model for promptable segmentation
28
- tasks. It supports loading pre-trained weights and offers zero-shot performance capabilities.
29
-
30
- Attributes:
31
- model (torch.nn.Module): The loaded SAM2 model.
32
- task_map (Dict[str, Type[SAM2Predictor]]): Mapping of 'segment' task to SAM2Predictor.
33
-
34
- Methods:
35
- __init__: Initializes the SAM2 model with pre-trained weights.
36
- _load: Loads specified weights into the SAM2 model.
37
-
38
- Examples:
39
- >>> sam2 = SAM2("sam2_b.pt")
40
- >>> sam2._load('path/to/sam2_weights.pt')
41
- >>> task_map = sam2.task_map
42
- >>> print(task_map)
43
- {'segment': SAM2Predictor}
44
-
45
- Notes:
46
- - Supports .pt and .pth file extensions for model weights.
47
- - Offers zero-shot transfer capabilities for new image distributions and tasks.
48
- """
49
-
50
- def __init__(self, model="sam2_b.pt") -> None:
51
- """
52
- Initializes the SAM2 model with a pre-trained model file.
53
-
54
- Args:
55
- model (str): Path to the pre-trained SAM2 model file. File should have a .pt or .pth extension.
56
-
57
- Raises:
58
- NotImplementedError: If the model file extension is not .pt or .pth.
59
-
60
- Examples:
61
- >>> sam2 = SAM2("sam2_b.pt")
62
- """
63
- super().__init__(model=model)
64
-
65
- def _load(self, weights: str, task=None):
66
- """
67
- Loads the specified weights into the SAM2 model.
68
-
69
- This method is responsible for loading pre-trained weights into the SAM2 model. It supports loading
70
- weights from files with .pt or .pth extensions.
71
-
72
- Args:
73
- weights (str): Path to the weights file. Should be a file with .pt or .pth extension.
74
- task (str | None): Task name. If provided, it may be used to configure model-specific settings.
75
-
76
- Examples:
77
- >>> sam2_model = SAM2()
78
- >>> sam2_model._load('path/to/sam2_weights.pt')
79
- """
80
- self.model = build_sam2(weights)
81
-
82
- @property
83
- def task_map(self):
84
- """
85
- Provides a mapping from the 'segment' task to its corresponding 'Predictor'.
86
-
87
- Returns:
88
- (Dict[str, Type[SAM2Predictor]]): A dictionary mapping the 'segment' task to its corresponding
89
- SAM2Predictor class.
90
-
91
- Examples:
92
- >>> sam2 = SAM2()
93
- >>> task_map = sam2.task_map
94
- >>> print(task_map)
95
- {'segment': SAM2Predictor}
96
- """
97
- return {"segment": {"predictor": SAM2Predictor}}
@@ -1 +0,0 @@
1
- # Ultralytics YOLO 🚀, AGPL-3.0 license