File size: 846 Bytes
b06a49c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import gradio as gr
import tempfile
import os

from utils.video_utils import extract_frames
from utils.depth_utils import estimate_depth
from utils.pointcloud_utils import depth_to_pointcloud

def video_to_3d(video):
    with tempfile.TemporaryDirectory() as tmpdir:
        video_path = os.path.join(tmpdir, "input.mp4")
        os.rename(video, video_path)

        frames = extract_frames(video_path, tmpdir)
        depth_maps = estimate_depth(frames)
        ply_path = depth_to_pointcloud(depth_maps, frames, tmpdir)

        return ply_path

demo = gr.Interface(
    fn=video_to_3d,
    inputs=gr.Video(label="Upload Object Video"),
    outputs=gr.File(label="Download 3D Model (.ply)"),
    title="🎥 Video to 3D Model Generator",
    description="Upload a short 360° video of an object to generate a 3D point cloud."
)

demo.launch()