## PyTorch Implementation of [AnimeGANv2](https://github.com/TachibanaYoshino/AnimeGANv2)
**Updates**
* `2021-10-17` Add weights for [FacePortraitV2](#additional-model-weights). [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/bryandlee/animegan2-pytorch/blob/main/colab_demo.ipynb)
![sample](https://user-images.githubusercontent.com/26464535/142294796-54394a4a-a566-47a1-b9ab-4e715b901442.gif)
* `2021-11-07` Thanks to [ak92501](https://twitter.com/ak92501), a [web demo](https://huggingface.co/spaces/akhaliq/AnimeGANv2) is integrated to [Huggingface Spaces](https://huggingface.co/spaces) with [Gradio](https://github.com/gradio-app/gradio). [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/akhaliq/AnimeGANv2)
* `2021-11-07` Thanks to [xhlulu](https://github.com/xhlulu), the `torch.hub` model is now available. See [Torch Hub Usage](#torch-hub-usage).
## Basic Usage
**Inference**
```
python test.py --input_dir [image_folder_path] --device [cpu/cuda]
```
## Torch Hub Usage
You can load the model via `torch.hub`:
```python
import torch
model = torch.hub.load("bryandlee/animegan2-pytorch", "generator").eval()
out = model(img_tensor) # BCHW tensor
```
Currently, the following `pretrained` shorthands are available:
```python
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:
```python
from PIL import Image
face2paint = torch.hub.load("bryandlee/animegan2-pytorch:main", "face2paint", size=512)
img = Image.open(...).convert("RGB")
out = face2paint(model, img)
```
More details about `torch.hub` is in [the torch docs](https://pytorch.org/docs/stable/hub.html)
## Weight Conversion from the Original Repo (Tensorflow)
1. Install the [original repo's dependencies](https://github.com/TachibanaYoshino/AnimeGANv2#requirements): python 3.6, tensorflow 1.15.0-gpu
2. Install torch >= 1.7.1
3. Clone the original repo & run
```
git clone https://github.com/TachibanaYoshino/AnimeGANv2
python convert_weights.py
```
<details>
<summary>samples</summary>
<br>
Results from converted `Paprika` style model (input image, original tensorflow result, pytorch result from left to right)
<img src="./samples/compare/1.jpg" width="960">
<img src="./samples/compare/2.jpg" width="960">
<img src="./samples/compare/3.jpg" width="960">
</details>
**Note:** Results from converted weights slightly different due to the [bilinear upsample issue](https://github.com/pytorch/pytorch/issues/10604)
## Additional Model Weights
**Webtoon Face** [[ckpt]](https://drive.google.com/file/d/10T6F3-_RFOCJn6lMb-6mRmcISuYWJXGc)
<details>
<summary>samples</summary>
Trained on <b>256x256</b> face images. Distilled from [webtoon face model](https://github.com/bryandlee/naver-webtoon-faces/blob/master/README.md#face2webtoon) with L2 + VGG + GAN Loss and CelebA-HQ images.
![face_results](https://user-images.githubusercontent.com/26464535/143959011-1740d4d3-790b-4c4c-b875-24404ef9c614.jpg)
</details>
**Face Portrait v1** [[ckpt]](https://drive.google.com/file/d/1WK5Mdt6mwlcsqCZMHkCUSDJxN1UyFi0-)
<details>
<summary>samples</summary>
Trained on <b>512x512</b> face images.
[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1jCqcKekdtKzW7cxiw_bjbbfLsPh-dEds?usp=sharing)
![samples](https://user-images.githubusercontent.com/26464535/127134790-93595da2-4f8b-4aca-a9d7-98699c5e6914.jpg)
[ðº](https://youtu.be/CbMfI-HNCzw?t=317)
![sample](https://user-images.githubusercontent.com/26464535/129888683-98bb6283-7bb8-4d1a-a04a-e795f5858dcf.gif)
</details>
**Face Portrait v2** [[ckpt]](https://drive.google.com/uc?id=18H3iK09_d54qEDoWIc82SyWB2xun4gjU)
<details>
<summary>samples</summary>
Trained on <b>512x512</b> face images. Compared to v1, `ð»beautify` `ðºrobustness`
[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1jCqcKekdtKzW7cxiw_bjbbfLsPh-dEds?usp=sharing)
![face_portrait_v2_0](https://user-images.githubusercontent.com/26464535/137619176-59620b59-4e20-4d98-9559-a424f86b7f24.jpg)
![face_portrait_v2_1](https://user-images.githubusercontent.com/26464535/137619181-a45c9230-f5e7-4f3c-8002-7c266f89de45.jpg)
ð¦ ð® ð¥
![face_portrait_v2_squid_game](https://user-images.githubusercontent.com/26464535/137619183-20e94f11-7a8e-4c3e-9b45-378ab63827ca.jpg)
</details>
程序媛一枚~
- 粉丝: 4w+
- 资源: 30
最新资源
- 永磁同步电机(pmsm)模型预测控制(MPC)matla b simulink仿真模型,有PI矢量控制,直接预测控制(有限集模型预测控制)(这个其中包括做了单矢量和双矢量或者可以成为三矢量的有限集预测
- Google Chrome浏览器ChromeDriver驱动下载(Chrome版本:132.0.6834.84)win64
- Google Chrome浏览器ChromeDriver驱动下载(Chrome版本:132.0.6834.84)win32
- 从0到1搭建推荐系统 - 数据驱动的算法与架构设计(带数据集)
- 汇川H3U标准程序,程序有本体脉冲控制的三轴定位,有总线控制的汇川伺服定位,轴点动,回零,相对定位绝对定位,程序结构清晰,分模块控制,是工控者学习的好案例
- 从0到1搭建推荐系统 - 数据驱动的算法与架构设计(带数据集)
- S7-200Smart 恒压供水程序样例+485通讯样例
- 基于simulink三自由度汽车操纵模型(侧向,侧倾,横摆)带数据参数,有详细公式文档 具有特殊性,发出不 哦(高于或等于MATLAB 2016a版本的都可打开模型)
- C++编写,qt框架,windows串口调试助手,多线程运行,性能好,效率高,不丢数据,保证代码质量
- 从0到1搭建推荐系统 - 数据驱动的算法与架构设计(带数据集)
- . NET C# WPF图书管理系统源码 .net C# WPF图书管理系统源码 自己开发,纯源码 主要技术:C#、基于wpf开发、sql server数据库的增删改查 源码特点:代码完整规范,采
- 西门子Smart200和台达ⅤFD一M系列变频器通讯程序 Smart和三菱E700或D7O0变频器通讯程序,程序带注释,包括接线图纸,变频器参数设置,全都有,拿到即可以用,节约开发时间
- ofdm 水声通信 qpsk fpga
- COMSOL手性超材料文献模拟模型 计算左右旋圆偏振下的吸收、反射、透射率(材料参数未与文献一致 趋势吻合)
- 昆仑通态MCGS与3台力士乐VFC-x610变频器通讯程序 实现昆仑通态触摸屏与3台力士乐VFC-x610变频器通讯,程序稳定可靠 器件:昆仑通态TPC7062KD触摸屏,3台力士乐VFC-x610变
- Unity3d 基于UniStorm插件和xx天气API实现实时天气系统源码工程
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