Update app.py
Browse files
app.py
CHANGED
|
@@ -276,18 +276,16 @@ async def upload_image(file: UploadFile = File(...)):
|
|
| 276 |
# Convert uploaded file to PIL Image
|
| 277 |
image = Image.open(io.BytesIO(await file.read()))
|
| 278 |
|
| 279 |
-
#
|
| 280 |
-
|
| 281 |
-
# Generate OBJ file in the temporary directory
|
| 282 |
-
obj_file_path = step_1_generate_obj(image, temp_dir)
|
| 283 |
|
| 284 |
-
|
| 285 |
-
|
| 286 |
|
| 287 |
-
|
| 288 |
-
|
| 289 |
|
| 290 |
-
|
| 291 |
|
| 292 |
except Exception as e:
|
| 293 |
raise HTTPException(status_code=500, detail=f"Error processing the image: {str(e)}")
|
|
|
|
| 276 |
# Convert uploaded file to PIL Image
|
| 277 |
image = Image.open(io.BytesIO(await file.read()))
|
| 278 |
|
| 279 |
+
# Generate OBJ file in the temporary directory
|
| 280 |
+
obj_file_path = step_1_generate_obj(image)
|
|
|
|
|
|
|
| 281 |
|
| 282 |
+
# Generate a unique name for the S3 object
|
| 283 |
+
obj_name = f"object{uuid.uuid4()}.obj"
|
| 284 |
|
| 285 |
+
# Upload the OBJ file to S3
|
| 286 |
+
s3_url = upload_file_to_s3(obj_file_path, 'framebucket3d', obj_name)
|
| 287 |
|
| 288 |
+
return JSONResponse(content={"Output": s3_url})
|
| 289 |
|
| 290 |
except Exception as e:
|
| 291 |
raise HTTPException(status_code=500, detail=f"Error processing the image: {str(e)}")
|