dgenerate-ultralytics-headless 8.3.181__py3-none-any.whl → 8.3.182__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dgenerate-ultralytics-headless
3
- Version: 8.3.181
3
+ Version: 8.3.182
4
4
  Summary: Automatically built Ultralytics package with python-opencv-headless dependency instead of python-opencv
5
5
  Author-email: Glenn Jocher <glenn.jocher@ultralytics.com>, Jing Qiu <jing.qiu@ultralytics.com>
6
6
  Maintainer-email: Ultralytics <hello@ultralytics.com>
@@ -1,4 +1,4 @@
1
- dgenerate_ultralytics_headless-8.3.181.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
1
+ dgenerate_ultralytics_headless-8.3.182.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
2
2
  tests/__init__.py,sha256=b4KP5_q-2IO8Br8YHOSLYnn7IwZS81l_vfEF2YPa2lM,894
3
3
  tests/conftest.py,sha256=LXtQJcFNWPGuzauTGkiXgsvVC3llJKfg22WcmhRzuQc,2593
4
4
  tests/test_cli.py,sha256=EMf5gTAopOnIz8VvzaM-Qb044o7D0flnUHYQ-2ffOM4,5670
@@ -8,7 +8,8 @@ tests/test_exports.py,sha256=CY-4xVZlVM16vdyIC0mSR3Ix59aiZm1qjFGIhSNmB20,11007
8
8
  tests/test_integrations.py,sha256=kl_AKmE_Qs1GB0_91iVwbzNxofm_hFTt0zzU6JF-pg4,6323
9
9
  tests/test_python.py,sha256=-qvdeg-hEcKU5mWSDEU24iFZ-i8FAwQRznSXpkp6WQ4,27928
10
10
  tests/test_solutions.py,sha256=tuf6n_fsI8KvSdJrnc-cqP2qYdiYqCWuVrx0z9dOz3Q,13213
11
- ultralytics/__init__.py,sha256=OqBNN1EOKn4_vq1OWj-ax36skQmjTn4HuE7IOLGpaI0,730
11
+ ultralytics/__init__.py,sha256=NmFp8Z3Rk0s1QZu4IuBv2wLLf-Pc5DLFdycD5Y49Keg,730
12
+ ultralytics/py.typed,sha256=la67KBlbjXN-_-DfGNcdOcjYumVpKG_Tkw-8n5dnGB4,8
12
13
  ultralytics/assets/bus.jpg,sha256=wCAZxJecGR63Od3ZRERe9Aja1Weayrb9Ug751DS_vGM,137419
13
14
  ultralytics/assets/zidane.jpg,sha256=Ftc4aeMmen1O0A3o6GCDO9FlfBslLpTAw0gnetx7bts,50427
14
15
  ultralytics/cfg/__init__.py,sha256=Uj1br3-NVFvP6VY5CL4PK63mAQAom93XFC5cqSbM6t4,39887
@@ -151,13 +152,13 @@ ultralytics/models/sam/__init__.py,sha256=iR7B06rAEni21eptg8n4rLOP0Z_qV9y9PL-L93
151
152
  ultralytics/models/sam/amg.py,sha256=IpcuIfC5KBRiF4sdrsPl1ecWEJy75axo1yG23r5BFsw,11783
152
153
  ultralytics/models/sam/build.py,sha256=J6n-_QOYLa63jldEZmhRe9D3Is_AJE8xyZLUjzfRyTY,12629
153
154
  ultralytics/models/sam/model.py,sha256=j1TwsLmtxhiXyceU31VPzGVkjRXGylphKrdPSzUJRJc,7231
154
- ultralytics/models/sam/predict.py,sha256=awE_46I-GmYRIeDDLmGIdaYwJvPeSbw316DyanrA1Ys,86453
155
+ ultralytics/models/sam/predict.py,sha256=R32JjExRBL5c2zBcDdauhX4UM8E8kMrBLoa0sZ9vk6I,86494
155
156
  ultralytics/models/sam/modules/__init__.py,sha256=lm6MckFYCPTbqIoX7w0s_daxdjNeBeKW6DXppv1-QUM,70
156
157
  ultralytics/models/sam/modules/blocks.py,sha256=lnMhnexvXejzhixWRQQyqjrpALoIhuOSwnSGW-c9kZk,46089
157
158
  ultralytics/models/sam/modules/decoders.py,sha256=U9jqFRkD0JmO3eugSmwLD0sQkiGqJJLympWNO83osGM,25638
158
159
  ultralytics/models/sam/modules/encoders.py,sha256=srtxrfy3SfUarkC41L1S8tY4GdFueUuR2qQDFZ6ZPl4,37362
159
160
  ultralytics/models/sam/modules/memory_attention.py,sha256=F1XJAxSwho2-LMlrao_ij0MoALTvhkK-OVghi0D4cU0,13651
