import streamlit as st from video_utils import extract_frames, annotate_video from model import predict_fault import os st.title("🔍 Solar Panel Fault Detection from Video") st.write("Upload a drone video of solar panels to detect faults: **cracked**, **dusted**, **shaded**, **overheated**.") uploaded_file = st.file_uploader("Upload a solar panel video", type=["mp4", "avi"]) if uploaded_file is not None: # Save uploaded video temporarily video_path = os.path.join("temp_video.mp4") with open(video_path, "wb") as f: f.write(uploaded_file.read()) st.video(video_path) st.write("🔎 Processing video...") frames = extract_frames(video_path, interval=30) # every 30th frame (~1/sec) predictions = {} for frame_idx, image in frames: label = predict_fault(image) predictions[frame_idx] = label st.image(image, caption=f"Frame {frame_idx}: {label}", use_column_width=True) st.write("🎞️ Generating annotated video...") output_video_path = annotate_video(video_path, predictions) st.video(output_video_path) st.success("✅ Detection complete.")