Dricz commited on
Commit
7ba0645
·
verified ·
1 Parent(s): 01c1334

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -34,7 +34,13 @@ def response2(image: gr.Image = None,image_size: gr.Slider = 640, conf_threshold
34
  # im_rgb = im_bgr[..., ::-1] # Convert BGR to RGB
35
 
36
  # # im_rgb = Image.fromarray(im_rgb)
37
- return render
 
 
 
 
 
 
38
 
39
 
40
  inputs = [
@@ -48,7 +54,9 @@ inputs = [
48
  ]
49
 
50
 
51
- outputs = gr.Image( type="filepath", label="Output Image")
 
 
52
 
53
  title = "YOLOv8 Custom Object Detection by Uyen Nguyen"
54
 
 
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
 
46
  inputs = [
 
54
  ]
55
 
56
 
57
+ outputs = [gr.Image( type="filepath", label="Output Image"),
58
+ gr.textbox()
59
+ ]
60
 
61
  title = "YOLOv8 Custom Object Detection by Uyen Nguyen"
62