Introduction

In this tutorial, we are taking images captured by an iPhone camera and transforming them to their anime form. There are 3 differents models to select from, each yielding their own anime version. hayao-v2 generates the best results.

Codebase Updates

  • I forked this repo https://github.com/ptran1203/pytorch-animeGAN to fix a dependency (described below) that was breaking the image conversion process. These changes were made in the inference.py file. I commented out incorrect lines 16 & 148 and made the corrections in lines 17 & 149.
  • I added the model_weights directory and downloaded & stored the pytorch models directly in the repo. Then, in the utils/common.py file, I made changes in the RELEASED_WEIGHTS variable and the load_state_dict(weight, map_location) function, so that the models are being loaded directly from the repo rather than being downloaded from the GitHub URLs every time in the RELEASED_WEIGHTS variable.
  • Finally, I added a results directory with two sub-directories (original & animeify) which contain our original and converted images.

Generating & Comparing Results

Beatrix

Original

Beatrix Original

hayao:v2

To generate results, execute this command in your terminal: python3 inference.py --weight hayao:v2 --src results/original/beatrix.jpg --out results/animeify/beatrix_hayao_v2.jpg Beatrix hayao:v2

shinkai:v2

To generate results, execute this command in your terminal: python3 inference.py --weight shinkai:v2 --src results/original/beatrix.jpg --out results/animeify/beatrix_shinkai_v2.jpg Beatrix shinkai:v2

arcane:v2

To generate results, execute this command in your terminal: python3 inference.py --weight arcane:v2 --src results/original/beatrix.jpg --out results/animeify/beatrix_arcane_v2.jpg Beatrix arcane:v2

Frank

Original

Frank Original

hayao:v2

To generate results, execute this command in your terminal: python3 inference.py --weight hayao:v2 --src results/original/frank.jpg --out results/animeify/frank_hayao_v2.jpg Frank hayao:v2

shinkai:v2

To generate results, execute this command in your terminal: python3 inference.py --weight shinkai:v2 --src results/original/frank.jpg --out results/animeify/frank_shinkai_v2.jpg Frank shinkai:v2

arcane:v2

To generate results, execute this command in your terminal: python3 inference.py --weight arcane:v2 --src results/original/frank.jpg --out results/animeify/frank_arcane_v2.jpg Frank arcane:v2