Upload 2 files
Browse files- app.py +3 -7
- requirements.txt +2 -0
app.py
CHANGED
@@ -4,18 +4,14 @@ import os
|
|
4 |
import uuid
|
5 |
|
6 |
# Set your Replicate API token
|
7 |
-
os.environ["REPLICATE_API_TOKEN"] = "
|
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
|
@@ -24,8 +20,8 @@ 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 |
|
31 |
-
demo.launch()
|
|
|
4 |
import uuid
|
5 |
|
6 |
# Set your Replicate API token
|
7 |
+
os.environ["REPLICATE_API_TOKEN"] = "your_token_here"
|
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 |
glb_url = output[0]
|
|
|
|
|
15 |
file_name = f"{uuid.uuid4()}.glb"
|
16 |
os.system(f"wget {glb_url} -O {file_name}")
|
17 |
return file_name
|
|
|
20 |
gr.Markdown("## 3D Model Generator (Text to 3D)")
|
21 |
prompt = gr.Textbox(label="Prompt", placeholder="e.g. A sci-fi sword")
|
22 |
output = gr.Model3D(label="Generated 3D Model")
|
23 |
+
|
24 |
btn = gr.Button("Generate")
|
25 |
btn.click(fn=generate_3d, inputs=prompt, outputs=output)
|
26 |
|
27 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
replicate
|