File size: 1,139 Bytes
7f22df5
91a0ae1
 
 
0885772
91a0ae1
 
0885772
91a0ae1
0885772
91a0ae1
 
 
 
 
0885772
91a0ae1
0885772
91a0ae1
 
0885772
91a0ae1
 
 
 
 
0885772
91a0ae1
 
0885772
91a0ae1
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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.")