Last active
February 24, 2020 10:39
-
-
Save bagusnl/d92289df161b4455696438c1d5a532b7 to your computer and use it in GitHub Desktop.
CLI Batch for waifu2x-converter-cpp by DeadSix27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
title waifu2x CLI | |
echo waifu2x CLI | |
:start | |
echo Select processing units for waifu2x | |
.\waifu2x-converter-cpp.exe -l | |
set /p processor="Enter processor ID: " | |
if '%processor%' == '' goto start | |
echo. | |
cls | |
goto threadcount | |
:threadcount | |
echo Set thread count for processing "(>1)" | |
set /p thread="Thread count: " | |
if '%thread%' == '' goto threadcount | |
echo. | |
cls | |
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 | |
cls | |
echo Scaler Only Mode | |
echo. | |
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. | |
cls | |
goto inputfile | |
:noise | |
cls | |
echo Noise Reduction Only Mode | |
echo. | |
echo Set desired noise level (0-3) | |
set /p noisel="Noise level: " | |
set modeset=-m noise --noise-level %noisel% | |
echo. | |
cls | |
goto inputfile | |
:snr | |
cls | |
echo Scale and Noise Reduction Mode | |
echo. | |
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. | |
cls | |
goto inputfile | |
:inputfile | |
cls | |
.\waifu2x-converter-cpp.exe --list-opencv-formats | |
echo. | |
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: " | |
if '%inputfile%' == '' goto inputfile | |
echo. | |
goto outputfile | |
:outputfile | |
cls | |
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: " | |
if '%outputfile%' == '' goto outputfile | |
echo. | |
goto inputformat | |
:inputformat | |
cls | |
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: " | |
cls | |
if '%inputformat%'=='1' goto jpg | |
if '%inputformat%'=='2' goto png | |
if '%inputformat%'=='3' goto confirmation | |
echo. | |
:jpg | |
echo Set JPEG/JPG/WebM compression quality (0-100), 100 = Max quality, larger file | |
set /p jpgcomp="Input compression value: " | |
if '%jpgcomp%' == '' set jpgcomp=100 | |
echo. | |
set compcommand=-q %jpgcomp% | |
goto confirmation | |
:png | |
echo Set PNG compression value (0-9), 9 = Max compression (slow,smallest) | |
set /p pngcomp="Input compression value: " | |
if '%pngcomp%' == '' set pngcomp=0 | |
echo. | |
set compcommand=-c %pngcomp% | |
goto confirmation | |
:confirmation | |
cls | |
echo Please confirm your input! | |
echo. | |
echo Processor list: | |
.\waifu2x-converter-cpp.exe -l | |
echo Your choice is number %processor% | |
echo. | |
echo You want to use %thread% thread(s) | |
echo. | |
if '%mode%'=='1' echo You are using Scale Only Mode | |
if '%mode%'=='2' echo You are using Noise Reduction Only Mode | |
if '%mode%'=='3' echo You are using Scale and Noise Reduction Mode | |
echo. | |
echo Your JPEG/JPG/WebM compression quality is '%jpgcomp%' (ignore if you pick PNG/Anything else in the input format menu) | |
echo. | |
echo Your JPEG/JPG/WebM compression quality is '%pngcomp%' (ignore if you pick JPEG/Anything else in the input format menu) | |
echo. | |
pause | |
:process | |
cls | |
.\waifu2x-converter-cpp.exe -p %processor% -j %thread% %compcommand% %modeset% -i %inputfile% -o %outputfile% | |
goto complete | |
:complete | |
echo. | |
echo Process complete! | |
echo. | |
echo Do you want to open the output file? | |
choice | |
if '%ERRORLEVEL%' == '1' %outputfile% | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DeadSix27's waifu2x download https://github.com/DeadSix27/waifu2x-converter-cpp/releases
simply put the batch into the same folder as the waifu2x-converter-cpp.exe and you're ready to go