SuriRaja's picture
Update app.py
0f72c7b verified
raw
history blame
1.44 kB
'''
import gradio as gr
from utils import extract_frames
from model import predict_defect
def analyze_video(video):
frames = extract_frames(video)
results = [predict_defect(frame) for frame in frames]
return results
demo = gr.Interface(
fn=analyze_video,
inputs=gr.Video(label="Upload Drone Video"),
outputs=gr.Gallery(label="Detected Road Defects")
,
title="Drone-based Road Defect Detection",
description="Upload drone footage to identify and highlight road surface defects."
)
if __name__ == "__main__":
demo.launch()
'''
import gradio as gr
import os
from utils import extract_frames
from model import predict_defect
# === 1. Load videos from the Data folder ===
DATA_DIR = "Data"
def get_video_choices():
return [os.path.join(DATA_DIR, f) for f in os.listdir(DATA_DIR) if f.endswith(".mp4")]
# === 2. Analyze selected video ===
def analyze_selected_video(video_path):
frames = extract_frames(video_path)
results = [predict_defect(frame) for frame in frames]
return results
# === 3. Gradio interface ===
demo = gr.Interface(
fn=analyze_selected_video,
inputs=gr.Dropdown(choices=get_video_choices(), label="Select Drone Video"),
outputs=gr.Gallery(label="Detected Road Defects"),
title="Drone-based Road Defect Detection",
description="Select footage from the Data folder to highlight road surface defects."
)
if __name__ == "__main__":
demo.launch()