Martin Tomov commited on
Commit
0764038
Β·
verified Β·
1 Parent(s): 3114eb9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
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(images):
195
  labels = ["insect"]
196
  results = []
197
  json_outputs = []
198
- for image in images:
 
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="file"),
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()