Spaces:
Sleeping
Sleeping
import gradio as gr | |
from core_pipeline import extract_frames, detect_trees, plot_detections | |
def process_video(video_file): | |
import tempfile | |
import numpy as np | |
if video_file is None: | |
return None | |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp4") as tmp: | |
tmp.write(video_file.read()) | |
video_path = tmp.name | |
frames = extract_frames(video_path) | |
results = [] | |
for i, frame in enumerate(frames[:3]): | |
detected, bboxes, confs, labels = detect_trees(frame) | |
annotated = plot_detections(detected, bboxes) | |
results.append(annotated) | |
if results: | |
preview = np.hstack(results) | |
return preview | |
return None | |
gr.Interface( | |
fn=process_video, | |
inputs=gr.File(label="Upload Drone Video", file_types=[".mp4"]), # β FIXED | |
outputs=gr.Image(label="Tree Detections (Sample Frames)"), | |
title="π³ Tree Height Detection from Drone Video", | |
description="Upload drone video to detect trees. Sample frames will be shown with bounding boxes." | |
).launch() | |