Martin Tomov commited on
Commit
dd9911e
Β·
verified Β·
1 Parent(s): 0369ba3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -15
app.py CHANGED
@@ -13,7 +13,6 @@ import matplotlib.pyplot as plt
13
  from transformers import AutoModelForMaskGeneration, AutoProcessor, pipeline
14
  import gradio as gr
15
  import spaces
16
- import json
17
 
18
  @dataclass
19
  class BoundingBox:
@@ -192,22 +191,11 @@ def process_image(image):
192
  annotated_image = plot_detections(original_image, detections)
193
  yellow_background_with_insects = create_yellow_background_with_insects(np.array(original_image), detections)
194
  yellow_background_with_boxes = draw_classification_boxes(yellow_background_with_insects.copy(), detections)
195
-
196
- detection_results_json = []
197
- for detection in detections:
198
- result_dict = {
199
- "score": detection.score,
200
- "label": detection.label,
201
- "box": detection.box.xyxy,
202
- "mask": detection.mask.tolist() if detection.mask is not None else None
203
- }
204
- detection_results_json.append(result_dict)
205
-
206
- return annotated_image, yellow_background_with_boxes, json.dumps(detection_results_json)
207
 
208
  gr.Interface(
209
  fn=process_image,
210
  inputs=gr.Image(type="pil"),
211
- outputs=[gr.Image(type="numpy"), gr.Image(type="numpy"), gr.JSON()],
212
  title="🐞 InsectSAM + GroundingDINO Inference",
213
- ).launch()
 
13
  from transformers import AutoModelForMaskGeneration, AutoProcessor, pipeline
14
  import gradio as gr
15
  import spaces
 
16
 
17
  @dataclass
18
  class BoundingBox:
 
191
  annotated_image = plot_detections(original_image, detections)
192
  yellow_background_with_insects = create_yellow_background_with_insects(np.array(original_image), detections)
193
  yellow_background_with_boxes = draw_classification_boxes(yellow_background_with_insects.copy(), detections)
194
+ return annotated_image, yellow_background_with_boxes
 
 
 
 
 
 
 
 
 
 
 
195
 
196
  gr.Interface(
197
  fn=process_image,
198
  inputs=gr.Image(type="pil"),
199
+ outputs=[gr.Image(type="numpy"), gr.Image(type="numpy")],
200
  title="🐞 InsectSAM + GroundingDINO Inference",
201
+ ).launch()