tree_height2 / app.py
nagasurendra's picture
Update app.py
7ece5c2 verified
raw
history blame
951 Bytes
import gradio as gr
from core_pipeline import extract_frames, detect_trees, plot_detections
import numpy as np
def process_video(video_path):
if not video_path:
return None
frames = extract_frames(video_path)
results = []
for i, frame in enumerate(frames[:3]): # limit to 3 sample frames for preview
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.Video(label="Upload Drone Video", type="filepath"),
outputs=gr.Image(label="Tree Detections (Sample Frames)"),
title="🌳 Tree Height Detection from Drone Video",
description="Upload top-down drone video to detect trees and visualize sample frames. Height estimation is possible if SfM data is provided."
).launch()