vibs08 commited on
Commit
b00a6a7
·
verified ·
1 Parent(s): a1b0cc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
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
- # Create a temporary directory to store the OBJ file
280
- with tempfile.TemporaryDirectory() as temp_dir:
281
- # Generate OBJ file in the temporary directory
282
- obj_file_path = step_1_generate_obj(image, temp_dir)
283
 
284
- # Generate a unique name for the S3 object
285
- obj_name = f"{uuid.uuid4()}.obj"
286
 
287
- # Upload the OBJ file to S3
288
- s3_url = save_file_to_s3(obj_file_path, 'framebucket3d', obj_name)
289
 
290
- return JSONResponse(content={"Output": s3_url})
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)}")