Eugene Siow
commited on
Commit
·
e1c6348
1
Parent(s):
9c26a9a
Add README.
Browse files- README.md +60 -0
- images/samples1.jpg +0 -0
README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- stylegan2
|
| 5 |
+
- image-generation
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
# AniCharaGAN: Anime Character Generation with StyleGAN2
|
| 9 |
+
|
| 10 |
+
[](https://github.com/eugenesiow/practical-ml)
|
| 11 |
+
|
| 12 |
+
This model uses the awesome lucidrains’s [stylegan2-pytorch](https://github.com/lucidrains/stylegan2-pytorch) library to train a model on a private anime character dataset to generate full-body 256x256 female anime characters.
|
| 13 |
+
|
| 14 |
+
Here are some samples:
|
| 15 |
+
|
| 16 |
+

|
| 17 |
+
|
| 18 |
+
## Model description
|
| 19 |
+
The model generates 256x256, square, white background, full-body anime characters. It is trained using [stylegan2-pytorch](https://github.com/lucidrains/stylegan2-pytorch). It is trained to 150 epochs.
|
| 20 |
+
|
| 21 |
+
## Intended uses & limitations
|
| 22 |
+
You can use the model for generating anime characters and than use a super resolution library like [super_image](https://github.com/eugenesiow/super-image) to upscale.
|
| 23 |
+
|
| 24 |
+
### How to use
|
| 25 |
+
|
| 26 |
+
[](https://colab.research.google.com/github/eugenesiow/practical-ml/blob/master/notebooks/Anime_Character_Generation_with_StyleGAN2.ipynb "Open in Colab")
|
| 27 |
+
|
| 28 |
+
Install the dependencies:
|
| 29 |
+
```bash
|
| 30 |
+
pip install -q stylegan2_pytorch==1.5.10
|
| 31 |
+
```
|
| 32 |
+
Here is how to generate images:
|
| 33 |
+
```python
|
| 34 |
+
import torch
|
| 35 |
+
from torchvision.utils import save_image
|
| 36 |
+
from stylegan2_pytorch import ModelLoader
|
| 37 |
+
from pathlib import Path
|
| 38 |
+
|
| 39 |
+
Path('./models/ani-chara-gan/').mkdir(parents=True, exist_ok=True)
|
| 40 |
+
torch.hub.download_url_to_file('https://huggingface.co/eugenesiow/ani-chara-gan/resolve/main/model.pt',
|
| 41 |
+
'./models/ani-chara-gan/model_150.pt')
|
| 42 |
+
torch.hub.download_url_to_file('https://huggingface.co/eugenesiow/ani-chara-gan/resolve/main/.config.json',
|
| 43 |
+
'./models/ani-chara-gan/.config.json')
|
| 44 |
+
|
| 45 |
+
loader = ModelLoader(
|
| 46 |
+
base_dir = './', name = 'ani-chara-gan'
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
noise = torch.randn(1, 256).cuda() # noise
|
| 50 |
+
styles = loader.noise_to_styles(noise, trunc_psi = 0.7) # pass through mapping network
|
| 51 |
+
images = loader.styles_to_images(styles) # call the generator on intermediate style vectors
|
| 52 |
+
|
| 53 |
+
save_image(images, './sample.jpg')
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
## BibTeX entry and citation info
|
| 57 |
+
|
| 58 |
+
The model is part of the [practical-ml](https://github.com/eugenesiow/practical-ml) repository.
|
| 59 |
+
|
| 60 |
+
[](https://github.com/eugenesiow/practical-ml)
|
images/samples1.jpg
ADDED
|