Spaces:
Runtime error
Runtime error
mie035
commited on
Commit
•
894cc56
1
Parent(s):
08eadfe
app.py
CHANGED
@@ -25,7 +25,7 @@ def resize_and_show(image):
|
|
25 |
cv2.waitKey(1000)
|
26 |
cv2.destroyAllWindows()
|
27 |
|
28 |
-
def segmentate(
|
29 |
BG_COLOR = (192, 192, 192) # gray
|
30 |
MASK_COLOR = (255, 255, 255) # white
|
31 |
|
@@ -39,8 +39,8 @@ def segmentate(image):
|
|
39 |
# Loop through demo image(s)
|
40 |
|
41 |
# Create the MediaPipe image file that will be segmented
|
42 |
-
|
43 |
-
|
44 |
# Retrieve the masks for the segmented image
|
45 |
segmentation_result = segmenter.segment(image)
|
46 |
category_mask = segmentation_result.category_mask
|
@@ -67,7 +67,7 @@ examples = [[f'examples/{name}', 3] for name in sorted(os.listdir('examples'))]
|
|
67 |
iface = gr.Interface(
|
68 |
fn=segmentate,
|
69 |
inputs=[
|
70 |
-
gr.Image(type='
|
71 |
],
|
72 |
outputs=[
|
73 |
gr.Image(label='image segmentated')
|
|
|
25 |
cv2.waitKey(1000)
|
26 |
cv2.destroyAllWindows()
|
27 |
|
28 |
+
def segmentate(filepath):
|
29 |
BG_COLOR = (192, 192, 192) # gray
|
30 |
MASK_COLOR = (255, 255, 255) # white
|
31 |
|
|
|
39 |
# Loop through demo image(s)
|
40 |
|
41 |
# Create the MediaPipe image file that will be segmented
|
42 |
+
image = mp.Image.create_from_file(filepath)
|
43 |
+
|
44 |
# Retrieve the masks for the segmented image
|
45 |
segmentation_result = segmenter.segment(image)
|
46 |
category_mask = segmentation_result.category_mask
|
|
|
67 |
iface = gr.Interface(
|
68 |
fn=segmentate,
|
69 |
inputs=[
|
70 |
+
gr.Image(type='filepath', label='Input Image')
|
71 |
],
|
72 |
outputs=[
|
73 |
gr.Image(label='image segmentated')
|