Zanflip commited on
Commit
6a923f9
·
verified ·
1 Parent(s): 49fb9a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -6,16 +6,19 @@ import uuid
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
  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
18
-
19
  with gr.Blocks() as demo:
20
  gr.Markdown("## 3D Model Generator (Text to 3D)")
21
  prompt = gr.Textbox(label="Prompt", placeholder="e.g. A sci-fi sword")
 
6
  # Set your Replicate API token
7
  os.environ["REPLICATE_API_TOKEN"] = "r8_FqBcLY8OR6F3Fsf4D4fT415tb1CN3790UGzYE"
8
 
9
+ import requests
10
+
11
  def generate_3d(prompt):
12
  output = replicate.run(
13
  "openai/shap-e:9c9ecb8d35d0cc0ecde68b8a0d4a2f94f2bc6ee9393e8c3d76c44d7c0d75b1f9",
14
  input={"prompt": prompt, "guidance_scale": 15, "num_inference_steps": 64}
15
  )
16
  glb_url = output[0]
17
+ response = requests.get(glb_url)
18
  file_name = f"{uuid.uuid4()}.glb"
19
+ with open(file_name, 'wb') as f:
20
+ f.write(response.content)
21
  return file_name
 
22
  with gr.Blocks() as demo:
23
  gr.Markdown("## 3D Model Generator (Text to 3D)")
24
  prompt = gr.Textbox(label="Prompt", placeholder="e.g. A sci-fi sword")