`cv2.resize` interpolation fix (#7903)

Fix for https://github.com/ultralytics/yolov5/discussions/7901
This commit is contained in:
Glenn Jocher 2022-05-20 12:59:05 +02:00 committed by GitHub
parent 43569d53da
commit a9a92aec5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -663,7 +663,7 @@ class LoadImagesAndLabels(Dataset):
h0, w0 = im.shape[:2] # orig hw h0, w0 = im.shape[:2] # orig hw
r = self.img_size / max(h0, w0) # ratio r = self.img_size / max(h0, w0) # ratio
if r != 1: # if sizes are not equal if r != 1: # if sizes are not equal
interp = cv2.INTER_LINEAR if self.augment else cv2.INTER_AREA # random.choice(self.rand_interp_methods) 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, (int(w0 * r), int(h0 * r)), interpolation=interp)
return im, (h0, w0), im.shape[:2] # im, hw_original, hw_resized return im, (h0, w0), im.shape[:2] # im, hw_original, hw_resized
else: else: