File size: 1,440 Bytes
0f72c7b
179bd59
 
 
 
 
8f4b4c0
179bd59
 
 
 
 
 
72d54a5
 
179bd59
 
 
 
0f72c7b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179bd59
 
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'''
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()