Spaces:
Running
on
Zero
Running
on
Zero
Martin Tomov
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -191,11 +191,12 @@ def detections_to_json(detections):
|
|
191 |
detections_list.append(detection_dict)
|
192 |
return detections_list
|
193 |
|
194 |
-
def process_images(
|
195 |
labels = ["insect"]
|
196 |
results = []
|
197 |
json_outputs = []
|
198 |
-
for
|
|
|
199 |
original_image, detections = grounded_segmentation(image, labels, threshold=0.3, polygon_refinement=True)
|
200 |
yellow_background_with_insects = create_yellow_background_with_insects(np.array(original_image), detections)
|
201 |
detections_json = detections_to_json(detections)
|
@@ -208,7 +209,7 @@ def process_images(images):
|
|
208 |
|
209 |
gr.Interface(
|
210 |
fn=process_images,
|
211 |
-
inputs=gr.File(file_count="multiple", type="
|
212 |
outputs=[gr.Gallery(), gr.Textbox()],
|
213 |
title="π InsectSAM + GroundingDINO Inference",
|
214 |
).launch()
|
|
|
191 |
detections_list.append(detection_dict)
|
192 |
return detections_list
|
193 |
|
194 |
+
def process_images(image_files):
|
195 |
labels = ["insect"]
|
196 |
results = []
|
197 |
json_outputs = []
|
198 |
+
for image_file in image_files:
|
199 |
+
image = Image.open(image_file).convert("RGB")
|
200 |
original_image, detections = grounded_segmentation(image, labels, threshold=0.3, polygon_refinement=True)
|
201 |
yellow_background_with_insects = create_yellow_background_with_insects(np.array(original_image), detections)
|
202 |
detections_json = detections_to_json(detections)
|
|
|
209 |
|
210 |
gr.Interface(
|
211 |
fn=process_images,
|
212 |
+
inputs=gr.File(file_count="multiple", type="filepath"),
|
213 |
outputs=[gr.Gallery(), gr.Textbox()],
|
214 |
title="π InsectSAM + GroundingDINO Inference",
|
215 |
).launch()
|