Spaces:
Running
Running
Camille
commited on
Commit
•
0a313a4
1
Parent(s):
09472f4
first commit
Browse files- LEMONMILK-Regular.otf +0 -0
- app.py +44 -0
- gradio_queue.db +0 -0
- gradio_queue.db-journal +0 -0
- requirements.txt +10 -0
LEMONMILK-Regular.otf
ADDED
Binary file (34.6 kB). View file
|
|
app.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
os.system("pip install gradio==2.8.0b3")
|
3 |
+
import torch
|
4 |
+
import gradio as gr
|
5 |
+
from PIL import ImageFont, ImageDraw
|
6 |
+
|
7 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
8 |
+
model1 = torch.hub.load("bryandlee/animegan2-pytorch:main", "generator", device=device, pretrained="face_paint_512_v1")
|
9 |
+
model2 = torch.hub.load("bryandlee/animegan2-pytorch:main", "generator", device=device, pretrained="face_paint_512_v2")
|
10 |
+
face2paint = torch.hub.load("bryandlee/animegan2-pytorch:main", "face2paint", device=device)
|
11 |
+
|
12 |
+
|
13 |
+
def inference(img, ver):
|
14 |
+
title_font = ImageFont.truetype("LEMONMILK-Regular.otf", 20)
|
15 |
+
title_text = "@_temp.late_"
|
16 |
+
padding = 10
|
17 |
+
x, y = 15, 15 # 180, 412
|
18 |
+
w, h = title_font.getsize(title_text)
|
19 |
+
if ver == "version 2 (🔺 Réaliste,🔻 Stylé)":
|
20 |
+
out = face2paint(model2, img)
|
21 |
+
else:
|
22 |
+
out = face2paint(model1, img)
|
23 |
+
image_editable = ImageDraw.Draw(out)
|
24 |
+
image_editable.rectangle((x, y, x + w + padding, y + h + padding), fill="white")
|
25 |
+
image_editable.text((x + padding / 2, y + padding / 2), title_text, (0, 0, 0), font=title_font)
|
26 |
+
return out
|
27 |
+
|
28 |
+
|
29 |
+
title = "Temp Late"
|
30 |
+
gr.Interface(
|
31 |
+
inference,
|
32 |
+
[
|
33 |
+
gr.inputs.Image(type="pil", source="upload"),
|
34 |
+
gr.inputs.Radio(
|
35 |
+
["version 1 (🔺 Stylé, 🔻 Réaliste)", "version 2 (🔺 Réaliste,🔻 Stylé)"],
|
36 |
+
type="value",
|
37 |
+
default="version 2 (🔺 Réaliste,🔻 Stylé)",
|
38 |
+
label="version",
|
39 |
+
),
|
40 |
+
],
|
41 |
+
gr.outputs.Image(type="pil"),
|
42 |
+
allow_flagging="never",
|
43 |
+
allow_screenshot=False,
|
44 |
+
).launch(enable_queue=True)
|
gradio_queue.db
ADDED
File without changes
|
gradio_queue.db-journal
ADDED
Binary file (512 Bytes). View file
|
|
requirements.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
torchvision
|
3 |
+
Pillow
|
4 |
+
gdown
|
5 |
+
numpy
|
6 |
+
scipy
|
7 |
+
cmake
|
8 |
+
onnxruntime-gpu
|
9 |
+
opencv-python-headless
|
10 |
+
jinja2
|