This commit is contained in:
Glenn Jocher 2019-11-30 18:52:37 -08:00
parent 6a05cf56c2
commit 93c348f353
1 changed files with 4 additions and 4 deletions

View File

@ -425,7 +425,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing
# Letterbox # Letterbox
h, w = img.shape[:2] h, w = img.shape[:2]
shape = self.batch_shapes[self.batch[index]] if self.rect else self.img_size # final letterboxed shape shape = self.batch_shapes[self.batch[index]] if self.rect else self.img_size # final letterboxed shape
img, ratio, pad = letterbox(img, shape, auto=False) img, ratio, pad = letterbox(img, shape, auto=False, scaleup=self.augment)
# Load labels # Load labels
labels = [] labels = []
@ -609,16 +609,16 @@ def load_mosaic(self, index):
return img4, labels4 return img4, labels4
def letterbox(img, new_shape=(416, 416), color=(128, 128, 128), auto=True, scaleFill=False, interp=cv2.INTER_AREA): def letterbox(img, new_shape=(416, 416), color=(128, 128, 128),
auto=True, scaleFill=False, scaleup=True, interp=cv2.INTER_AREA):
# Resize image to a 32-pixel-multiple rectangle https://github.com/ultralytics/yolov3/issues/232 # Resize image to a 32-pixel-multiple rectangle https://github.com/ultralytics/yolov3/issues/232
shape = img.shape[:2] # current shape [height, width] shape = img.shape[:2] # current shape [height, width]
if isinstance(new_shape, int): if isinstance(new_shape, int):
new_shape = (new_shape, new_shape) new_shape = (new_shape, new_shape)
# Scale ratio (new / old) # Scale ratio (new / old)
scaleup_ok = True
r = max(new_shape) / max(shape) r = max(new_shape) / max(shape)
if not scaleup_ok: # only scale down if not scaleup: # only scale down, do not scale up (for better test mAP)
r = min(r, 1.0) r = min(r, 1.0)
# Compute padding # Compute padding