Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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="
|
| 24 |
title="Scan Spectrum - 2D to 3D Converter",
|
| 25 |
-
description="Upload any 2D image to generate a realistic 3D model you can
|
| 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()
|