## 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>
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
animegan2-pytorch 是一个基于 PyTorch 实现的动漫图像生成模型 AnimeGAN v2 的代码库。它是用于生成高质量动漫风格图像的深度学习模型。 AnimeGAN v2 是对原始 AnimeGAN 模型的改进和优化,通过引入条件生成器和多尺度判别器等技术,提升了生成图像的质量和多样性。 animegan2-pytorch-main 代码库包含了 AnimeGAN v2 的训练和测试代码,以及预训练模型和数据集处理代码。通过使用这个代码库,你可以训练自己的 AnimeGAN v2 模型,也可以使用预训练模型生成动漫风格的图像。 你可以在 GitHub 上找到 animegan2-pytorch-main 代码库的地址和相关资源。以下是一些相关链接: animegan2-pytorch-main GitHub 代码库:https://github.com/TachibanaYoshino/AnimeGANv2 这个代码库包含了 animegan2-pytorch-main 的源代码、模型和数据集。你可以从这里下载代码并开始使用。 AnimeGAN v2 论
资源推荐
资源详情
资源评论
收起资源包目录
animegan2-pytorch-main.rar (20个子文件)
animegan2-pytorch-main
weights
face_paint_512_v1.pt 8.2MB
face_paint_512_v2.pt 8.2MB
paprika.pt 8.2MB
celeba_distill.pt 8.2MB
LICENSE 1KB
samples
compare
2.jpg 1.26MB
1.jpg 863KB
3.jpg 1.4MB
inputs
2.jpg 536KB
1.jpg 719KB
3.jpg 227KB
hubconf.py 2KB
demo.ipynb 812KB
model.py 4KB
convert_weights.py 4KB
colab_demo.ipynb 38KB
requirements.txt 26B
.gitignore 2KB
test.py 2KB
README.md 5KB
共 20 条
- 1
资源评论
睿科知识云
- 粉丝: 2w+
- 资源: 227
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 英语日常词汇分类.doc
- 英语动词单三变化规则与名词单数变复数口诀.doc
- 幼教、少儿创新教育课程《快乐记忆》系列课程市场运营方案报告.doc
- 在阳光中奔跑[800字]作文.doc
- 语文必修三理解性默写填空.doc
- 中考语文答题套路(人版).doc
- 中学课程设置方案.doc
- 家庭教育及亲子沟通公益讲座讲稿.doc
- 综合实践我国象棋教学案.doc
- 不安全化学品储罐区隐患排查表.doc
- 教师行为规范心得体会.doc
- 建设工程合同模板管理试题A卷与答案.doc
- 科教版八年级物理(上册)期末测试题及答案.doc
- 牛津高中英语模块一至模块十一短语.doc
- 鲁迅的儿童教育思想-王敏.doc
- H3C SecPath F1000F5000FW插卡vFW系列防火墙 命令参考(V7)(R8X60-R9X60-E8X60-E9X60-E1185)-6W614
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功