3dGen / app.py
Zanflip's picture
Upload 2 files
33ab927 verified
raw
history blame
825 Bytes
import gradio as gr
import replicate
import os
import uuid
# Set your Replicate API token
os.environ["REPLICATE_API_TOKEN"] = "your_token_here"
def generate_3d(prompt):
output = replicate.run(
"openai/shap-e:9c9ecb8d35d0cc0ecde68b8a0d4a2f94f2bc6ee9393e8c3d76c44d7c0d75b1f9",
input={"prompt": prompt, "guidance_scale": 15, "num_inference_steps": 64}
)
glb_url = output[0]
file_name = f"{uuid.uuid4()}.glb"
os.system(f"wget {glb_url} -O {file_name}")
return file_name
with gr.Blocks() as demo:
gr.Markdown("## 3D Model Generator (Text to 3D)")
prompt = gr.Textbox(label="Prompt", placeholder="e.g. A sci-fi sword")
output = gr.Model3D(label="Generated 3D Model")
btn = gr.Button("Generate")
btn.click(fn=generate_3d, inputs=prompt, outputs=output)
demo.launch()