Spaces:
Sleeping
Sleeping
File size: 1,011 Bytes
71bcbad 6379b00 71bcbad 6379b00 71bcbad 6379b00 71bcbad 6379b00 71bcbad 6379b00 71bcbad 6379b00 71bcbad | 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 30 31 32 33 34 | import os
import gradio as gr
from huggingface_hub import InferenceClient
import tempfile
import trimesh
HF_TOKEN = os.getenv("HF_TOKEN") # token environment
client = InferenceClient(token=HF_TOKEN)
def generate_3d(prompt):
result = client.text_to_mesh(
model="Webaverse/Stable-Dreamfusion",
inputs={"prompt": prompt, "num_steps": 100},
)
mesh_bytes = result["output"] # raw mesh bytes
temp = tempfile.NamedTemporaryFile(delete=False, suffix=".ply")
temp.write(mesh_bytes)
temp.flush()
# optionally convert to .glb
mesh = trimesh.load(temp.name)
glb_path = temp.name.replace(".ply", ".glb")
mesh.export(glb_path)
return glb_path
iface = gr.Interface(
fn=generate_3d,
inputs=gr.Textbox(label="Prompt Game Asset"),
outputs=gr.Model3D(label="Generated 3D Asset (.glb)"),
title="Text‑to‑3D Game Asset (Dreamfusion)",
description="Masukkan prompt, hasil akan berupa file .glb yang siap impor ke game engine."
)
iface.launch()
|