From f69a30f053e8be7b30c325dd1b0dedcf8dd44447 Mon Sep 17 00:00:00 2001 From: tsurumeso Date: Thu, 21 Mar 2019 21:27:21 +0900 Subject: [PATCH] Fix #14 --- waifu2x.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/waifu2x.py b/waifu2x.py index 3d98018..214e94c 100644 --- a/waifu2x.py +++ b/waifu2x.py @@ -172,19 +172,20 @@ def load_models(cfg): filelist = [args.input] for path in filelist: - src = Image.open(path) - w, h = src.size[:2] - if args.width != 0: - args.scale_ratio = args.width / w - if args.height != 0: - args.scale_ratio = args.height / h outname, ext = os.path.splitext(os.path.basename(path)) outpath = os.path.join( args.output_dir, '{}.{}'.format(outname, args.extension)) if ext.lower() in extensions: - outname += '_(tta{})'.format(args.tta_level) if args.tta else '_' + src = Image.open(path) + w, h = src.size[:2] + if args.width != 0: + args.scale_ratio = args.width / w + if args.height != 0: + args.scale_ratio = args.height / h + dst = src.copy() start = time.time() + outname += '_(tta{})'.format(args.tta_level) if args.tta else '_' if 'noise_scale' in models: outname += '(noise{}_scale{:.1f}x)'.format( args.noise_level, args.scale_ratio)