Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,21 @@
|
|
1 |
import gradio as gr
|
2 |
from core_pipeline import extract_frames, detect_trees, plot_detections
|
3 |
-
import numpy as np
|
4 |
|
5 |
-
def process_video(
|
6 |
-
|
|
|
|
|
|
|
7 |
return None
|
8 |
|
|
|
|
|
|
|
|
|
9 |
frames = extract_frames(video_path)
|
10 |
results = []
|
11 |
|
12 |
-
for i, frame in enumerate(frames[:3]):
|
13 |
detected, bboxes, confs, labels = detect_trees(frame)
|
14 |
annotated = plot_detections(detected, bboxes)
|
15 |
results.append(annotated)
|
@@ -21,8 +27,8 @@ def process_video(video_path):
|
|
21 |
|
22 |
gr.Interface(
|
23 |
fn=process_video,
|
24 |
-
inputs=gr.
|
25 |
outputs=gr.Image(label="Tree Detections (Sample Frames)"),
|
26 |
title="🌳 Tree Height Detection from Drone Video",
|
27 |
-
description="Upload
|
28 |
).launch()
|
|
|
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 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp4") as tmp:
|
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 |
|
28 |
gr.Interface(
|
29 |
fn=process_video,
|
30 |
+
inputs=gr.File(label="Upload Drone Video", file_types=[".mp4"]), # ✅ FIXED
|
31 |
outputs=gr.Image(label="Tree Detections (Sample Frames)"),
|
32 |
title="🌳 Tree Height Detection from Drone Video",
|
33 |
+
description="Upload drone video to detect trees. Sample frames will be shown with bounding boxes."
|
34 |
).launch()
|