jm12138 commited on
Commit
f28c437
β€’
1 Parent(s): 3d4fd5f
Files changed (3) hide show
  1. app.py +13 -0
  2. requirements.txt +2 -0
  3. test.jpg +0 -0
app.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import paddlehub as hub
2
+ import gradio as gr
3
+
4
+ module = hub.Module(name="lseg")
5
+
6
+ def segment(image, labels):
7
+ results = module.segment(
8
+ image=image[..., ::-1],
9
+ labels=labels.split('\n')
10
+ )
11
+ return [results['color'][..., ::-1], results['mix'][..., ::-1], *[v[..., ::-1] for v in results['classes'].values()]]
12
+
13
+ gr.Interface(fn=segment, inputs=['image', gr.Textbox(placeholder='other\ncat', lines=5, max_lines=50)], outputs=['gallery']).launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ paddlepaddle
2
+ paddlehub
test.jpg ADDED