app.py
CHANGED
|
@@ -1,21 +1,16 @@
|
|
| 1 |
from PIL import Image
|
| 2 |
import torch
|
| 3 |
-
import requests
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
model2 = torch.hub.load(
|
| 7 |
"AK391/animegan2-pytorch:main",
|
| 8 |
-
"generator",
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
)
|
| 13 |
-
model1 = torch.hub.load("AK391/animegan2-pytorch:main",
|
| 14 |
-
"generator", pretrained="face_paint_512_v1", device="cpu")
|
| 15 |
face2paint = torch.hub.load(
|
| 16 |
'AK391/animegan2-pytorch:main', 'face2paint',
|
| 17 |
-
size=512, device="cpu", side_by_side=False
|
| 18 |
-
)
|
| 19 |
|
| 20 |
def inference(img, ver):
|
| 21 |
if ver == 'version 2 (🔺 robustness,🔻 stylization)':
|
|
@@ -27,21 +22,5 @@ def inference(img, ver):
|
|
| 27 |
title = "Face Anime For You"
|
| 28 |
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."
|
| 29 |
article = "<p style='text-align: center'>❤ from Bruce</p>"
|
| 30 |
-
examples = [['IU.png',
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
gr.Interface(inference,
|
| 34 |
-
[gr.inputs.Image(type="pil"), gr.inputs.Radio(
|
| 35 |
-
['version 1 (🔺 stylization, 🔻 robustness)',
|
| 36 |
-
'version 2 (🔺 robustness,🔻 stylization)'],
|
| 37 |
-
type="value",
|
| 38 |
-
default='version 2 (🔺 robustness,🔻 stylization)',
|
| 39 |
-
label='version')
|
| 40 |
-
],
|
| 41 |
-
gr.outputs.Image(type="pil"),
|
| 42 |
-
title=title,
|
| 43 |
-
description=description,
|
| 44 |
-
article=article,
|
| 45 |
-
enable_queue=True,
|
| 46 |
-
examples=examples,
|
| 47 |
-
allow_flagging=False).launch()
|
|
|
|
| 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", pretrained=True, device="cpu", progress=False)
|
| 8 |
+
model1 = torch.hub.load(
|
| 9 |
+
"AK391/animegan2-pytorch:main",
|
| 10 |
+
"generator", pretrained="face_paint_512_v1", device="cpu")
|
|
|
|
|
|
|
|
|
|
| 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 |
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 = [['IU.png', 'version 2 (🔺 robustness,🔻 stylization)'], ['elon.png', 'version 2 (🔺 robustness,🔻 stylization)']]
|
| 26 |
+
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')], gr.outputs.Image(type="pil"), title=title, description=description, article=article, enable_queue=True, examples=examples, allow_flagging=False).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|