Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
from utils import extract_frames
|
3 |
from model import predict_defect
|
@@ -16,5 +17,35 @@ demo = gr.Interface(
|
|
16 |
description="Upload drone footage to identify and highlight road surface defects."
|
17 |
)
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
if __name__ == "__main__":
|
20 |
demo.launch()
|
|
|
1 |
+
'''
|
2 |
import gradio as gr
|
3 |
from utils import extract_frames
|
4 |
from model import predict_defect
|
|
|
17 |
description="Upload drone footage to identify and highlight road surface defects."
|
18 |
)
|
19 |
|
20 |
+
if __name__ == "__main__":
|
21 |
+
demo.launch()
|
22 |
+
'''
|
23 |
+
|
24 |
+
import gradio as gr
|
25 |
+
import os
|
26 |
+
from utils import extract_frames
|
27 |
+
from model import predict_defect
|
28 |
+
|
29 |
+
# === 1. Load videos from the Data folder ===
|
30 |
+
DATA_DIR = "Data"
|
31 |
+
|
32 |
+
def get_video_choices():
|
33 |
+
return [os.path.join(DATA_DIR, f) for f in os.listdir(DATA_DIR) if f.endswith(".mp4")]
|
34 |
+
|
35 |
+
# === 2. Analyze selected video ===
|
36 |
+
def analyze_selected_video(video_path):
|
37 |
+
frames = extract_frames(video_path)
|
38 |
+
results = [predict_defect(frame) for frame in frames]
|
39 |
+
return results
|
40 |
+
|
41 |
+
# === 3. Gradio interface ===
|
42 |
+
demo = gr.Interface(
|
43 |
+
fn=analyze_selected_video,
|
44 |
+
inputs=gr.Dropdown(choices=get_video_choices(), label="Select Drone Video"),
|
45 |
+
outputs=gr.Gallery(label="Detected Road Defects"),
|
46 |
+
title="Drone-based Road Defect Detection",
|
47 |
+
description="Select footage from the Data folder to highlight road surface defects."
|
48 |
+
)
|
49 |
+
|
50 |
if __name__ == "__main__":
|
51 |
demo.launch()
|