def parse_args(): parser = ArgumentParser(description='ProSR') parser.add_argument('-c', '--checkpoint', type=str, required=True, help='Checkpoint') parser.add_argument( '-i', '--input', help= 'Input images, either list or path to folder. If not given, use bicubically downsampled target image as input', type=str, nargs='*', required=False, default=[]) parser.add_argument('-t', '--target', help='Target images, either list or path to folder', type=str, nargs='*', required=False, default=[]) parser.add_argument('-s', '--scale', help='upscale ratio e.g. 2, 4 or 8', type=int, required=True) parser.add_argument('-d', '--downscale', help='Bicubic downscaling of input to LR', action='store_true') parser.add_argument('-f', '--fmt', help='Image file format', type=str, default='*') parser.add_argument('-o', '--output-dir', help='Output folder.', required=True, type=str) parser.add_argument('--cpu', help='Use CPU.', action='store_true') input_args = parser.parse_args() input_args.input = get_filenames(input_args.input, IMG_EXTENSIONS) input_args.target = get_filenames(input_args.target, IMG_EXTENSIONS) log.debug("Parsed inputs") return input_args
def load_dataset(args): files = {'train': {}, 'test': {}} for phase in ['train', 'test']: for ft in ['source', 'target']: if args[phase].dataset.path[ft]: files[phase][ft] = get_filenames(args[phase].dataset.path[ft], image_format=IMG_EXTENSIONS) else: files[phase][ft] = [] return files['train'], files['test']
def parse_args(): parser = ArgumentParser(description='Evaluation') parser.add_argument( '-i', '--input', help='High-resolution images, either list or path to folder', type=str, nargs='*', required=True, default=[]) parser.add_argument( '-t', '--target', help='Super-resolution images, either list or path to folder', type=str, nargs='*', required=True, default=[]) parser.add_argument( '-s', '--scale', help='upscale ratio e.g. 2, 4 or 8', type=int, required=True) args = parser.parse_args() args.input = get_filenames(args.input, IMG_EXTENSIONS) args.target = get_filenames(args.target, IMG_EXTENSIONS) if not len(args.input): error("Did not find images in: {}".format(args.input)) if len(args.input) != len(args.target): error("Inconsistent number of images between 'input' and 'target'") return args
def parse_args(): parser = ArgumentParser(description='ProSR') parser.add_argument('-c', '--checkpoint', type=str, required=True, help='Checkpoint') parser.add_argument( '-i', '--input', help= 'Input images, either list or path to folder. If not given, use bicubically downsampled target image as input', type=str, nargs='*', required=False, default=[]) parser.add_argument('-t', '--target', help='Target images, either list or path to folder', type=str, nargs='*', required=False, default=[]) parser.add_argument('-s', '--scale', help='upscale ratio e.g. 2, 4 or 8', type=int, required=True) parser.add_argument('-d', '--downscale', help='Bicubic downscaling of input to LR', action='store_true') parser.add_argument('-mx', '--max-dimension', help='Split image into chunks of max-dimension.', type=int, required=False, default=0) parser.add_argument('--padding', help='Pad image when splitting into quadrants.', type=int, required=False, default=0) parser.add_argument('-f', '--fmt', help='Image file format', type=str, default='*') parser.add_argument('-o', '--output-dir', help='Output folder.', required=True, type=str) parser.add_argument('--cpu', help='Use CPU.', action='store_true') args = parser.parse_args() args.input = get_filenames(args.input, IMG_EXTENSIONS) args.target = get_filenames(args.target, IMG_EXTENSIONS) return args