File size: 947 Bytes
5c0b534
9b4ee8f
 
6b8e3c4
9917d3b
7598e8a
5c0b534
 
 
6b8e3c4
9780d7b
9917d3b
6b8e3c4
 
95036e2
5c0b534
 
 
 
b5815d9
 
 
 
5c0b534
 
 
 
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
import gradio as gr
from segment_anything import SamAutomaticMaskGenerator, sam_model_registry
import supervision as sv
from inference import DepthPredictor, SegmentPredictor
from utils import create_3d_obj, create_3d_pc
import numpy as np


def snap(image, video):
    depth_predictor = DepthPredictor()
    depth_result = depth_predictor.predict(image)
    gltf_path = create_3d_pc(np.array(image), depth_result)
    #segment_predictor = SegmentPredictor()
    #sam_result = segment_predictor.predict(image)
    return [image, gltf_path, gltf_path]#[depth_result, gltf_path, gltf_path]


demo = gr.Interface(
    snap,
    inputs=[gr.Image(source="webcam", tool=None, type="pil"),
            gr.Video(source="webcam")],
    outputs=[gr.Image(label="predicted depth", type="pil"),
             gr.Model3D(label="3d mesh reconstruction", clear_color=[1.0, 1.0, 1.0, 1.0]), gr.File(label="3d gLTF")]
)

if __name__ == "__main__":
    demo.launch()