def get_data(name, batch): isTrain = name == 'train' if isTrain: augmentors = [ GoogleNetResize(crop_area_fraction=0.49), imgaug.RandomOrderAug([ imgaug.BrightnessScale((0.6, 1.4), clip=False), imgaug.Contrast((0.6, 1.4), clip=False), imgaug.Saturation(0.4, rgb=False), # rgb-bgr conversion for the constants copied from fb.resnet.torch imgaug.Lighting( 0.1, eigval=np.asarray([0.2175, 0.0188, 0.0045][::-1]) * 255.0, eigvec=np.array([[-0.5675, 0.7192, 0.4009], [-0.5808, -0.0045, -0.8140], [-0.5836, -0.6948, 0.4203]], dtype='float32')[::-1, ::-1]) ]), imgaug.Flip(horiz=True), ] else: augmentors = [ imgaug.ResizeShortestEdge(256, cv2.INTER_CUBIC), imgaug.CenterCrop((224, 224)), ] return get_imagenet_dataflow(args.data, name, batch, augmentors)
def get_data(name, batch): isTrain = name == 'train' image_shape = 224 if isTrain: augmentors = [ # use lighter augs if model is too small GoogleNetResize( crop_area_fraction=0.49 if args.width_ratio < 1 else 0.08, target_shape=image_shape), imgaug.RandomOrderAug([ imgaug.BrightnessScale((0.6, 1.4), clip=False), imgaug.Contrast((0.6, 1.4), clip=False), imgaug.Saturation(0.4, rgb=False), ]), imgaug.Flip(horiz=True), ] else: augmentors = [ imgaug.ResizeShortestEdge(int(image_shape * 256 / 224), cv2.INTER_CUBIC), imgaug.CenterCrop((image_shape, image_shape)), ] return get_imagenet_dataflow(args.data_dir, name, batch, augmentors, meta_dir=args.meta_dir)