fffiloni commited on
Commit
17a9b0e
β€’
1 Parent(s): acf5ef2

Create new file

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