From 067ee264c009d1c730da03d75b37147063798374 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 7 Apr 2020 12:59:52 -0700 Subject: [PATCH] scale_img() bug fix --- utils/torch_utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/utils/torch_utils.py b/utils/torch_utils.py index 42b1645f..adfaf774 100644 --- a/utils/torch_utils.py +++ b/utils/torch_utils.py @@ -120,11 +120,10 @@ def scale_img(img, ratio=1.0, same_shape=True): # img(16,3,256,416), r=ratio h, w = img.shape[2:] s = (int(h * ratio), int(w * ratio)) # new size img = F.interpolate(img, size=s, mode='bilinear', align_corners=False) # resize + p = h - s[0], w - s[1] if not same_shape: # pad/crop img - p = h - s[0], w - s[1] p = [int(math.fmod(x, 64)) for x in p] # pad to 64 grid size - img = F.pad(img, [0, p[1], 0, p[0]], value=0.447) # value = imagenet mean - return img + return F.pad(img, [0, p[1], 0, p[0]], value=0.447) # value = imagenet mean class ModelEMA: