Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,51 @@
|
|
|
|
1 |
import torch
|
2 |
import gradio as gr
|
3 |
|
4 |
-
model2 = torch.hub.load(
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
def inference(img, ver):
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
11 |
|
12 |
title = "AnimeGANv2"
|
13 |
-
description = "Gradio Demo for AnimeGanv2 Face Portrait.
|
14 |
-
article = "<p style='text-align: center'><a href='https://github.com/bryandlee/animegan2-pytorch' target='_blank'>Github Repo Pytorch</a></p>"
|
15 |
|
16 |
gr.Interface(
|
17 |
fn=inference,
|
18 |
inputs=[
|
19 |
gr.inputs.Image(type="pil"),
|
20 |
-
gr.inputs.Radio(
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
24 |
],
|
25 |
outputs=gr.outputs.Image(type="pil"),
|
26 |
title=title,
|
|
|
1 |
+
from PIL import Image
|
2 |
import torch
|
3 |
import gradio as gr
|
4 |
|
5 |
+
model2 = torch.hub.load(
|
6 |
+
"AK391/animegan2-pytorch:main",
|
7 |
+
"generator",
|
8 |
+
pretrained=True,
|
9 |
+
device="cpu",
|
10 |
+
progress=False
|
11 |
+
)
|
12 |
+
|
13 |
+
model1 = torch.hub.load(
|
14 |
+
"AK391/animegan2-pytorch:main",
|
15 |
+
"generator",
|
16 |
+
pretrained="face_paint_512_v1",
|
17 |
+
device="cpu"
|
18 |
+
)
|
19 |
+
|
20 |
+
face2paint = torch.hub.load(
|
21 |
+
'AK391/animegan2-pytorch:main',
|
22 |
+
'face2paint',
|
23 |
+
size=512,
|
24 |
+
device="cpu",
|
25 |
+
side_by_side=False
|
26 |
+
)
|
27 |
|
28 |
def inference(img, ver):
|
29 |
+
if ver == 'version 2 (🔺 robustness,🔻 stylization)':
|
30 |
+
out = face2paint(model2, img)
|
31 |
+
else:
|
32 |
+
out = face2paint(model1, img)
|
33 |
+
return out
|
34 |
|
35 |
title = "AnimeGANv2"
|
36 |
+
description = "Gradio Demo for AnimeGanv2 Face Portrait. To use it, simply upload your image."
|
37 |
+
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>"
|
38 |
|
39 |
gr.Interface(
|
40 |
fn=inference,
|
41 |
inputs=[
|
42 |
gr.inputs.Image(type="pil"),
|
43 |
+
gr.inputs.Radio(
|
44 |
+
['version 1 (🔺 stylization, 🔻 robustness)', 'version 2 (🔺 robustness,🔻 stylization)'],
|
45 |
+
type="value",
|
46 |
+
default='version 2 (🔺 robustness,🔻 stylization)',
|
47 |
+
label='version'
|
48 |
+
)
|
49 |
],
|
50 |
outputs=gr.outputs.Image(type="pil"),
|
51 |
title=title,
|