Camille commited on
Commit
8d321c7
1 Parent(s): 175715f

First commit

Browse files
Files changed (4) hide show
  1. app.py +38 -0
  2. gradio_queue.db +0 -0
  3. gradio_queue.db-journal +0 -0
  4. requirements.txt +11 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding: utf-8
2
+ import os
3
+ #os.system("pip install gradio==2.8.0b3")
4
+ import torch
5
+ import gradio as gr
6
+ from PIL import ImageFont, ImageDraw
7
+
8
+ device = "cuda" if torch.cuda.is_available() else "cpu"
9
+ model1 = torch.hub.load("bryandlee/animegan2-pytorch:main", "generator", device=device, pretrained="face_paint_512_v1")
10
+ model2 = torch.hub.load("bryandlee/animegan2-pytorch:main", "generator", device=device, pretrained="face_paint_512_v2")
11
+ face2paint = torch.hub.load("bryandlee/animegan2-pytorch:main", "face2paint", device=device)
12
+
13
+
14
+ def inference(img, ver):
15
+ if ver == "Version 2 (Réaliste)":
16
+ out = face2paint(model2, img)
17
+ else:
18
+ out = face2paint(model1, img)
19
+ return out
20
+
21
+
22
+ title = "Temp Late"
23
+ gr.Interface(
24
+ inference,
25
+ [
26
+ gr.inputs.Image(type="pil", source="upload"),
27
+ gr.inputs.Radio(
28
+ ["Version 1 (Stylisé)", "Version 2 (Réaliste)"],
29
+ type="value",
30
+ default="Version 2 (Réaliste)",
31
+ label="Version",
32
+ ),
33
+ ],
34
+ gr.outputs.Image(type="pil"),
35
+ allow_flagging="auto",
36
+ allow_screenshot=False,
37
+ flagging_dir="flagged",
38
+ ).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,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ torch
2
+ torchvision
3
+ Pillow
4
+ gdown
5
+ numpy
6
+ scipy
7
+ cmake
8
+ onnxruntime-gpu
9
+ opencv-python-headless
10
+ jinja2
11
+ gradio