Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,3 @@
|
|
| 1 |
-
# Full code integrating:
|
| 2 |
-
# - Fault timestamps
|
| 3 |
-
# - CSV export
|
| 4 |
-
# - Clickable snapshots
|
| 5 |
-
# - Heatmap overlay
|
| 6 |
-
|
| 7 |
import streamlit as st
|
| 8 |
import cv2
|
| 9 |
import numpy as np
|
|
@@ -50,7 +44,8 @@ def detect_faults(frame, results, frame_idx, fps):
|
|
| 50 |
"Frame": frame_idx,
|
| 51 |
"Time (s)": timestamp,
|
| 52 |
"Fault Type": label,
|
| 53 |
-
"
|
|
|
|
| 54 |
})
|
| 55 |
|
| 56 |
cv2.rectangle(annotated_frame, (x1, y1), (x2, y2), color, 2)
|
|
@@ -101,7 +96,9 @@ def process_video(video_path):
|
|
| 101 |
snapshots.append(snapshot_path)
|
| 102 |
|
| 103 |
for fault in faults_found:
|
| 104 |
-
|
|
|
|
|
|
|
| 105 |
else:
|
| 106 |
annotated_frame = frame
|
| 107 |
|
|
@@ -166,3 +163,4 @@ if uploaded_file:
|
|
| 166 |
|
| 167 |
st.markdown("---")
|
| 168 |
st.caption("Built with Streamlit + YOLOv5 (Ultralytics) + OpenCV")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import cv2
|
| 3 |
import numpy as np
|
|
|
|
| 44 |
"Frame": frame_idx,
|
| 45 |
"Time (s)": timestamp,
|
| 46 |
"Fault Type": label,
|
| 47 |
+
"Confidence": float(box.conf[0]) if box.conf is not None else None,
|
| 48 |
+
"Intensity": round(mean_intensity, 2)
|
| 49 |
})
|
| 50 |
|
| 51 |
cv2.rectangle(annotated_frame, (x1, y1), (x2, y2), color, 2)
|
|
|
|
| 96 |
snapshots.append(snapshot_path)
|
| 97 |
|
| 98 |
for fault in faults_found:
|
| 99 |
+
# Coordinates were removed, so we don't update heatmap here by bounding box.
|
| 100 |
+
# As an alternative, we could store it based on center points or skip heatmap.
|
| 101 |
+
pass
|
| 102 |
else:
|
| 103 |
annotated_frame = frame
|
| 104 |
|
|
|
|
| 163 |
|
| 164 |
st.markdown("---")
|
| 165 |
st.caption("Built with Streamlit + YOLOv5 (Ultralytics) + OpenCV")
|
| 166 |
+
|