GithubHelp home page GithubHelp logo

reginal-gerald / waifu2x-chainer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tsurumeso/waifu2x-chainer

0.0 1.0 0.0 185.55 MB

Chainer implementation of waifu2x

License: MIT License

Shell 3.02% Batchfile 2.97% Python 94.01%

waifu2x-chainer's Introduction

waifu2x-chainer

This is a Chainer implementation of waifu2x [1]. Note that the training procedure of waifu2x-chainer may be slightly different from original waifu2x.

Summary

  • 2D character picture (Kagamine Rin) is licensed under CC BY-NC by piapro [2].

Requirements

  • Chainer
  • CuPy (for GPU support)
  • Matplotlib (for benchmark)
  • ONNX-Chainer (for ONNX model export)
  • Pillow
  • Wand (for training)

Installation

Install Python packages

pip install chainer
pip install pillow

Enable GPU support

Install CuPy precompiled binary package which includes the latest version of cuDNN library.
See: CuPy Installation Guide

Getting waifu2x-chainer

git clone https://github.com/tsurumeso/waifu2x-chainer.git

Testing

cd waifu2x-chainer
python waifu2x.py

Usage

Omitting --gpu (-g) option run on CPU.

Noise reduction

python waifu2x.py --method noise --noise_level 1 --input path/to/image/or/directory --arch VGG7 --gpu 0

python waifu2x.py -m noise -n 0 -i path/to/image/or/directory -a 0 -g 0
python waifu2x.py -m noise -n 2 -i path/to/image/or/directory -a 0 -g 0
python waifu2x.py -m noise -n 3 -i path/to/image/or/directory -a 0 -g 0

2x upscaling

python waifu2x.py --method scale --input path/to/image/or/directory --arch VGG7 --gpu 0

python waifu2x.py -m scale -i path/to/image/or/directory -a 0 -g 0

Noise reduction + 2x upscaling

python waifu2x.py --method noise_scale --noise_level 1 --input path/to/image/or/directory --arch VGG7 --gpu 0

python waifu2x.py -m noise_scale -n 0 -i path/to/image/or/directory -a 0 -g 0
python waifu2x.py -m noise_scale -n 2 -i path/to/image/or/directory -a 0 -g 0
python waifu2x.py -m noise_scale -n 3 -i path/to/image/or/directory -a 0 -g 0

Train your own model

Install Wand

sudo apt install libmagickwand-dev
pip install wand

For more details, please refer template training script at appendix/linux or appendix/windows . In my case, 5000 JPEG images are used for pretraining and 1000 noise-free-PNG images for finetuning.

Convert Chainer models to ONNX and Caffe models

Install ONNX-Chainer

pip install onnx-chainer

Run script

cd appendix
python convert_models.py

Results are saved at the same directory of the original models (e.g. models/vgg7/anime_style_scale_rgb.npz to models/vgg7/anime_style_scale_rgb.caffemodel).
Note: Since chainer.CaffeFunction does not currently support Slice layer, some models skip conversion to caffemodel.

References

waifu2x-chainer's People

Contributors

tsurumeso avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.