akhaliq HF staff commited on
Commit
6783ab6
1 Parent(s): ce12a69

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import cv2
3
+ import paddlehub as hub
4
+
5
+
6
+ model = hub.Module(name='U2Net')
7
+
8
+ def inference(img):
9
+ result = model.Segmentation(
10
+ images=[cv2.imread(img)],
11
+ paths=None,
12
+ batch_size=1,
13
+ input_size=320,
14
+ output_dir='output',
15
+ visualization=True)
16
+ print(result)
17
+ return result[0][0]
18
+
19
+
20
+ title="u2Net"
21
+ description="U^2-Net: Going Deeper with Nested U-Structure for Salient Object Detection"
22
+
23
+ examples=[['cat2.jpg']]
24
+ gr.Interface(inference,gr.inputs.Image(type="filepath"),"label",title=title,description=description,examples=examples).launch(enable_queue=True,cache_examples=True)