siddartha1506 commited on
Commit
b5c2cd4
·
verified ·
1 Parent(s): 1414894

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -11,18 +11,24 @@ def generate_3d(image):
11
  with open(image, "rb") as f:
12
  response = requests.post(API_URL, headers=headers, files={"file": f})
13
  if response.status_code == 200:
14
- return response.content
 
 
 
 
15
  else:
16
  return f"Error: {response.text}"
17
  except Exception as e:
18
  return f"An error occurred: {str(e)}"
19
 
 
20
  iface = gr.Interface(
21
  fn=generate_3d,
22
  inputs=gr.Image(type="filepath", label="Upload 2D Image"),
23
- outputs="model3d",
24
  title="Scan Spectrum - 2D to 3D Converter",
25
- description="Upload any 2D image to generate a realistic 3D model you can rotate and zoom.",
26
  )
27
 
 
28
  iface.launch()
 
11
  with open(image, "rb") as f:
12
  response = requests.post(API_URL, headers=headers, files={"file": f})
13
  if response.status_code == 200:
14
+ # Save the model locally
15
+ output_path = "output.glb"
16
+ with open(output_path, "wb") as out_file:
17
+ out_file.write(response.content)
18
+ return output_path # Gradio will let user download it
19
  else:
20
  return f"Error: {response.text}"
21
  except Exception as e:
22
  return f"An error occurred: {str(e)}"
23
 
24
+
25
  iface = gr.Interface(
26
  fn=generate_3d,
27
  inputs=gr.Image(type="filepath", label="Upload 2D Image"),
28
+ outputs="file", # change here
29
  title="Scan Spectrum - 2D to 3D Converter",
30
+ description="Upload any 2D image to generate a realistic 3D model you can download.",
31
  )
32
 
33
+
34
  iface.launch()