Update README.md
This commit is contained in:
parent
aecddf273a
commit
72250c44a6
101
README.md
101
README.md
|
@ -1,53 +1,6 @@
|
|||
## PyTorch Implementation of [AnimeGANv2](https://github.com/TachibanaYoshino/AnimeGANv2)
|
||||
|
||||
|
||||
**Torch Hub Usage**
|
||||
|
||||
You can load Animegan v2 via `torch.hub`:
|
||||
|
||||
```python
|
||||
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](https://pytorch.org/docs/stable/hub.html)):
|
||||
```python
|
||||
model = torch.hub.load(
|
||||
"bryandlee/animegan2-pytorch",
|
||||
"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:
|
||||
```python
|
||||
model = torch.hub.load("bryandlee/animegan2-pytorch", "generator", pretrained="celeba_distill")
|
||||
model = torch.hub.load("bryandlee/animegan2-pytorch", "generator", pretrained="face_paint_512_v1")
|
||||
model = torch.hub.load("bryandlee/animegan2-pytorch", "generator", pretrained="face_paint_512_v2")
|
||||
model = torch.hub.load("bryandlee/animegan2-pytorch", "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`:
|
||||
```python
|
||||
face2paint = torch.hub.load(
|
||||
'bryandlee/animegan2-pytorch', 'face2paint',
|
||||
size=512, device="cpu"
|
||||
)
|
||||
|
||||
img = Image.open(...).convert("RGB")
|
||||
out = face2paint(model, img)
|
||||
```
|
||||
|
||||
**Updates**
|
||||
|
||||
* `2021-10-17` Add weights for [face portrait v2](https://github.com/bryandlee/animegan2-pytorch#additional-models)
|
||||
|
@ -55,6 +8,10 @@ out = face2paint(model, img)
|
|||
|
||||
See demo: [![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 model can be loaded using torch.hub.
|
||||
|
||||
|
||||
## Basic Usage
|
||||
|
||||
**Weight Conversion from the Original Repo (Requires TensorFlow 1.x)**
|
||||
```
|
||||
|
@ -81,7 +38,7 @@ python test.py --input_dir [image_folder_path] --device [cpu/cuda]
|
|||
|
||||
|
||||
|
||||
## Additional Models
|
||||
## Additional Model Weights
|
||||
|
||||
**Webtoon Face** [[ckpt]](https://drive.google.com/file/d/10T6F3-_RFOCJn6lMb-6mRmcISuYWJXGc)
|
||||
|
||||
|
@ -132,3 +89,51 @@ Trained on <b>512x512</b> face images. Compared to v1, `🔻beautify` `🔺robus
|
|||
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
## Torch Hub Usage
|
||||
|
||||
You can load Animegan v2 via `torch.hub`:
|
||||
|
||||
```python
|
||||
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](https://pytorch.org/docs/stable/hub.html)):
|
||||
```python
|
||||
model = torch.hub.load(
|
||||
"bryandlee/animegan2-pytorch",
|
||||
"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:
|
||||
```python
|
||||
model = torch.hub.load("bryandlee/animegan2-pytorch", "generator", pretrained="celeba_distill")
|
||||
model = torch.hub.load("bryandlee/animegan2-pytorch", "generator", pretrained="face_paint_512_v1")
|
||||
model = torch.hub.load("bryandlee/animegan2-pytorch", "generator", pretrained="face_paint_512_v2")
|
||||
model = torch.hub.load("bryandlee/animegan2-pytorch", "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`:
|
||||
```python
|
||||
face2paint = torch.hub.load(
|
||||
'bryandlee/animegan2-pytorch', 'face2paint',
|
||||
size=512, device="cpu"
|
||||
)
|
||||
|
||||
img = Image.open(...).convert("RGB")
|
||||
out = face2paint(model, img)
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue