From 76cd1d16506e35a047c597524e163a71b993e4d4 Mon Sep 17 00:00:00 2001 From: Niles Rogoff Date: Fri, 27 Jan 2017 16:38:31 -0500 Subject: [PATCH] Initial commit --- README.md | 11 +++++++++++ upscale.py | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 README.md create mode 100755 upscale.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..c14a9be --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +## Upscale Wrapper + +### Usage + +`upscale [outfile] [noise reduction level]` + +If outfile is not given, it will try to guess. + +Valid values for the noise reduction argument are `0`, `1` and `2`, with 0 being off and 2 being the most aggressive. The default is off + +It will try to upscale it 2x. diff --git a/upscale.py b/upscale.py new file mode 100755 index 0000000..725849a --- /dev/null +++ b/upscale.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# waifu2x-converter-cpp -j 2 --scale_ratio 2.0 --noise_level 2 -m noise_scale -o mpv-shot0011.png -i mpv-shot0011.jpg +import subprocess, sys, os +null = open(os.devnull, "w") +infile = sys.argv[1] +outfile = ".".join(sys.argv[1].split(".")[:-1]) + "-waifu2x.png" +noise_level = False +if len(sys.argv) > 2: + outfile = sys.argv[2] +if len(sys.argv) > 3: + noise_level = int(sys.argv[3]) +if not noise_level or noise_level == 0: + noise_level = ["-m", "scale"] +else: + noise_level = ["-m", "noise_scale", "--noise_level", str(noise_level)] +args = ["waifu2x-converter-cpp", "-j", "2", *noise_level, "-o", outfile, "-i", infile] +print(" ".join(args)) +subprocess.call(args, stdout=null) +null.close() +print("Written to " + outfile)