Turn Photos into Studio Ghibli‑Style Anime with AnimeGAN – A Hands‑On Guide

This article introduces AnimeGAN, a lightweight GAN that converts real photos into Japanese anime‑style illustrations, explains its architecture, loss functions, model size advantages, and provides step‑by‑step instructions with code for setting up, training, and testing the TensorFlow implementation.

Programmer DD
Programmer DD
Programmer DD
Turn Photos into Studio Ghibli‑Style Anime with AnimeGAN – A Hands‑On Guide

Introduction

Although the 2019 Turing Award honored computer graphics and Pixar 3D animation, many still find 2‑D anime more appealing. Models that transform real images into the hand‑drawn style of masters like Miyazaki and Shinkai are especially exciting.

Recent discoveries such as CartoonGAN and AnimeGAN can generate impressive anime‑style images. A new TensorFlow project implements AnimeGAN and offers pretrained models for immediate experimentation.

Project Overview

The AnimeGAN repository ( https://github.com/TachibanaYoshino/AnimeGAN ) provides the code and pretrained weights. The authors compare AnimeGAN with CartoonGAN and ComixGAN, showing superior detail, more natural colors, and a style closer to Miyazaki’s work.

Method Summary

AnimeGAN follows a conventional convolutional generator‑discriminator architecture, enhanced with instance normalization and a novel Leaky ReLU activation. The authors introduce three new loss functions:

Grayscale style loss

Grayscale adversarial loss

Color reconstruction loss

These losses help the generated images better match true comic styles.

Model Size and Speed

Compared with CartoonGAN, AnimeGAN is lightweight, with fewer parameters and faster inference. On a P100 GPU, generating a single image takes about 2.3 seconds.

Implementation Details

Required dependencies (all common in computer‑vision projects): python 3.6.8, tensorflow‑gpu 1.8, opencv, tqdm, numpy, glob, argparse.

!git clone https://github.com/TachibanaYoshino/AnimeGAN

Download pretrained models and dataset with the following shell script (download_staffs.sh):

URL=https://github.com/TachibanaYoshino/AnimeGAN/releases/download/Haoyao-style_V1.0/Haoyao-style.zip
ZIP_FILE=./checkpoint/Haoyao-style.zip
TARGET_DIR=./checkpoint/saved_model
mkdir -p ./checkpoint
wget -N $URL -O $ZIP_FILE
mkdir -p $TARGET_DIR
unzip $ZIP_FILE -d $TARGET_DIR
rm $ZIP_FILE

DatesetURL=https://github.com/TachibanaYoshino/AnimeGAN/releases/download/dataset-1/dataset.zip
ZIP_FILE=./dataset.zip
TARGET_DIR=./dataset
rm -rf dataset
wget -N $DatesetURL -O $ZIP_FILE
unzip $ZIP_FILE -d $TARGET_DIR
rm $ZIP_FILE

VGG_FILE=./vgg19_weight/vgg19.npy
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1U5HCRpZWAbDVLipNoF8t0ZHpwCRX7kdF' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1
/p')&id=1U5HCRpZWAbDVLipNoF8t0ZHpwCRX7kdF" -O $VGG_FILE && rm -rf /tmp/cookies.txt

Run the script to fetch all assets: !bash download_staffs.sh Train the model (example for Hayao style, 101 epochs):

!python main.py --phase train --dataset Hayao --epoch 101 --init_epoch 1

Test the model by placing test images in dataset/test/real and executing:

!python test.py --checkpoint_dir checkpoint/saved_model --test_dir dataset/test/real --style_name H

Results are saved in the results folder. The overall speed is fast, making the project enjoyable to try.

Conclusion

AnimeGAN is a lightweight, effective GAN for photo‑to‑anime style transfer, requiring only unpaired real and anime images for training, which are easy to collect. Its small model size and fast inference make it suitable for experimentation and creative applications.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Deep LearningGANTensorFlowStyle TransferAnimeGANimage-to-anime
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.