From 3505b57421322cb1d38dd9774a92d7a0ec79c53c Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 10 Jan 2020 11:55:54 -0800 Subject: [PATCH] updates --- utils/datasets.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/utils/datasets.py b/utils/datasets.py index d0ee7660..f1dccc8e 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -506,17 +506,18 @@ class LoadImagesAndLabels(Dataset): # for training/testing def load_image(self, index): # loads 1 image from dataset, returns img, original hw, resized hw - if self.imgs[index] is None: # not cached + img = self.imgs[index] + if img is None: # not cached img_path = self.img_files[index] img = cv2.imread(img_path) # BGR assert img is not None, 'Image Not Found ' + img_path h0, w0 = img.shape[:2] # orig hw r = self.img_size / max(h0, w0) # resize image to img_size - if self.augment and (r != 1): # always resize down, only resize up if training with augmentation - h, w = int(h0 * r), int(w0 * r) - return cv2.resize(img, (w, h), interpolation=cv2.INTER_LINEAR), (h0, w0), (h, w) # _LINEAR fastest - else: # cached - return self.imgs[index], self.img_hw0[index], self.img_hw[index] # img, hw + if r < 1 or (self.augment and (r != 1)): # always resize down, only resize up if training with augmentation + img = cv2.resize(img, (int(w0 * r), int(h0 * r)), interpolation=cv2.INTER_LINEAR) # _LINEAR fastest + return img, (h0, w0), img.shape[:2] # img, hw_original, hw_resized + else: + return self.imgs[index], self.img_hw0[index], self.img_hw[index] # img, hw_original, hw_resized def augment_hsv(img, hgain=0.5, sgain=0.5, vgain=0.5):