Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import tempfile
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
from utils.video_utils import extract_frames
|
| 6 |
+
from utils.depth_utils import estimate_depth
|
| 7 |
+
from utils.pointcloud_utils import depth_to_pointcloud
|
| 8 |
+
|
| 9 |
+
def video_to_3d(video):
|
| 10 |
+
with tempfile.TemporaryDirectory() as tmpdir:
|
| 11 |
+
video_path = os.path.join(tmpdir, "input.mp4")
|
| 12 |
+
os.rename(video, video_path)
|
| 13 |
+
|
| 14 |
+
frames = extract_frames(video_path, tmpdir)
|
| 15 |
+
depth_maps = estimate_depth(frames)
|
| 16 |
+
ply_path = depth_to_pointcloud(depth_maps, frames, tmpdir)
|
| 17 |
+
|
| 18 |
+
return ply_path
|
| 19 |
+
|
| 20 |
+
demo = gr.Interface(
|
| 21 |
+
fn=video_to_3d,
|
| 22 |
+
inputs=gr.Video(label="Upload Object Video"),
|
| 23 |
+
outputs=gr.File(label="Download 3D Model (.ply)"),
|
| 24 |
+
title="🎥 Video to 3D Model Generator",
|
| 25 |
+
description="Upload a short 360° video of an object to generate a 3D point cloud."
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
demo.launch()
|