Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -384,3 +384,51 @@ def process_video(video, resize_width=4000, resize_height=3000, frame_skip=5):
|
|
| 384 |
logs_zip,
|
| 385 |
output_path # For video download
|
| 386 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 384 |
logs_zip,
|
| 385 |
output_path # For video download
|
| 386 |
)
|
| 387 |
+
|
| 388 |
+
# Gradio interface
|
| 389 |
+
with gr.Blocks(theme=gr.themes.Soft(primary_hue="orange")) as iface:
|
| 390 |
+
gr.Markdown("# NHAI Road Defect Detection Dashboard")
|
| 391 |
+
with gr.Row():
|
| 392 |
+
with gr.Column(scale=3):
|
| 393 |
+
video_input = gr.Video(label="Upload Video (12MP recommended for NHAI compliance)")
|
| 394 |
+
width_slider = gr.Slider(320, 4000, value=4000, label="Output Width", step=1)
|
| 395 |
+
height_slider = gr.Slider(240, 3000, value=3000, label="Output Height", step=1)
|
| 396 |
+
skip_slider = gr.Slider(1, 10, value=5, label="Frame Skip", step=1)
|
| 397 |
+
process_btn = gr.Button("Process Video", variant="primary")
|
| 398 |
+
with gr.Column(scale=1):
|
| 399 |
+
metrics_output = gr.Textbox(label="Detection Metrics", lines=5, interactive=False)
|
| 400 |
+
with gr.Row():
|
| 401 |
+
video_output = gr.Video(label="Processed Video")
|
| 402 |
+
issue_gallery = gr.Gallery(label="Detected Issues", columns=4, height="auto", object_fit="contain")
|
| 403 |
+
with gr.Row():
|
| 404 |
+
chart_output = gr.Image(label="Detection Trend")
|
| 405 |
+
map_output = gr.Image(label="Issue Locations Map")
|
| 406 |
+
with gr.Row():
|
| 407 |
+
logs_output = gr.Textbox(label="Logs", lines=5, interactive=False)
|
| 408 |
+
with gr.Row():
|
| 409 |
+
gr.Markdown("## Download Results")
|
| 410 |
+
with gr.Row():
|
| 411 |
+
json_download = gr.File(label="Download Data Lake JSON")
|
| 412 |
+
images_zip_download = gr.File(label="Download Geotagged Images (ZIP)")
|
| 413 |
+
logs_zip_download = gr.File(label="Download Flight Logs (ZIP)")
|
| 414 |
+
video_download = gr.File(label="Download Processed Video")
|
| 415 |
+
|
| 416 |
+
process_btn.click(
|
| 417 |
+
fn=process_video,
|
| 418 |
+
inputs=[video_input, width_slider, height_slider, skip_slider],
|
| 419 |
+
outputs=[
|
| 420 |
+
video_output,
|
| 421 |
+
metrics_output,
|
| 422 |
+
logs_output,
|
| 423 |
+
issue_gallery,
|
| 424 |
+
chart_output,
|
| 425 |
+
map_output,
|
| 426 |
+
json_download,
|
| 427 |
+
images_zip_download,
|
| 428 |
+
logs_zip_download,
|
| 429 |
+
video_download
|
| 430 |
+
]
|
| 431 |
+
)
|
| 432 |
+
|
| 433 |
+
if __name__ == "__main__":
|
| 434 |
+
iface.launch()
|