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
|
|
@@ -58,10 +52,6 @@ def detect_faults(frame, results, frame_idx, fps):
|
|
| 58 |
"Fault Type": label,
|
| 59 |
"Confidence": round(float(box.conf[0]), 2) if box.conf is not None else None,
|
| 60 |
"Intensity": round(mean_intensity, 2),
|
| 61 |
-
"X1": x1,
|
| 62 |
-
"Y1": y1,
|
| 63 |
-
"X2": x2,
|
| 64 |
-
"Y2": y2,
|
| 65 |
"Box": f"({x1}, {y1}, {x2}, {y2})"
|
| 66 |
})
|
| 67 |
|
|
@@ -71,7 +61,6 @@ def detect_faults(frame, results, frame_idx, fps):
|
|
| 71 |
|
| 72 |
return annotated_frame, faults_found
|
| 73 |
|
| 74 |
-
|
| 75 |
def process_video(video_path):
|
| 76 |
cap = cv2.VideoCapture(video_path)
|
| 77 |
if not cap.isOpened():
|
|
@@ -115,7 +104,8 @@ def process_video(video_path):
|
|
| 115 |
snapshots.append(snapshot_path)
|
| 116 |
|
| 117 |
for fault in faults_found:
|
| 118 |
-
|
|
|
|
| 119 |
else:
|
| 120 |
annotated_frame = frame
|
| 121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import cv2
|
| 3 |
import numpy as np
|
|
|
|
| 52 |
"Fault Type": label,
|
| 53 |
"Confidence": round(float(box.conf[0]), 2) if box.conf is not None else None,
|
| 54 |
"Intensity": round(mean_intensity, 2),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
"Box": f"({x1}, {y1}, {x2}, {y2})"
|
| 56 |
})
|
| 57 |
|
|
|
|
| 61 |
|
| 62 |
return annotated_frame, faults_found
|
| 63 |
|
|
|
|
| 64 |
def process_video(video_path):
|
| 65 |
cap = cv2.VideoCapture(video_path)
|
| 66 |
if not cap.isOpened():
|
|
|
|
| 104 |
snapshots.append(snapshot_path)
|
| 105 |
|
| 106 |
for fault in faults_found:
|
| 107 |
+
x1, y1, x2, y2 = map(int, fault["Box"].strip("()").split(","))
|
| 108 |
+
heatmap[y1:y2, x1:x2] += 1
|
| 109 |
else:
|
| 110 |
annotated_frame = frame
|
| 111 |
|