Guy2 commited on
Commit
664cf36
·
1 Parent(s): e365c96

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -27,10 +27,8 @@ def anylize(url):
27
 
28
  # annotate
29
  detections = sv.Detections.from_transformers(transformers_results=results).with_nms(threshold=0.5)
30
- labels = [f"{id2label[class_id]} {confidence:.2f}" for _, _, confidence, class_id, _ in detections]
31
- box_annotator = sv.BoxAnnotator()
32
- frame = box_annotator.annotate(scene=image.copy(), detections=detections, labels=labels)
33
- return frame
34
 
35
- output = gr.components.Image(type="numpy", label="Output Image")
36
- gr.Interface(fn = anylize, inputs="text", outputs=output).launch()
 
27
 
28
  # annotate
29
  detections = sv.Detections.from_transformers(transformers_results=results).with_nms(threshold=0.5)
30
+ labels = [str([list(xyxy), confidence, id2label[class_id]]) for xyxy, _, confidence, class_id, _ in detections]
31
+ json_list = json.dumps(labels)
32
+ return json_list
 
33
 
34
+ gr.Interface(fn = anylize, inputs="text", outputs=gr.JSON()).launch()