Zanflip commited on
Commit
2ed15be
·
verified ·
1 Parent(s): 9ebbc97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -9,6 +9,8 @@ os.environ["REPLICATE_API_TOKEN"] = "r8_FqBcLY8OR6F3Fsf4D4fT415tb1CN3790UGzYE"
9
 
10
  def generate_3d(prompt):
11
  print("Prompt received:", prompt) # Check if button works
 
 
12
  try:
13
  output = replicate.run(
14
  "openai/shap-e:9c9ecb8d35d0cc0ecde68b8a0d4a2f94f2bc6ee9393e8c3d76c44d7c0d75b1f9",
@@ -18,25 +20,28 @@ def generate_3d(prompt):
18
  "num_inference_steps": 64
19
  }
20
  )
21
-
22
- print("Replicate output:", output) # See what the model gives
23
 
24
  if not output or not isinstance(output, list):
25
  return "Error: No model output."
26
 
27
  glb_url = output[0]
28
- response = requests.get(glb_url)
29
 
 
30
  if response.status_code != 200:
 
31
  return f"Download failed: {response.status_code}"
32
 
33
  file_name = f"{uuid.uuid4()}.glb"
34
  with open(file_name, 'wb') as f:
35
  f.write(response.content)
36
 
 
37
  return file_name
38
 
39
  except Exception as e:
 
40
  return f"Generation failed: {str(e)}"
41
  with gr.Blocks() as demo:
42
  gr.Markdown("## 3D Model Generator (Text to 3D)")
 
9
 
10
  def generate_3d(prompt):
11
  print("Prompt received:", prompt) # Check if button works
12
+ def generate_3d(prompt):
13
+ print("Prompt received:", prompt)
14
  try:
15
  output = replicate.run(
16
  "openai/shap-e:9c9ecb8d35d0cc0ecde68b8a0d4a2f94f2bc6ee9393e8c3d76c44d7c0d75b1f9",
 
20
  "num_inference_steps": 64
21
  }
22
  )
23
+ print("Replicate output:", output)
 
24
 
25
  if not output or not isinstance(output, list):
26
  return "Error: No model output."
27
 
28
  glb_url = output[0]
29
+ print("GLB URL:", glb_url)
30
 
31
+ response = requests.get(glb_url)
32
  if response.status_code != 200:
33
+ print("Download failed with status:", response.status_code)
34
  return f"Download failed: {response.status_code}"
35
 
36
  file_name = f"{uuid.uuid4()}.glb"
37
  with open(file_name, 'wb') as f:
38
  f.write(response.content)
39
 
40
+ print("Saved to:", file_name)
41
  return file_name
42
 
43
  except Exception as e:
44
+ print("Exception occurred:", str(e))
45
  return f"Generation failed: {str(e)}"
46
  with gr.Blocks() as demo:
47
  gr.Markdown("## 3D Model Generator (Text to 3D)")