160
- ultralytics/models/sam/modules/sam.py,sha256=ACI2wA-FiWwj5ctHMHJIi_ZMw4ujrBkHEaZ77X1De_Y,55649
161
+ ultralytics/models/sam/modules/sam.py,sha256=CjM4M2PfRltQFnHFOp2G6QAdYk9BxWlurx82FSX_TYo,55760
161
162
  ultralytics/models/sam/modules/tiny_encoder.py,sha256=lmUIeZ9-3M-C3YmJBs13W6t__dzeJloOl0qFR9Ll8ew,42241
162
163
  ultralytics/models/sam/modules/transformer.py,sha256=xc2g6gb0jvr7cJkHkzIbZOGcTrmsOn2ojvuH-MVIMVs,14953
163
164
  ultralytics/models/sam/modules/utils.py,sha256=-PYSLExtBajbotBdLan9J07aFaeXJ03WzopAv4JcYd4,16022
@@ -250,7 +251,7 @@ ultralytics/utils/loss.py,sha256=fbOWc3Iu0QOJiWbi-mXWA9-1otTYlehtmUsI7os7ydM,397
250
251
  ultralytics/utils/metrics.py,sha256=tQjYxPd0dSzjucVyI1evIISunyYRkABXMXVQo64mAUE,68756
251
252
  ultralytics/utils/ops.py,sha256=8d60fbpntrexK3gPoLUS6mWAYGrtrQaQCOYyRJsCjuI,34521
252
253
  ultralytics/utils/patches.py,sha256=PPWiKzwGbCvuawLzDKVR8tWOQAlZbJBi8g_-A6eTCYA,6536
253
- ultralytics/utils/plotting.py,sha256=IEugKlTITLxArZjbSr7i_cTaHHAqNwVVk08Ak7I_ZdM,47169
254
+ ultralytics/utils/plotting.py,sha256=4TG_J8rz9VVPrOXbdjRHPJZVgJrFYVmEYE0BcVDdolc,47745
254
255
  ultralytics/utils/tal.py,sha256=aXawOnhn8ni65tJWIW-PYqWr_TRvltbHBjrTo7o6lDQ,20924
255
256
  ultralytics/utils/torch_utils.py,sha256=D76Pvmw5OKh-vd4aJkOMO0dSLbM5WzGr7Hmds54hPEk,39233
256
257
  ultralytics/utils/triton.py,sha256=M7qe4RztiADBJQEWQKaIQsp94ERFJ_8_DUHDR6TXEOM,5410
@@ -266,8 +267,8 @@ ultralytics/utils/callbacks/neptune.py,sha256=j8pecmlcsM8FGzLKWoBw5xUsi5t8E5HuxY
266
267
  ultralytics/utils/callbacks/raytune.py,sha256=S6Bq16oQDQ8BQgnZzA0zJHGN_BBr8iAM_WtGoLiEcwg,1283
267
268
  ultralytics/utils/callbacks/tensorboard.py,sha256=MDPBW7aDes-66OE6YqKXXvqA_EocjzEMHWGM-8z9vUQ,5281
268
269
  ultralytics/utils/callbacks/wb.py,sha256=Tm_-aRr2CN32MJkY9tylpMBJkb007-MSRNSQ7rDJ5QU,7521
269
- dgenerate_ultralytics_headless-8.3.181.dist-info/METADATA,sha256=6a7UOAonIPqJS7OoY1QQ6pBR1hIhPk4Tu5Rb-RSlINU,38727
270
- dgenerate_ultralytics_headless-8.3.181.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
271
- dgenerate_ultralytics_headless-8.3.181.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
272
- dgenerate_ultralytics_headless-8.3.181.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
273
- dgenerate_ultralytics_headless-8.3.181.dist-info/RECORD,,
270
+ dgenerate_ultralytics_headless-8.3.182.dist-info/METADATA,sha256=9mclDbKNmjy6iHAfrNiWQ6ub-pJajkvFPmjeHl25Ios,38727
271
+ dgenerate_ultralytics_headless-8.3.182.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
272
+ dgenerate_ultralytics_headless-8.3.182.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
273
+ dgenerate_ultralytics_headless-8.3.182.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
274
+ dgenerate_ultralytics_headless-8.3.182.dist-info/RECORD,,
ultralytics/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
2
 
3
- __version__ = "8.3.181"
3
+ __version__ = "8.3.182"
4
4
 
5
5
  import os
6
6
 
@@ -1032,3 +1032,4 @@ class SAM2Model(torch.nn.Module):
1032
1032
  self.image_size = imgsz[0]
1033
1033
  self.sam_prompt_encoder.input_image_size = imgsz
