Skip to content

Instantly share code, notes, and snippets.

@bagusnl
Created June 9, 2019 10:39
Show Gist options
  • Save bagusnl/a91dc6d2243c1bf498e78d0d99b3a0a2 to your computer and use it in GitHub Desktop.
Save bagusnl/a91dc6d2243c1bf498e78d0d99b3a0a2 to your computer and use it in GitHub Desktop.
CLI Batch for waifu2x-converter-cpp by DeadSix27
@echo off
echo waifu2x CLI
:start
echo Select processing units for waifu2x
.\waifu2x-converter-cpp.exe -l
set /p processor="Enter processor ID: "
echo.
goto threadcount
:threadcount
echo Set thread count for processing "(>1)"
set /p thread="Thread count: "
echo.
goto mode
:mode
echo Select waifu2x mode
echo 1 scale only
echo 2 noise reduction only
echo 3 scale+noise reduction
set /p mode="Mode: "
echo.
if '%mode%'=='1' goto scale
if '%mode%'=='2' goto noise
if '%mode%'=='3' goto snr
:scale
echo Set desired scale ratio (1~2)
echo Scale value above 2 is NOT recommended
set /p scaler="Scale ratio: "
set modeset=-m scale --scale-ratio %scaler%
echo.
goto inputfile
:noise
echo Set desired noise level (0-3)
set /p noisel="Noise level: "
set modeset=-m noise --noise-level %noisel%
echo.
goto inputfile
:snr
echo Set desired scale ratio (1~2)
echo Scale value above 2 is NOT recommended
set /p scaler="Scale ratio: "
echo.
echo Set desired noise level (0-3)
set /p noisel="Noise level: "
set modeset=-m noise-scale --scale-ratio %scaler% --noise-level %noisel%
echo.
goto inputfile
:inputfile
.\waifu2x-converter-cpp.exe --list-opencv-formats
echo Please input your image filepath
echo Example: "C:\path\to\image\input\file.jpg"
echo You can drop the file here
set /p inputfile="Image input filepath: "
echo.
goto outputfile
:outputfile
echo Please input your output image filepath
echo Example: "C:\path\to\image\output\file.jpg"
echo The extension should match the inputfile
set /p outputfile="Image output filepath: "
echo.
goto inputformat
:inputformat
echo Select your input format
echo 1 JPEG/JPG/WebM
echo 2 PNG
echo 3 Anything else (or if you're not sure about the format)
set /p inputformat="Input format: "
if '%inputformat%'=='1' goto jpg
if '%inputformat%'=='2' goto png
if '%inputformat%'=='3' goto startstd
echo.
:jpg
echo Set JPEG/JPG/WebM compression quality (0-100), 100 = Max quality, larger file
set /p jpgcomp="Input compression value: "
echo.
goto startjpg
:png
echo Set PNG compression value (0-9), 9 = Max compression (slow,smallest)
set /p pngcomp="Input compression value: "
echo.
goto startpng
:startjpg
.\waifu2x-converter-cpp.exe -p %processor% -j %thread% -q %jpgcomp% %modeset% -i %inputfile% -o %outputfile%
goto complete
:startpng
.\waifu2x-converter-cpp.exe -p %processor% -j %thread% -c %pngcomp% %modeset% -i %inputfile% -o %outputfile%
goto complete
:complete
echo Process complete!
pause
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment