Fix predicted mask shape mismatch (#21083)

Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Laughing 2025-06-17 19:30:08 +08:00 committed by GitHub
parent ac012a7465
commit 54eb54a23c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -111,7 +111,11 @@ class SegmentationValidator(DetectionValidator):
pred["masks"] = (
self.process(proto[i], coefficient, pred["bboxes"], shape=imgsz)
if len(coefficient)
else torch.zeros((0, imgsz[0], imgsz[1]), dtype=torch.uint8, device=pred["bboxes"].device)
else torch.zeros(
(0, *(imgsz if self.process is ops.process_mask_native else proto.shape[2:])),
dtype=torch.uint8,
device=pred["bboxes"].device,
)
)
return preds