From 2370a5513ebf67bd10b8d15fd6353e008380bc43 Mon Sep 17 00:00:00 2001 From: "Mr.Li" <1055271769@qq.com> Date: Thu, 22 Dec 2022 21:55:09 +0800 Subject: [PATCH] Bugfix: update dataloaders.py to fix "resize to 0" (#10558) * fix bug "resize to 0" * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Use math.ceil() for resize to enforce min floor of 1 pixel Signed-off-by: Glenn Jocher Signed-off-by: Glenn Jocher Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher --- utils/dataloaders.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/dataloaders.py b/utils/dataloaders.py index 302cc33..cbb3114 100644 --- a/utils/dataloaders.py +++ b/utils/dataloaders.py @@ -737,7 +737,7 @@ class LoadImagesAndLabels(Dataset): r = self.img_size / max(h0, w0) # ratio if r != 1: # if sizes are not equal interp = cv2.INTER_LINEAR if (self.augment or r > 1) else cv2.INTER_AREA - im = cv2.resize(im, (int(w0 * r), int(h0 * r)), interpolation=interp) + im = cv2.resize(im, (math.ceil(w0 * r), math.ceil(h0 * r)), interpolation=interp) return im, (h0, w0), im.shape[:2] # im, hw_original, hw_resized return self.ims[i], self.im_hw0[i], self.im_hw[i] # im, hw_original, hw_resized