Spaces:
Runtime error
Runtime error
jens
commited on
Commit
·
c810b3c
1
Parent(s):
968b967
annotated image
Browse files- app.py +3 -3
- inference.py +4 -4
app.py
CHANGED
@@ -39,7 +39,7 @@ with block:
|
|
39 |
with gr.Row():
|
40 |
prompt_image = gr.Image(label='Segments')
|
41 |
prompt_lbl_image = gr.AnnotatedImage(label='Segment Labels')
|
42 |
-
everything_image = gr.
|
43 |
|
44 |
with gr.Row():
|
45 |
with gr.Column():
|
@@ -123,8 +123,8 @@ with block:
|
|
123 |
def on_sam_sgmt_everything_btn_click(inputs):
|
124 |
print("segmenting everything")
|
125 |
image = inputs[input_image]
|
126 |
-
|
127 |
-
return [
|
128 |
sam_sgmt_everything_btn.click(on_sam_sgmt_everything_btn_click, components, [everything_image], queue=False)
|
129 |
|
130 |
|
|
|
39 |
with gr.Row():
|
40 |
prompt_image = gr.Image(label='Segments')
|
41 |
prompt_lbl_image = gr.AnnotatedImage(label='Segment Labels')
|
42 |
+
everything_image = gr.AnnotatedImage(label='Everything')
|
43 |
|
44 |
with gr.Row():
|
45 |
with gr.Column():
|
|
|
123 |
def on_sam_sgmt_everything_btn_click(inputs):
|
124 |
print("segmenting everything")
|
125 |
image = inputs[input_image]
|
126 |
+
sam_masks = sam.segment_everything(image)
|
127 |
+
return [sam_masks]
|
128 |
sam_sgmt_everything_btn.click(on_sam_sgmt_everything_btn_click, components, [everything_image], queue=False)
|
129 |
|
130 |
|
inference.py
CHANGED
@@ -156,7 +156,7 @@ class SegmentPredictor:
|
|
156 |
def segment_everything(self, image):
|
157 |
image = np.array(image)
|
158 |
sam_result = self.mask_generator.generate(image)
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
return
|
|
|
156 |
def segment_everything(self, image):
|
157 |
image = np.array(image)
|
158 |
sam_result = self.mask_generator.generate(image)
|
159 |
+
sam_masks = []
|
160 |
+
for i,mask in enumerate(sam_result):
|
161 |
+
sam_masks.append((mask["segmentation"], str(i)))
|
162 |
+
return sam_masks
|