Spaces:
Running
Running
Upload with huggingface_hub
Browse files- DESCRIPTION.md +1 -0
- README.md +1 -1
- app.py +0 -8
DESCRIPTION.md
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Recreate the viral AnimeGAN image transformation demo.
|
README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
|
2 |
---
|
3 |
title: animeganv2
|
4 |
-
emoji:
|
5 |
colorFrom: indigo
|
6 |
colorTo: indigo
|
7 |
sdk: gradio
|
|
|
1 |
|
2 |
---
|
3 |
title: animeganv2
|
4 |
+
emoji: π₯
|
5 |
colorFrom: indigo
|
6 |
colorTo: indigo
|
7 |
sdk: gradio
|
app.py
CHANGED
@@ -1,11 +1,7 @@
|
|
1 |
-
# URL: https://huggingface.co/spaces/gradio/animeganv2
|
2 |
-
# DESCRIPTION: Recreate the viral AnimeGAN image transformation demo.
|
3 |
-
# imports
|
4 |
import gradio as gr
|
5 |
from PIL import Image
|
6 |
import torch
|
7 |
|
8 |
-
# load the models
|
9 |
model2 = torch.hub.load(
|
10 |
"AK391/animegan2-pytorch:main",
|
11 |
"generator",
|
@@ -18,7 +14,6 @@ face2paint = torch.hub.load(
|
|
18 |
size=512,side_by_side=False
|
19 |
)
|
20 |
|
21 |
-
# define the core function
|
22 |
def inference(img, ver):
|
23 |
if ver == 'version 2 (πΊ robustness,π» stylization)':
|
24 |
out = face2paint(model2, img)
|
@@ -26,13 +21,11 @@ def inference(img, ver):
|
|
26 |
out = face2paint(model1, img)
|
27 |
return out
|
28 |
|
29 |
-
# define the title, description and examples
|
30 |
title = "AnimeGANv2"
|
31 |
description = "Gradio Demo for AnimeGanv2 Face Portrait. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please use a cropped portrait picture for best results similar to the examples below."
|
32 |
article = "<p style='text-align: center'><a href='https://github.com/bryandlee/animegan2-pytorch' target='_blank'>Github Repo Pytorch</a></p> <center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_animegan' alt='visitor badge'></center></p>"
|
33 |
examples=[['groot.jpeg','version 2 (πΊ robustness,π» stylization)'],['gongyoo.jpeg','version 1 (πΊ stylization, π» robustness)']]
|
34 |
|
35 |
-
# define the interface
|
36 |
demo = gr.Interface(
|
37 |
fn=inference,
|
38 |
inputs=[gr.inputs.Image(type="pil"),gr.inputs.Radio(['version 1 (πΊ stylization, π» robustness)','version 2 (πΊ robustness,π» stylization)'], type="value", default='version 2 (πΊ robustness,π» stylization)', label='version')],
|
@@ -42,5 +35,4 @@ demo = gr.Interface(
|
|
42 |
article=article,
|
43 |
examples=examples)
|
44 |
|
45 |
-
# launch
|
46 |
demo.launch()
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from PIL import Image
|
3 |
import torch
|
4 |
|
|
|
5 |
model2 = torch.hub.load(
|
6 |
"AK391/animegan2-pytorch:main",
|
7 |
"generator",
|
|
|
14 |
size=512,side_by_side=False
|
15 |
)
|
16 |
|
|
|
17 |
def inference(img, ver):
|
18 |
if ver == 'version 2 (πΊ robustness,π» stylization)':
|
19 |
out = face2paint(model2, img)
|
|
|
21 |
out = face2paint(model1, img)
|
22 |
return out
|
23 |
|
|
|
24 |
title = "AnimeGANv2"
|
25 |
description = "Gradio Demo for AnimeGanv2 Face Portrait. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please use a cropped portrait picture for best results similar to the examples below."
|
26 |
article = "<p style='text-align: center'><a href='https://github.com/bryandlee/animegan2-pytorch' target='_blank'>Github Repo Pytorch</a></p> <center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_animegan' alt='visitor badge'></center></p>"
|
27 |
examples=[['groot.jpeg','version 2 (πΊ robustness,π» stylization)'],['gongyoo.jpeg','version 1 (πΊ stylization, π» robustness)']]
|
28 |
|
|
|
29 |
demo = gr.Interface(
|
30 |
fn=inference,
|
31 |
inputs=[gr.inputs.Image(type="pil"),gr.inputs.Radio(['version 1 (πΊ stylization, π» robustness)','version 2 (πΊ robustness,π» stylization)'], type="value", default='version 2 (πΊ robustness,π» stylization)', label='version')],
|
|
|
35 |
article=article,
|
36 |
examples=examples)
|
37 |
|
|
|
38 |
demo.launch()
|