Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import numpy as np | |
| import cv2 | |
| from core_pipeline import extract_frames, detect_trees, plot_detections | |
| def process_video(video_file): | |
| if video_file is None: | |
| return None | |
| video_path = video_file.name # ✅ fix for NamedString input | |
| frames = extract_frames(video_path) | |
| results = [] | |
| for i, frame in enumerate(frames[:3]): # Show top 3 sample frames | |
| 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"]), | |
| outputs=gr.Image(label="Tree Detections (Sample Frames)"), | |
| title="🌳 Drone Tree Detection App", | |
| description="Upload top-down drone footage (.mp4). This app detects trees using YOLOv8 and shows sample frames with bounding boxes." | |
| ).launch() | |