Update app.py
Browse filesgradio
replicate
app.py
CHANGED
@@ -1,15 +1,30 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
def generate_3d(prompt):
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
with gr.Blocks() as demo:
|
9 |
gr.Markdown("## 3D Model Generator (Text to 3D)")
|
10 |
prompt = gr.Textbox(label="Prompt", placeholder="e.g. A sci-fi sword")
|
11 |
-
output = gr.Model3D(label="Generated 3D Model"
|
12 |
-
|
13 |
btn = gr.Button("Generate")
|
14 |
btn.click(fn=generate_3d, inputs=prompt, outputs=output)
|
15 |
|
|
|
1 |
import gradio as gr
|
2 |
+
import replicate
|
3 |
+
import os
|
4 |
+
import uuid
|
5 |
+
|
6 |
+
# Set your Replicate API token
|
7 |
+
os.environ["REPLICATE_API_TOKEN"] = "r8_FqBcLY8OR6F3Fsf4D4fT415tb1CN3790UGzYE"
|
8 |
|
9 |
def generate_3d(prompt):
|
10 |
+
output = replicate.run(
|
11 |
+
"openai/shap-e:9c9ecb8d35d0cc0ecde68b8a0d4a2f94f2bc6ee9393e8c3d76c44d7c0d75b1f9",
|
12 |
+
input={"prompt": prompt, "guidance_scale": 15, "num_inference_steps": 64}
|
13 |
+
)
|
14 |
+
|
15 |
+
# output = [url_to_glb_file]
|
16 |
+
glb_url = output[0]
|
17 |
+
|
18 |
+
# Download the .glb file and return local filename
|
19 |
+
file_name = f"{uuid.uuid4()}.glb"
|
20 |
+
os.system(f"wget {glb_url} -O {file_name}")
|
21 |
+
return file_name
|
22 |
|
23 |
with gr.Blocks() as demo:
|
24 |
gr.Markdown("## 3D Model Generator (Text to 3D)")
|
25 |
prompt = gr.Textbox(label="Prompt", placeholder="e.g. A sci-fi sword")
|
26 |
+
output = gr.Model3D(label="Generated 3D Model")
|
27 |
+
|
28 |
btn = gr.Button("Generate")
|
29 |
btn.click(fn=generate_3d, inputs=prompt, outputs=output)
|
30 |
|