|
import tempfile |
|
import gradio as gr |
|
from gradio.inputs import Image |
|
from gradio.outputs import Image3D |
|
from gltflib import GLTF, FileResource |
|
|
|
gltf = GLTF.load('./Avocado.glb') |
|
|
|
def load_mesh(im: str): |
|
print(im) |
|
model = gltf.clone() |
|
res = FileResource(im) |
|
with tempfile.NamedTemporaryFile(suffix=".glb", delete=False) as file: |
|
model.export(file.name) |
|
return file.name |
|
|
|
iface = gr.Interface( |
|
fn=load_mesh, |
|
|
|
inputs=Image(source="canvas", type="file", label="canvas"), |
|
outputs=Image3D(), |
|
live=True, |
|
) |
|
|
|
if __name__ == "__main__": |
|
iface.launch() |
|
|