1034
1034
  self.sam_prompt_encoder.image_embedding_size = [x // 16 for x in imgsz] # fixed ViT patch size of 16
1035
+ self.sam_image_embedding_size = self.image_size // self.backbone_stride # update image embedding size
@@ -1283,6 +1283,7 @@ class SAM2VideoPredictor(SAM2Predictor):
1283
1283
  - If `batch` is greater than 1, the features are expanded to fit the batch size.
1284
1284
  - The method leverages the model's `_prepare_backbone_features` method to prepare the backbone features.
1285
1285
  """
1286
+ self.model.set_imgsz(self.imgsz)
1286
1287
  backbone_out = self.model.forward_image(im)
1287
1288
  if batch > 1: # expand features if there's more than one prompt
1288
1289
  for i, feat in enumerate(backbone_out["backbone_fpn"]):
ultralytics/py.typed ADDED
@@ -0,0 +1 @@
1
+ partial
@@ -361,38 +361,46 @@ class Annotator:
361
361
  lineType=cv2.LINE_AA,
362
362
  )
363
363
 
364
- def masks(self, masks, colors, im_gpu, alpha: float = 0.5, retina_masks: bool = False):
364
+ def masks(self, masks, colors, im_gpu: torch.Tensor = None, alpha: float = 0.5, retina_masks: bool = False):
365
365
  """
366
366
  Plot masks on image.
367
367
 
368
368
  Args:
369
- masks (torch.Tensor): Predicted masks on cuda, shape: [n, h, w]
369
+ masks (torch.Tensor | np.ndarray): Predicted masks with shape: [n, h, w]
370
370
  colors (List[List[int]]): Colors for predicted masks, [[r, g, b] * n]
371
- im_gpu (torch.Tensor): Image is in cuda, shape: [3, h, w], range: [0, 1]
371
+ im_gpu (torch.Tensor | None): Image is in cuda, shape: [3, h, w], range: [0, 1]
372
372
  alpha (float, optional): Mask transparency: 0.0 fully transparent, 1.0 opaque.
373
373
  retina_masks (bool, optional): Whether to use high resolution masks or not.
374
374
  """
375
375
  if self.pil:
376
376
  # Convert to numpy first
377
377
  self.im = np.asarray(self.im).copy()
378
- if len(masks) == 0:
379
- self.im[:] = im_gpu.permute(1, 2, 0).contiguous().cpu().numpy() * 255
380
- if im_gpu.device != masks.device:
381
- im_gpu = im_gpu.to(masks.device)
382
- colors = torch.tensor(colors, device=masks.device, dtype=torch.float32) / 255.0 # shape(n,3)
383
- colors = colors[:, None, None] # shape(n,1,1,3)
384
- masks = masks.unsqueeze(3) # shape(n,h,w,1)
385
- masks_color = masks * (colors * alpha) # shape(n,h,w,3)
386
-
387
- inv_alpha_masks = (1 - masks * alpha).cumprod(0) # shape(n,h,w,1)
388
- mcs = masks_color.max(dim=0).values # shape(n,h,w,3)
389
-
390
- im_gpu = im_gpu.flip(dims=[0]) # flip channel
391
- im_gpu = im_gpu.permute(1, 2, 0).contiguous() # shape(h,w,3)
392
- im_gpu = im_gpu * inv_alpha_masks[-1] + mcs
393
- im_mask = im_gpu * 255
394
- im_mask_np = im_mask.byte().cpu().numpy()
395
- self.im[:] = im_mask_np if retina_masks else ops.scale_image(im_mask_np, self.im.shape)
378
+ if im_gpu is None:
379
+ assert isinstance(masks, np.ndarray), "`masks` must be a np.ndarray if `im_gpu` is not provided."
380
+ overlay = self.im.copy()
381
+ for i, mask in enumerate(masks):
382
+ overlay[mask.astype(bool)] = colors[i]
383
+ self.im = cv2.addWeighted(self.im, 1 - alpha, overlay, alpha, 0)
384
+ else:
385
+ assert isinstance(masks, torch.Tensor), "`masks` must be a torch.Tensor if `im_gpu` is provided."
386
+ if len(masks) == 0:
387
+ self.im[:] = im_gpu.permute(1, 2, 0).contiguous().cpu().numpy() * 255
388
+ if im_gpu.device != masks.device:
389
+ im_gpu = im_gpu.to(masks.device)
390
+ colors = torch.tensor(colors, device=masks.device, dtype=torch.float32) / 255.0 # shape(n,3)
391
+ colors = colors[:, None, None] # shape(n,1,1,3)
392
+ masks = masks.unsqueeze(3) # shape(n,h,w,1)
393
+ masks_color = masks * (colors * alpha) # shape(n,h,w,3)
394
+
395
+ inv_alpha_masks = (1 - masks * alpha).cumprod(0) # shape(n,h,w,1)
396
+ mcs = masks_color.max(dim=0).values # shape(n,h,w,3)
397
+
398
+ im_gpu = im_gpu.flip(dims=[0]) # flip channel
399
+ im_gpu = im_gpu.permute(1, 2, 0).contiguous() # shape(h,w,3)
400
+ im_gpu = im_gpu * inv_alpha_masks[-1] + mcs
401
+ im_mask = im_gpu * 255
402
+ im_mask_np = im_mask.byte().cpu().numpy()
403
+ self.im[:] = im_mask_np if retina_masks else ops.scale_image(im_mask_np, self.im.shape)
396
404
  if self.pil:
397
405
  # Convert im back to PIL and update draw
398
406
  self.fromarray(self.im)