Spaces:
Running
Running
app.py
CHANGED
@@ -4,13 +4,17 @@ import gradio as gr
|
|
4 |
|
5 |
model2 = torch.hub.load(
|
6 |
"AK391/animegan2-pytorch:main",
|
7 |
-
"generator",
|
8 |
-
|
9 |
-
"
|
10 |
-
|
|
|
|
|
|
|
11 |
face2paint = torch.hub.load(
|
12 |
'AK391/animegan2-pytorch:main', 'face2paint',
|
13 |
-
size=512, device="cpu", side_by_side=False
|
|
|
14 |
|
15 |
def inference(img, ver):
|
16 |
if ver == 'version 2 (🔺 robustness,🔻 stylization)':
|
@@ -22,5 +26,7 @@ def inference(img, ver):
|
|
22 |
title = "Face Anime For You"
|
23 |
description = "Online Demo for AnimeGanv2 Face Portrait v2. To use it, simply upload your image, or click one of the examples to load them. Please use a cropped portrait picture for best results similar to the examples below."
|
24 |
article = "<p style='text-align: center'>❤ from Bruce</p>"
|
25 |
-
examples = [['
|
26 |
-
|
|
|
|
|
|
4 |
|
5 |
model2 = torch.hub.load(
|
6 |
"AK391/animegan2-pytorch:main",
|
7 |
+
"generator",
|
8 |
+
pretrained=True,
|
9 |
+
device="cpu",
|
10 |
+
progress=False
|
11 |
+
)
|
12 |
+
model1 = torch.hub.load("AK391/animegan2-pytorch:main",
|
13 |
+
"generator", pretrained="face_paint_512_v1", device="cpu")
|
14 |
face2paint = torch.hub.load(
|
15 |
'AK391/animegan2-pytorch:main', 'face2paint',
|
16 |
+
size=512, device="cpu", side_by_side=False
|
17 |
+
)
|
18 |
|
19 |
def inference(img, ver):
|
20 |
if ver == 'version 2 (🔺 robustness,🔻 stylization)':
|
|
|
26 |
title = "Face Anime For You"
|
27 |
description = "Online Demo for AnimeGanv2 Face Portrait v2. To use it, simply upload your image, or click one of the examples to load them. Please use a cropped portrait picture for best results similar to the examples below."
|
28 |
article = "<p style='text-align: center'>❤ from Bruce</p>"
|
29 |
+
examples = [['elon.png', 'version 2 (🔺 robustness,🔻 stylization)'],
|
30 |
+
['IU.png', 'version 2 (🔺 robustness,🔻 stylization)']]
|
31 |
+
gr.Interface(inference, [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')
|
32 |
+
], gr.outputs.Image(type="pil"), title=title, description=description, article=article, enable_queue=True, examples=examples, allow_flagging=False).launch()
|