`ultralytics 8.3.24` SAM fix `pred_boxes` when no objects segmented (#17215)

Co-authored-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
pull/17216/head^2 v8.3.24
Laughing 4 weeks ago committed by GitHub
parent 542320c041
commit 6c12c1d69f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      ultralytics/__init__.py
  2. 2
      ultralytics/models/sam/predict.py

@ -1,6 +1,6 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license # Ultralytics YOLO 🚀, AGPL-3.0 license
__version__ = "8.3.23" __version__ = "8.3.24"
import os import os

@ -478,7 +478,7 @@ class Predictor(BasePredictor):
results = [] results = []
for masks, orig_img, img_path in zip([pred_masks], orig_imgs, self.batch[0]): for masks, orig_img, img_path in zip([pred_masks], orig_imgs, self.batch[0]):
if len(masks) == 0: if len(masks) == 0:
masks = None masks, pred_bboxes = None, torch.zeros((0, 6), device=pred_masks.device)
else: else:
masks = ops.scale_masks(masks[None].float(), orig_img.shape[:2], padding=False)[0] masks = ops.scale_masks(masks[None].float(), orig_img.shape[:2], padding=False)[0]
masks = masks > self.model.mask_threshold # to bool masks = masks > self.model.mask_threshold # to bool

Loading…
Cancel
Save