Dricz commited on
Commit
78dbbdb
1 Parent(s): d550fff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -12
app.py CHANGED
@@ -27,19 +27,13 @@ def response2(image: gr.Image = None,image_size: gr.Slider = 640, conf_threshold
27
  box = results[0].boxes
28
 
29
  render = render_result(model=model, image=image, result=results[0], rect_th = 1, text_th = 1)
30
- # for i, r in enumerate(results):
31
-
32
- # # Plot results image
33
- # im_bgr = r.plot()
34
- # im_rgb = im_bgr[..., ::-1] # Convert BGR to RGB
35
-
36
- # # im_rgb = Image.fromarray(im_rgb)
37
  text = ""
38
- for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
39
- box = [round(i, 2) for i in box.tolist()]
40
-
41
- text = text + (f"Detected {model.config.id2label[label.item()]} with confidence, {round(score.item(), 3)} at location {box}")
42
-
43
  return render,text
44
 
45
 
 
27
  box = results[0].boxes
28
 
29
  render = render_result(model=model, image=image, result=results[0], rect_th = 1, text_th = 1)
30
+
 
 
 
 
 
 
31
  text = ""
32
+ for result in results:
33
+ for score, label, box in zip(result.scores, result.labels, result.boxes):
34
+ box = [round(i, 2) for i in box.tolist()]
35
+ text += f"Detected {model.config.id2label[label.item()]} with confidence {round(score.item(), 3)} at location {box}\n"
36
+
37
  return render,text
38
 
39