Ahsen Khaliq
commited on
Commit
·
6321605
1
Parent(s):
85a0fdf
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,7 +15,7 @@ device = "cpu"
|
|
| 15 |
model = Generator().eval().to(device)
|
| 16 |
model.load_state_dict(torch.load("face_paint_512_v2_0.pt"))
|
| 17 |
|
| 18 |
-
from PIL import Image
|
| 19 |
from torchvision.transforms.functional import to_tensor, to_pil_image
|
| 20 |
import gradio as gr
|
| 21 |
|
|
@@ -54,11 +54,14 @@ import scipy.ndimage
|
|
| 54 |
|
| 55 |
import requests
|
| 56 |
|
| 57 |
-
def inference(
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
title = "Animeganv2"
|
| 64 |
description = "Gradio demo for AnimeGanv2 Face Portrait v2. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below."
|
|
|
|
| 15 |
model = Generator().eval().to(device)
|
| 16 |
model.load_state_dict(torch.load("face_paint_512_v2_0.pt"))
|
| 17 |
|
| 18 |
+
from PIL import Image
|
| 19 |
from torchvision.transforms.functional import to_tensor, to_pil_image
|
| 20 |
import gradio as gr
|
| 21 |
|
|
|
|
| 54 |
|
| 55 |
import requests
|
| 56 |
|
| 57 |
+
def inference(img):
|
| 58 |
+
basewidth = 512
|
| 59 |
+
wpercent = (basewidth/float(img.size[0]))
|
| 60 |
+
hsize = int((float(img.size[1])*float(wpercent)))
|
| 61 |
+
img = img.resize((basewidth,hsize), Image.ANTIALIAS)
|
| 62 |
+
out = face2paint(img, 512)
|
| 63 |
+
return out
|
| 64 |
+
|
| 65 |
|
| 66 |
title = "Animeganv2"
|
| 67 |
description = "Gradio demo for AnimeGanv2 Face Portrait v2. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below."
|