Naveenkumar1546 commited on
Commit
65c2d6d
·
verified ·
1 Parent(s): b703594

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -14
app.py CHANGED
@@ -38,6 +38,7 @@ def detect_faults(frame, results, frame_idx, fps):
38
  mean_intensity = np.mean(roi)
39
  area = (x2 - x1) * (y2 - y1)
40
 
 
41
  if mean_intensity > 240:
42
  label = "Burned Solar Panel" if area >= 10000 else "Burned Solar Cell"
43
  color = (0, 0, 255)
@@ -51,25 +52,26 @@ def detect_faults(frame, results, frame_idx, fps):
51
  continue
52
 
53
  timestamp = round(frame_idx / fps, 2)
54
- faults_found.append({
55
- "Frame": frame_idx,
56
- "Time (s)": timestamp,
57
- "Fault Type": label,
58
- "Confidence": round(float(box.conf[0]), 2) if box.conf is not None else None,
59
- "Intensity": round(mean_intensity, 2),
60
- "X1": x1,
61
- "Y1": y1,
62
- "X2": x2,
63
- "Y2": y2,
64
- "Box": f"({x1}, {y1}, {x2}, {y2})"
65
- })
66
-
67
-
68
  cv2.rectangle(annotated_frame, (x1, y1), (x2, y2), color, 2)
69
  cv2.putText(annotated_frame, label, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
70
 
71
  return annotated_frame, faults_found
72
 
 
73
  def process_video(video_path):
74
  cap = cv2.VideoCapture(video_path)
75
  if not cap.isOpened():
 
38
  mean_intensity = np.mean(roi)
39
  area = (x2 - x1) * (y2 - y1)
40
 
41
+ # Fault classification logic
42
  if mean_intensity > 240:
43
  label = "Burned Solar Panel" if area >= 10000 else "Burned Solar Cell"
44
  color = (0, 0, 255)
 
52
  continue
53
 
54
  timestamp = round(frame_idx / fps, 2)
55
+ faults_found.append({
56
+ "Frame": frame_idx,
57
+ "Time (s)": timestamp,
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
+
68
+ # Annotate frame
69
  cv2.rectangle(annotated_frame, (x1, y1), (x2, y2), color, 2)
70
  cv2.putText(annotated_frame, label, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
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():