default="./Test/t1.png") parser.add_argument('--scale', help='Scaling factor of the model', default=2) parser.add_argument('--epoch', help='Number of epochs during training', default=100) parser.add_argument('--lr', help='Sets the learning rate', default=0.01) args = parser.parse_args() ARGS = dict() ARGS["SCALE"] = int(args.scale) main_ckpt_dir = "./checkpoints" if not os.path.exists(main_ckpt_dir): os.makedirs(main_ckpt_dir) ARGS["CKPT_dir"] = main_ckpt_dir + "/checkpoint" + "_sc" + str(args.scale) ARGS["CKPT"] = ARGS["CKPT_dir"] + "/ESPCN_ckpt_sc" + str(args.scale) ARGS["TRAINDIR"] = args.traindir ARGS["EPOCH_NUM"] = int(args.epoch) ARGS["TESTIMG"] = args.testimg ARGS["LRATE"] = float(args.lr) if args.train: run.training(ARGS) elif args.test: run.test(ARGS) elif args.export: run.export(ARGS)
exit() # Set gpu config = tf.ConfigProto() #log_device_placement=True config.gpu_options.allow_growth = True # Create run instance run = run.run(config, lr_size, ckpt_path, scale, args.batch, args.epochs, args.lr, args.fromscratch, fsrcnn_params, small, args.validdir) if args.train: # if finetune, load model and train on general100 if args.finetune: traindir = args.finetunedir augmented_path = "./augmented_general100" # augment (if not done before) and then load images data_utils.augment(traindir, save_path=augmented_path) run.train(augmented_path) if args.test: run.testFromPb(args.image) #run.test(args.image) #run.upscale(args.image) if args.export: run.export() print("I ran successfully.")
else: print( "No checkpoint directory. Choose scale 2, 3 or 4. Or add checkpoint directory for this scale." ) exit() # Set gpu os.environ["CUDA_VISIBLE_DEVICES"] = "4" config = tf.compat.v1.ConfigProto() config.gpu_options.allow_growth = True print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU'))) # Create run instance run = run.run(config, ckpt_path, scale, args.batch, args.epochs, args.B, args.F, args.lr, args.fromscratch, meanbgr) if args.train: run.train(args.traindir, args.validdir) if args.test: run.test() if args.upscale: print('Test image: ', args.image) run.upscaleFromPb(args.image) #run.upscale(args.image) if args.export: run.export(args.quant)