Spaces:
Running
Running
Upload with huggingface_hub
Browse files
README.md
CHANGED
@@ -6,6 +6,7 @@ colorFrom: indigo
|
|
6 |
colorTo: indigo
|
7 |
sdk: gradio
|
8 |
sdk_version: 3.4.1
|
9 |
-
|
|
|
10 |
pinned: false
|
11 |
---
|
|
|
6 |
colorTo: indigo
|
7 |
sdk: gradio
|
8 |
sdk_version: 3.4.1
|
9 |
+
|
10 |
+
app_file: app.py
|
11 |
pinned: false
|
12 |
---
|
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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",
|
8 |
+
pretrained=True,
|
9 |
+
progress=False
|
10 |
+
)
|
11 |
+
model1 = torch.hub.load("AK391/animegan2-pytorch:main", "generator", pretrained="face_paint_512_v1")
|
12 |
+
face2paint = torch.hub.load(
|
13 |
+
'AK391/animegan2-pytorch:main', 'face2paint',
|
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)
|
20 |
+
else:
|
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')],
|
32 |
+
outputs=gr.outputs.Image(type="pil"),
|
33 |
+
title=title,
|
34 |
+
description=description,
|
35 |
+
article=article,
|
36 |
+
examples=examples)
|
37 |
+
|
38 |
+
demo.launch()
|