|
|
|
# Animating using AnimeGanV2
|
|
|
|
*author: Filip Haltmayer*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
|
|
|
Convert an image into an animated image using [`AnimeganV2`](https://github.com/TachibanaYoshino/AnimeGANv2).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Code Example
|
|
|
|
Load an image from path './test.png'.
|
|
|
|
|
|
|
|
*Write the pipeline in simplified style*:
|
|
|
|
|
|
|
|
```python
|
|
|
|
import towhee
|
|
|
|
|
|
|
|
towhee.glob('./test.png') \
|
|
|
|
.image_decode.cv2() \
|
|
|
|
.img2img_translation.animegan(model_name = 'hayao') \
|
|
|
|
.show()
|
|
|
|
```
|
|
|
|
|
|
|
|
<img src="./results1.png" height="150px"/>
|
|
|
|
|
|
|
|
*Write a same pipeline with explicit inputs/outputs name specifications:*
|
|
|
|
|
|
|
|
```python
|
|
|
|
import towhee
|
|
|
|
|
|
|
|
towhee.glob['path']('./test.png') \
|
|
|
|
.image_decode.cv2['path', 'origin']() \
|
|
|
|
.img2img_translation.animegan['origin', 'facepaintv2'](model_name = 'facepaintv2') \
|
|
|
|
.img2img_translation.animegan['origin', 'hayao'](model_name = 'hayao') \
|
|
|
|
.img2img_translation.animegan['origin', 'paprika'](model_name = 'paprika') \
|
|
|
|
.img2img_translation.animegan['origin', 'shinkai'](model_name = 'shinkai') \
|
|
|
|
.select('origin', 'facepaintv2', 'hayao', 'paprika', 'shinkai') \
|
|
|
|
.show()
|
|
|
|
```
|
|
|
|
|
|
|
|
<img src="./results2.png" alt="results1" height="150px"/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Factory Constructor
|
|
|
|
|
|
|
|
Create the operator via the following factory method
|
|
|
|
|
|
|
|
***img2img_translation.animegan(model_name = 'which anime model to use')***
|
|
|
|
|
|
|
|
Model options:
|
|
|
|
- celeba
|
|
|
|
- facepaintv1
|
|
|
|
- facepaintv2
|
|
|
|
- hayao
|
|
|
|
- paprika
|
|
|
|
- shinkai
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Interface
|
|
|
|
|
|
|
|
Takes in a numpy rgb image in channels first. It transforms input into animated image in numpy form.
|
|
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
***model_name***: *str*
|
|
|
|
|
|
|
|
Which model to use for transfer.
|
|
|
|
|
|
|
|
***framework***: *str*
|
|
|
|
|
|
|
|
Which ML framework being used, for now only supports PyTorch.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
**Returns**: *towhee.types.Image (a sub-class of dumpy.ndarray)*
|
|
|
|
|
|
|
|
The new image.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Reference
|
|
|
|
|
|
|
|
Jie Chen, Gang Liu, Xin Chen
|
|
|
|
"AnimeGAN: A Novel Lightweight GAN for Photo Animation."
|
|
|
|
ISICA 2019: Artificial Intelligence Algorithms and Applications pp 242-256, 2019.
|