fffiloni commited on
Commit
13a751b
β€’
1 Parent(s): c5332bb

Create new file

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import imageio
3
+ from PIL import Image
4
+
5
+ source_img = gr.Image(source="upload", type="filepath", tool="sketch");
6
+ outputs = [gr.outputs.Image(type="file",label="output"),gr.outputs.Image(type="file",label="Mask")]
7
+ def resize(height,img):
8
+ baseheight = height
9
+ img = Image.open(img)
10
+ hpercent = (baseheight/float(img.size[1]))
11
+ wsize = int((float(img.size[0])*float(hpercent)))
12
+ img = img.resize((wsize,baseheight), Image.Resampling.LANCZOS)
13
+ return img
14
+
15
+ def predict(source_img):
16
+
17
+ #print(sketch)
18
+ #print(sketch.mode)
19
+ #sketch_png = resize(512,source_img)
20
+ #sketch_png.save('source.png')
21
+ #print(sketch_png)
22
+ imageio.imwrite("data.png", img["image"])
23
+ imageio.imwrite("data_mask.png", img["mask"])
24
+ return "data.png", "data_mask.png"
25
+ gr.Interface(fn=predict, inputs=source_img, outputs=outputs).launch(enable_queue=True)