ZhangTianqi commited on
Commit
e288e5a
1 Parent(s): 0c65d3c

Add application file

Browse files
Files changed (3) hide show
  1. app.py +27 -0
  2. image/test.jpg +0 -0
  3. output/test.jpg +0 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os.path
3
+
4
+ import torch
5
+ import cv2
6
+ import numpy as np
7
+ from PIL import Image
8
+
9
+ def output(image_path):
10
+ pil_image = Image.open(image_path).convert("RGB")
11
+ image = np.array(pil_image)[:, :, [2, 1, 0]]
12
+ output_path = 'output'
13
+ caption = 'person . mask'
14
+ flag = False
15
+ save_image_path = os.path.join(output_path,os.path.split(image_path)[-1])
16
+ return save_image_path
17
+
18
+ with gr.Blocks() as demo:
19
+ gr.Markdown("<h1><center>Demo</center></h1>")
20
+ img_obj = gr.Image(value ='image/test.jpg',type = "filepath",label='object_img')
21
+ btn = gr.Button("Submit",variant="primary")
22
+ img_output = gr.Image(type = "filepath",label='output_img')
23
+ btn.click(fn=output,inputs=[img_obj],
24
+ outputs=[img_output],
25
+ )
26
+
27
+ demo.launch(share=True)
image/test.jpg ADDED
output/test.jpg ADDED