https://wiki.archlinux.org/api.php?action=feedcontributions&user=Tremeschin&feedformat=atom
ArchWiki - User contributions [en]
2024-03-29T13:15:02Z
User contributions
MediaWiki 1.41.0
https://wiki.archlinux.org/index.php?title=Waifu2x&diff=571234
Waifu2x
2019-04-15T04:43:17Z
<p>Tremeschin: Typo: "downlaod" to "download"</p>
<hr />
<div>[[Category:Image]]<br />
[[ja:Waifu2x]]<br />
This article covers installing, using and training [https://github.com/nagadomi/waifu2x waifu2x], image super-resolution for anime-style art using deep convolutional neural networks.<br />
<br />
== Installation ==<br />
<br />
To directly use waifu2x, install {{AUR|waifu2x-git}} pakage. There are other alternates for using waifu2x, just search {{ic|waifu2x}} in AUR.<br />
<br />
{{Tip|If you have an NVIDIA GPU, you can install {{Pkg|cuda}} to significantly speed up the conversion process.}}<br />
<br />
== Usage ==<br />
<br />
waifu2x is avaliable with command {{ic|waifu2x}}. For detailed options, run {{ic|waifu2x --help}}<br />
<br />
=== Upscaling ===<br />
<br />
Use {{ic|--scale_ratio}} parameter to specify scale ratio you want. And {{ic|-i}} with input file name, {{ic|-o}} with output file name:<br />
<br />
{{bc|1=<nowiki><br />
waifu2x --scale_ratio 2 -i my_waifu.png -o 2x_my_waifu.png<br />
</nowiki>}}<br />
<br />
=== Noise Reduction ===<br />
<br />
Use {{ic|--noise_level}} parameter({{ic|1}} or {{ic|2}}) to specify noise reduction level:<br />
<br />
{{bc|1=<nowiki><br />
waifu2x --noise_level 1 -i my_waifu.png -o lucid_my_waifu.png<br />
</nowiki>}}<br />
<br />
And you can use {{ic|--jobs}} to specify number of threads launching at same time, benifit for multi-core CPU :<br />
<br />
{{bc|1=<nowiki><br />
waifu2x --jobs 4 --noise_level 1 -i my_waifu.png -o lucid_my_waifu.png<br />
</nowiki>}}<br />
<br />
=== Upscaling & Noise Reduction ===<br />
<br />
{{ic|--scale_ratio}} and {{ic|--noise_level}} can be combined, so you can:<br />
<br />
{{bc|1=<nowiki><br />
waifu2x --scale_ratio 2 --noise_level 1 -i my_waifu.png -o 2x_lucid_my_waifu.png<br />
</nowiki>}}<br />
<br />
{{Tip|If you are finding a batch operation interface, you can have a look at this [https://gist.github.com/frantic1048/0970e86c4304b322270edc0ab36dd6a8 waifu2x wrapper script]}}<br />
<br />
== Training ==<br />
<br />
To train custom models, '''an NVIDIA graphical card is required''' because waifu2x uses [https://developer.nvidia.com/cuda-zone CUDA] for computing. Then you need to prepare below develop dependencies and waifu2x source.<br />
<br />
=== Dependencies ===<br />
<br />
Install:<br />
<br />
* {{Pkg|lua51}}<br />
* {{Pkg|cuda}}<br />
* {{Pkg|snappy}}<br />
* {{Pkg|graphicsmagick}}<br />
* {{AUR|torch7-git}}<br />
* {{AUR|torch7-trepl-git}}<br />
* {{AUR|torch7-sys-git}}<br />
* {{AUR|torch7-cutorch-git}}<br />
* {{AUR|torch7-nn-git}}<br />
* {{AUR|torch7-cunn-git}}<br />
* {{AUR|torch7-image-git}}<br />
* {{AUR|torch7-xlua-git}}<br />
* {{AUR|torch7-dok-git}}<br />
* {{AUR|torch7-optim-git}}<br />
* {{AUR|lua51-graphicsmagick-git}}<br />
* {{AUR|lua51-cjson}}<br />
* {{AUR|lua51-csvigo-git}}<br />
* {{AUR|lua51-snappy-git}}<br />
<br />
It is recommended to install below ''optional'' [https://developer.nvidia.com/cudnn cuDNN] library and bindings package. With them you can enable cuDNN backend for training, which have a significant speed up.<br />
<br />
You need to manually download a cudnn binary pack from [https://developer.nvidia.com/cudnn NVIDIA cuDNN site] during installing {{Pkg|cudnn}}.<br />
<br />
* (optional){{Pkg|cudnn}}<br />
* (optional){{AUR|torch7-cudnn-git}}:<br />
<br />
=== waifu2x source ===<br />
<br />
Fetch waifu2x source code from GitHub:<br />
<br />
{{bc|1=<nowiki><br />
git clone --depth 1 https://github.com/nagadomi/waifu2x.git<br />
</nowiki>}}<br />
<br />
Enter source directory. Now you can test waifu2x command line tool:<br />
<br />
{{bc|1=<nowiki><br />
th waifu2x.lua<br />
</nowiki>}}<br />
<br />
=== Command line tools ===<br />
<br />
{{Note|If you have installed cuDNN library, you can use cuDNN with {{ic|-force_cudnn 1}} option. cuDNN is too much faster than default kernel.}}<br />
<br />
==== Noise Reduction ====<br />
<br />
{{bc|1=<nowiki><br />
th waifu2x.lua -m noise -noise_level 1 -i input_image.png -o output_image.png<br />
</nowiki>}}<br />
<br />
{{bc|1=<nowiki><br />
th waifu2x.lua -m noise -noise_level 0 -i input_image.png -o output_image.png<br />
th waifu2x.lua -m noise -noise_level 2 -i input_image.png -o output_image.png<br />
th waifu2x.lua -m noise -noise_level 3 -i input_image.png -o output_image.png<br />
</nowiki>}}<br />
<br />
==== 2x Upscaling ====<br />
<br />
{{bc|1=<nowiki><br />
th waifu2x.lua -m scale -i input_image.png -o output_image.png<br />
</nowiki>}}<br />
<br />
==== Noise Reduction + 2x Upscaling ====<br />
<br />
{{bc|1=<nowiki><br />
th waifu2x.lua -m noise_scale -noise_level 1 -i input_image.png -o output_image.png<br />
</nowiki>}}<br />
<br />
{{bc|1=<nowiki><br />
th waifu2x.lua -m noise_scale -noise_level 0 -i input_image.png -o output_image.png<br />
th waifu2x.lua -m noise_scale -noise_level 2 -i input_image.png -o output_image.png<br />
th waifu2x.lua -m noise_scale -noise_level 3 -i input_image.png -o output_image.png<br />
</nowiki>}}<br />
<br />
For more, see [https://github.com/nagadomi/waifu2x#command-line-tools waifu2x#command-line-tools].<br />
<br />
=== Train your own models ===<br />
<br />
{{Note|If you have installed cuDNN library, you can use cuDNN kernel with {{ic|-backend cudnn}} option. And, you can convert trained cudnn model to cunn model with {{ic|tools/rebuild.lua}}.}}<br />
<br />
{{Note|The command that was used to train for waifu2x's pretraind models is available at {{ic|appendix/train_upconv_7_art.sh}}, {{ic|appendix/train_upconv_7_photo.sh}}. Maybe it is helpful.}}<br />
<br />
==== Data Preparation ====<br />
<br />
Genrating a file list.<br />
<br />
{{bc|1=<nowiki><br />
find /path/to/image/dir -name "*.png" > data/image_list.txt<br />
</nowiki>}}<br />
<br />
{{Note|You should use noise free images.}}<br />
<br />
Converting training data:<br />
<br />
{{bc|1=<nowiki><br />
th convert_data.lua<br />
</nowiki>}}<br />
<br />
==== Train a Noise Reduction(level1) model ====<br />
<br />
{{bc|1=<nowiki><br />
mkdir models/my_model<br />
th train.lua -model_dir models/my_model -method noise -noise_level 1 -test images/miku_noisy.png<br />
# usage<br />
th waifu2x.lua -model_dir models/my_model -m noise -noise_level 1 -i images/miku_noisy.png -o output.png<br />
</nowiki>}}<br />
<br />
You can check the performance of model with {{ic|models/my_model/noise1_best.png}}.<br />
<br />
==== Train a Noise Reduction(level2) model ====<br />
<br />
{{bc|1=<nowiki><br />
th train.lua -model_dir models/my_model -method noise -noise_level 2 -test images/miku_noisy.png<br />
# usage<br />
th waifu2x.lua -model_dir models/my_model -m noise -noise_level 2 -i images/miku_noisy.png -o output.png<br />
</nowiki>}}<br />
<br />
You can check the performance of model with {{ic|models/my_model/noise2_best.png}}.<br />
<br />
==== Train a 2x UpScaling model ====<br />
<br />
{{bc|1=<nowiki><br />
th train.lua -model upconv_7 -model_dir models/my_model -method scale -scale 2 -test images/miku_small.png<br />
# usage<br />
th waifu2x.lua -model_dir models/my_model -m scale -scale 2 -i images/miku_small.png -o output.png<br />
</nowiki>}}<br />
<br />
You can check the performance of model with {{ic|models/my_model/scale2.0x_best.png}}.<br />
<br />
==== Train a 2x and noise reduction fusion model ====<br />
<br />
{{bc|1=<nowiki><br />
th train.lua -model upconv_7 -model_dir models/my_model -method noise_scale -scale 2 -noise_level 1 -test images/miku_small.png<br />
# usage<br />
th waifu2x.lua -model_dir models/my_model -m noise_scale -scale 2 -noise_level 1 -i images/miku_small.png -o output.png<br />
</nowiki>}}<br />
<br />
You can check the performance of model with {{ic|models/my_model/noise1_scale2.0x_best.png}}.<br />
<br />
For latest information, see [https://github.com/nagadomi/waifu2x#train-your-own-model waifu2x#train-your-own-model].<br />
<br />
== Docker ==<br />
<br />
See [https://github.com/nagadomi/waifu2x#docker waifu2x#docker].<br />
<br />
== See also ==<br />
<br />
* [https://github.com/nagadomi/waifu2x waifu2x GitHub repository]</div>
Tremeschin