File size: 825 Bytes
29c62a9
58a6f69
 
 
 
 
33ab927
29c62a9
 
58a6f69
 
 
 
 
 
 
 
29c62a9
 
 
 
58a6f69
33ab927
29c62a9
 
 
33ab927
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
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()