Go to file
bryandlee 6c2de9660e
Docs: Specify model name for telegram bot
2021-11-08 07:19:25 +09:00
samples upsampling method changed + face model added 2021-02-21 15:04:52 +09:00
weights Add weights from gdrive 2021-11-06 16:57:09 -04:00
.gitignore Initial commit 2021-02-16 20:34:22 +09:00
LICENSE Create LICENSE 2021-08-23 07:45:19 +09:00
README.md Docs: Specify model name for telegram bot 2021-11-08 07:19:25 +09:00
convert_weights.py typo fixed 2021-02-17 14:03:56 +09:00
hubconf.py Change repo username 2021-11-07 01:12:44 -05:00
model.py additional cli 2021-03-03 19:44:57 +09:00
test.py additional cli 2021-03-03 19:44:57 +09:00
test_faces.ipynb upsampling method changed + face model added 2021-02-21 15:04:52 +09:00

README.md

PyTorch Implementation of AnimeGANv2

Updates

Basic Usage

Weight Conversion from the Original Repo (Requires TensorFlow 1.x)

git clone https://github.com/TachibanaYoshino/AnimeGANv2
python convert_weights.py

Inference

python test.py --input_dir [image_folder_path] --device [cpu/cuda]

Results from converted [Paprika] style model

(input image, original tensorflow result, pytorch result from left to right)

     

Note: Training code not included / Results from converted weights slightly different due to the bilinear upsample issue

Additional Model Weights

Webtoon Face [ckpt]

samples

Trained on 256x256 face images. Distilled from webtoon face model with L2 + VGG + GAN Loss and CelebA-HQ images. See test_faces.ipynb for details.

 

Face Portrait v1 [ckpt]

samples

Trained on 512x512 face images.

Colab

samples

📺

sample

Face Portrait v2 [ckpt]

samples

Trained on 512x512 face images. Compared to v1, 🔻beautify 🔺robustness

Colab

face_portrait_v2_0

face_portrait_v2_1

🦑 🎮 🔥

face_portrait_v2_squid_game

Torch Hub Usage

You can load Animegan v2 via torch.hub:

import torch
model = torch.hub.load('bryandlee/animegan2-pytorch', 'generator').eval()
# convert your image into tensor here
out = model(img_tensor)

You can load with various configs (more details in the torch docs):

model = torch.hub.load(
    "bryandlee/animegan2-pytorch:main",
    "generator",
    pretrained=True, # or give URL to a pretrained model
    device="cuda", # or "cpu" if you don't have a GPU
    progress=True, # show progress
)

Currently, the following pretrained shorthands are available:

model = torch.hub.load("bryandlee/animegan2-pytorch:main", "generator", pretrained="celeba_distill")
model = torch.hub.load("bryandlee/animegan2-pytorch:main", "generator", pretrained="face_paint_512_v1")
model = torch.hub.load("bryandlee/animegan2-pytorch:main", "generator", pretrained="face_paint_512_v2")
model = torch.hub.load("bryandlee/animegan2-pytorch:main", "generator", pretrained="paprika")

You can also load the face2paint util function. First, install dependencies:

pip install torchvision Pillow numpy

Then, import the function using torch.hub:

face2paint = torch.hub.load(
    'bryandlee/animegan2-pytorch:main', 'face2paint', 
    size=512, device="cpu"
)

img = Image.open(...).convert("RGB")
out = face2paint(model, img)