ethanrom commited on
Commit
6ce9669
·
1 Parent(s): adb740b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -56,13 +56,14 @@ def detect_objects(frame):
56
 
57
  return detections
58
 
59
- def display_detections(image, detections):
60
- for x1, y1, x2, y2, conf, cls in detections:
61
- label = f'{cls} ({conf:.2f})'
62
- cv2.rectangle(image, (x1, y1), (x2, y2), colors.get(cls, (255, 255, 255)), 2)
63
- cv2.putText(image, label, (x1, y1 - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.5, colors.get(cls, (255, 255, 255)), 2)
64
- return image
65
-
 
66
  def app():
67
  st.title("Helmet Detection App")
68
  st.write("This app uses YOLOv5 to detect helmets and riders in images and videos.")
 
56
 
57
  return detections
58
 
59
+ def display_detections(input_image, output_image, detections):
60
+ for det in detections:
61
+ x1, y1, x2, y2, conf, detected_name = det
62
+ color = colors.get(detected_name, (255, 255, 255))
63
+ cv2.rectangle(output_image, (x1, y1), (x2, y2), color, 2)
64
+ cv2.putText(output_image, f"{detected_name} ({conf:.2f})", (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
65
+ return output_image
66
+
67
  def app():
68
  st.title("Helmet Detection App")
69
  st.write("This app uses YOLOv5 to detect helmets and riders in images and videos.")