glenn-jocher commited on
Commit
a9a92ae
1 Parent(s): 43569d5

`cv2.resize` interpolation fix (#7903)

Browse files

Fix for https://github.com/ultralytics/yolov5/discussions/7901

Files changed (1) hide show
  1. utils/dataloaders.py +1 -1
utils/dataloaders.py CHANGED
@@ -663,7 +663,7 @@ class LoadImagesAndLabels(Dataset):
663
  h0, w0 = im.shape[:2] # orig hw
664
  r = self.img_size / max(h0, w0) # ratio
665
  if r != 1: # if sizes are not equal
666
- interp = cv2.INTER_LINEAR if self.augment else cv2.INTER_AREA # random.choice(self.rand_interp_methods)
667
  im = cv2.resize(im, (int(w0 * r), int(h0 * r)), interpolation=interp)
668
  return im, (h0, w0), im.shape[:2] # im, hw_original, hw_resized
669
  else:
 
663
  h0, w0 = im.shape[:2] # orig hw
664
  r = self.img_size / max(h0, w0) # ratio
665
  if r != 1: # if sizes are not equal
666
+ interp = cv2.INTER_LINEAR if (self.augment or r > 1) else cv2.INTER_AREA
667
  im = cv2.resize(im, (int(w0 * r), int(h0 * r)), interpolation=interp)
668
  return im, (h0, w0), im.shape[:2] # im, hw_original, hw_resized
669
  else: