Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,17 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
from core_pipeline import extract_frames, detect_trees, plot_detections
|
| 3 |
|
| 4 |
def process_video(video_file):
|
| 5 |
-
import tempfile
|
| 6 |
-
import numpy as np
|
| 7 |
-
|
| 8 |
if video_file is None:
|
| 9 |
return None
|
| 10 |
|
| 11 |
-
|
| 12 |
-
tmp.write(video_file.read())
|
| 13 |
-
video_path = tmp.name
|
| 14 |
-
|
| 15 |
frames = extract_frames(video_path)
|
| 16 |
results = []
|
| 17 |
|
| 18 |
-
for i, frame in enumerate(frames[:3]):
|
| 19 |
detected, bboxes, confs, labels = detect_trees(frame)
|
| 20 |
annotated = plot_detections(detected, bboxes)
|
| 21 |
results.append(annotated)
|
|
@@ -27,8 +23,8 @@ def process_video(video_file):
|
|
| 27 |
|
| 28 |
gr.Interface(
|
| 29 |
fn=process_video,
|
| 30 |
-
inputs=gr.File(label="Upload Drone Video", file_types=[".mp4"]),
|
| 31 |
outputs=gr.Image(label="Tree Detections (Sample Frames)"),
|
| 32 |
-
title="🌳 Tree
|
| 33 |
-
description="Upload drone
|
| 34 |
).launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import numpy as np
|
| 3 |
+
import cv2
|
| 4 |
from core_pipeline import extract_frames, detect_trees, plot_detections
|
| 5 |
|
| 6 |
def process_video(video_file):
|
|
|
|
|
|
|
|
|
|
| 7 |
if video_file is None:
|
| 8 |
return None
|
| 9 |
|
| 10 |
+
video_path = video_file.name # ✅ fix for NamedString input
|
|
|
|
|
|
|
|
|
|
| 11 |
frames = extract_frames(video_path)
|
| 12 |
results = []
|
| 13 |
|
| 14 |
+
for i, frame in enumerate(frames[:3]): # Show top 3 sample frames
|
| 15 |
detected, bboxes, confs, labels = detect_trees(frame)
|
| 16 |
annotated = plot_detections(detected, bboxes)
|
| 17 |
results.append(annotated)
|
|
|
|
| 23 |
|
| 24 |
gr.Interface(
|
| 25 |
fn=process_video,
|
| 26 |
+
inputs=gr.File(label="Upload Drone Video", file_types=[".mp4"]),
|
| 27 |
outputs=gr.Image(label="Tree Detections (Sample Frames)"),
|
| 28 |
+
title="🌳 Drone Tree Detection App",
|
| 29 |
+
description="Upload top-down drone footage (.mp4). This app detects trees using YOLOv8 and shows sample frames with bounding boxes."
|
| 30 |
).launch()
|