Spaces:
Runtime error
Runtime error
update
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import paddlehub as hub
|
2 |
import gradio as gr
|
3 |
|
@@ -6,11 +7,19 @@ module = hub.Module(name="lseg")
|
|
6 |
|
7 |
|
8 |
def segment(image, labels):
|
|
|
|
|
|
|
|
|
9 |
results = module.segment(
|
10 |
image=image[..., ::-1],
|
11 |
-
labels=labels.split('\n')
|
12 |
)
|
13 |
-
return [
|
|
|
|
|
|
|
|
|
14 |
|
15 |
|
16 |
gr.Interface(
|
|
|
1 |
+
import cv2
|
2 |
import paddlehub as hub
|
3 |
import gradio as gr
|
4 |
|
|
|
7 |
|
8 |
|
9 |
def segment(image, labels):
|
10 |
+
long_size = max(image.shape[:2])
|
11 |
+
if long_size > 512:
|
12 |
+
f = 512 / long_size
|
13 |
+
image = cv2.resize(image, (0, 0), fx=f, fy=f)
|
14 |
results = module.segment(
|
15 |
image=image[..., ::-1],
|
16 |
+
labels=[item for item in labels.split('\n') if item != '']
|
17 |
)
|
18 |
+
return [
|
19 |
+
results['color'][..., ::-1],
|
20 |
+
results['mix'][..., ::-1],
|
21 |
+
*[v[..., ::-1] for v in results['classes'].values()]
|
22 |
+
]
|
23 |
|
24 |
|
25 |
gr.Interface(
|