Update app.py
Browse files
app.py
CHANGED
|
@@ -56,13 +56,14 @@ def detect_objects(frame):
|
|
| 56 |
|
| 57 |
return detections
|
| 58 |
|
| 59 |
-
def display_detections(
|
| 60 |
-
for
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
cv2.
|
| 64 |
-
|
| 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.")
|