This commit is contained in:
Glenn Jocher 2019-11-30 17:13:21 -08:00
parent 3cdbf246c9
commit e28a425384
2 changed files with 7 additions and 9 deletions

View File

@ -200,8 +200,8 @@ if __name__ == '__main__':
parser.add_argument('--cfg', type=str, default='cfg/yolov3-spp.cfg', help='cfg file path') parser.add_argument('--cfg', type=str, default='cfg/yolov3-spp.cfg', help='cfg file path')
parser.add_argument('--data', type=str, default='data/coco.data', help='coco.data file path') parser.add_argument('--data', type=str, default='data/coco.data', help='coco.data file path')
parser.add_argument('--weights', type=str, default='weights/yolov3-spp.weights', help='path to weights file') parser.add_argument('--weights', type=str, default='weights/yolov3-spp.weights', help='path to weights file')
parser.add_argument('--batch-size', type=int, default=16, help='size of each image batch') parser.add_argument('--batch-size', type=int, default=2, help='size of each image batch')
parser.add_argument('--img-size', type=int, default=416, help='inference size (pixels)') parser.add_argument('--img-size', type=int, default=800, help='inference size (pixels)')
parser.add_argument('--iou-thres', type=float, default=0.5, help='iou threshold required to qualify as detected') parser.add_argument('--iou-thres', type=float, default=0.5, help='iou threshold required to qualify as detected')
parser.add_argument('--conf-thres', type=float, default=0.001, help='object confidence threshold') parser.add_argument('--conf-thres', type=float, default=0.001, help='object confidence threshold')
parser.add_argument('--nms-thres', type=float, default=0.5, help='iou threshold for non-maximum suppression') parser.add_argument('--nms-thres', type=float, default=0.5, help='iou threshold for non-maximum suppression')

View File

@ -423,10 +423,8 @@ class LoadImagesAndLabels(Dataset): # for training/testing
# Letterbox # Letterbox
h, w = img.shape[:2] h, w = img.shape[:2]
if self.rect: shape = self.batch_shapes[self.batch[index]] if self.rect else self.img_size # final letterboxed shape
img, ratio, pad = letterbox(img, self.batch_shapes[self.batch[index]], mode='rect') img, ratio, pad = letterbox(img, shape, auto=False)
else:
img, ratio, pad = letterbox(img, self.img_size, mode='square')
# Load labels # Load labels
labels = [] labels = []
@ -610,7 +608,7 @@ def load_mosaic(self, index):
return img4, labels4 return img4, labels4
def letterbox(img, new_shape=(416, 416), color=(128, 128, 128), mode='auto', interp=cv2.INTER_AREA): def letterbox(img, new_shape=(416, 416), color=(128, 128, 128), auto=True, scaleFill=False, interp=cv2.INTER_AREA):
# Resize a rectangular image to a 32 pixel multiple rectangle # Resize a rectangular image to a 32 pixel multiple rectangle
# https://github.com/ultralytics/yolov3/issues/232 # https://github.com/ultralytics/yolov3/issues/232
shape = img.shape[:2] # current shape [height, width] shape = img.shape[:2] # current shape [height, width]
@ -623,9 +621,9 @@ def letterbox(img, new_shape=(416, 416), color=(128, 128, 128), mode='auto', int
# Compute padding # Compute padding
dw, dh = new_shape[1] - new_unpad[0], new_shape[0] - new_unpad[1] # wh padding dw, dh = new_shape[1] - new_unpad[0], new_shape[0] - new_unpad[1] # wh padding
if mode is 'auto': # minimum rectangle if auto: # minimum rectangle
dw, dh = np.mod(dw, 32), np.mod(dh, 32) # wh padding dw, dh = np.mod(dw, 32), np.mod(dh, 32) # wh padding
elif mode is 'scaleFill': # stretch elif scaleFill: # stretch
dw, dh = 0.0, 0.0 dw, dh = 0.0, 0.0
new_unpad = new_shape new_unpad = new_shape
ratio = new_shape[0] / shape[1], new_shape[1] / shape[0] # width, height ratios ratio = new_shape[0] / shape[1], new_shape[1] / shape[0] # width, height ratios