From 1a04cd38e7285969c0e4d827f4fbe52c834798ed Mon Sep 17 00:00:00 2001 From: Vitaly Fralenko Date: Thu, 25 Jan 2024 23:02:29 +0300 Subject: [PATCH] Fix Yolo 8.0.206 scale bug (#7821) --- ultralytics/utils/ops.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ultralytics/utils/ops.py b/ultralytics/utils/ops.py index 5632fd90..5f02dabc 100644 --- a/ultralytics/utils/ops.py +++ b/ultralytics/utils/ops.py @@ -362,8 +362,8 @@ def scale_image(masks, im0_shape, ratio_pad=None): else: # gain = ratio_pad[0][0] pad = ratio_pad[1] - top, left = (int(round(pad[1] - 0.1)), int(round(pad[0] - 0.1))) # y, x - bottom, right = (int(round(im1_shape[0] - pad[1] + 0.1)), int(round(im1_shape[1] - pad[0] + 0.1))) + top, left = int(pad[1]), int(pad[0]) # y, x + bottom, right = int(im1_shape[0] - pad[1]), int(im1_shape[1] - pad[0]) if len(masks.shape) < 2: raise ValueError(f'"len of masks shape" should be 2 or 3, but got {len(masks.shape)}') @@ -731,8 +731,8 @@ def scale_masks(masks, shape, padding=True): if padding: pad[0] /= 2 pad[1] /= 2 - top, left = (int(round(pad[1] - 0.1)), int(round(pad[0] - 0.1))) if padding else (0, 0) # y, x - bottom, right = (int(round(mh - pad[1] + 0.1)), int(round(mw - pad[0] + 0.1))) + top, left = (int(pad[1]), int(pad[0])) if padding else (0, 0) # y, x + bottom, right = (int(mh - pad[1]), int(mw - pad[0])) masks = masks[..., top:bottom, left:right] masks = F.interpolate(masks, shape, mode="bilinear", align_corners=False) # NCHW