Update app.py
Browse files
app.py
CHANGED
@@ -274,24 +274,34 @@ def upload_file_to_s3(file_path, bucket_name, object_name):
|
|
274 |
|
275 |
@app.post("/upload/")
|
276 |
async def upload_image(file: UploadFile = File(...)):
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
#
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
|
291 |
-
|
292 |
-
|
293 |
-
except Exception as e:
|
294 |
-
raise HTTPException(status_code=500, detail=f"Error processing the image: {str(e)}")
|
295 |
|
296 |
# Run FastAPI
|
297 |
if __name__ == "__main__":
|
|
|
274 |
|
275 |
@app.post("/upload/")
|
276 |
async def upload_image(file: UploadFile = File(...)):
|
277 |
+
image_bytes = await file.read()
|
278 |
+
img_input = Image.open(BytesIO(image_bytes))
|
279 |
+
model_output = LitModel3D(
|
280 |
+
clear_color=[0.1, 0.1, 0.1, 0], # can adjust background color for better contrast
|
281 |
+
label="3D Model Visualization",
|
282 |
+
scale=1.0,
|
283 |
+
tonemapping="aces", # can use aces tonemapping for more realistic lighting
|
284 |
+
exposure=1.0, # can adjust exposure to control brightness
|
285 |
+
contrast=1.1, # can slightly increase contrast for better depth
|
286 |
+
camera_position=(0, 0, 2), # will set initial camera position to center the model
|
287 |
+
zoom_speed=0.5, # will adjust zoom speed for better control
|
288 |
+
pan_speed=0.5, # will adjust pan speed for better control
|
289 |
+
interactive=True # this allow users to interact with the model
|
290 |
+
)
|
291 |
+
|
292 |
+
obj_file_output, model_output = step_1_generate_obj(img_input)
|
293 |
+
|
294 |
+
timestamp = datetime.datetime.now().astimezone().strftime('%Y%m%d%H%M%S%f%z')
|
295 |
+
object_name = f'object_{timestamp}.obj'
|
296 |
+
|
297 |
+
if upload_file_to_s3(obj_file_output, 'framebucket3d',object_name):
|
298 |
+
|
299 |
+
return {
|
300 |
+
"obj_path": f"https://framebucket3d.s3.amazonaws.com/{object_name}"
|
301 |
+
}
|
302 |
|
303 |
+
|
304 |
+
|
|
|
|
|
305 |
|
306 |
# Run FastAPI
|
307 |
if __name__ == "__main__":
|