Martin Tomov commited on
Commit
ddec5aa
1 Parent(s): caabd4b

playing around with cv2

Browse files
Files changed (1) hide show
  1. app.py +1 -2
app.py CHANGED
@@ -194,13 +194,12 @@ def detections_to_json(detections):
194
  def process_image(image):
195
  labels = ["insect"]
196
  original_image, detections = grounded_segmentation(image, labels, threshold=0.3, polygon_refinement=True)
197
- annotated_image = plot_detections(original_image, detections)
198
  yellow_background_with_insects = create_yellow_background_with_insects(np.array(original_image), detections)
199
  detections_json = detections_to_json(detections)
200
  json_output_path = "insect_detections.json"
201
  with open(json_output_path, 'w') as json_file:
202
  json.dump(detections_json, json_file, indent=4)
203
- return annotated_image, json.dumps(detections_json, separators=(',', ':'))
204
 
205
  gr.Interface(
206
  fn=process_image,
 
194
  def process_image(image):
195
  labels = ["insect"]
196
  original_image, detections = grounded_segmentation(image, labels, threshold=0.3, polygon_refinement=True)
 
197
  yellow_background_with_insects = create_yellow_background_with_insects(np.array(original_image), detections)
198
  detections_json = detections_to_json(detections)
199
  json_output_path = "insect_detections.json"
200
  with open(json_output_path, 'w') as json_file:
201
  json.dump(detections_json, json_file, indent=4)
202
+ return yellow_background_with_insects, json.dumps(detections_json, separators=(',', ':'))
203
 
204
  gr.Interface(
205
  fn=process_image,