app.py
CHANGED
@@ -13,9 +13,9 @@ import os
|
|
13 |
app = FastAPI()
|
14 |
|
15 |
# Mount a static directory for serving images
|
16 |
-
folder = os.path.join(os.getcwd(), "static")
|
17 |
os.makedirs(folder)
|
18 |
-
app.mount("/static", StaticFiles(directory="static"), name="static")
|
19 |
|
20 |
# Templates for rendering HTML
|
21 |
templates = Jinja2Templates(directory="templates")
|
@@ -54,7 +54,7 @@ async def create_upload_file(file: UploadFile = File(...)):
|
|
54 |
image = Image.open(io.BytesIO(contents))
|
55 |
|
56 |
# Save the image to a static directory
|
57 |
-
save_path = f"static/{file.filename}"
|
58 |
image.save(save_path)
|
59 |
|
60 |
# Perform YOLO prediction
|
@@ -65,7 +65,7 @@ async def create_upload_file(file: UploadFile = File(...)):
|
|
65 |
image_with_boxes = draw_boxes(image_np, predictions)
|
66 |
|
67 |
# Save the image with bounding boxes
|
68 |
-
image_with_boxes_path = f"static/{file.filename.split('.')[0]}_with_boxes.jpg"
|
69 |
cv2.imwrite(image_with_boxes_path, cv2.cvtColor(image_with_boxes, cv2.COLOR_RGB2BGR))
|
70 |
|
71 |
# Render the HTML with the image and bounding boxes
|
|
|
13 |
app = FastAPI()
|
14 |
|
15 |
# Mount a static directory for serving images
|
16 |
+
folder = os.path.join(os.getcwd(), "/usr/src/tmp/static")
|
17 |
os.makedirs(folder)
|
18 |
+
app.mount("/usr/src/tmp/static", StaticFiles(directory="usr/src/tmp/static"), name="static")
|
19 |
|
20 |
# Templates for rendering HTML
|
21 |
templates = Jinja2Templates(directory="templates")
|
|
|
54 |
image = Image.open(io.BytesIO(contents))
|
55 |
|
56 |
# Save the image to a static directory
|
57 |
+
save_path = f"/usr/src/tmp/static/{file.filename}"
|
58 |
image.save(save_path)
|
59 |
|
60 |
# Perform YOLO prediction
|
|
|
65 |
image_with_boxes = draw_boxes(image_np, predictions)
|
66 |
|
67 |
# Save the image with bounding boxes
|
68 |
+
image_with_boxes_path = f"/usr/src/tmp/static/{file.filename.split('.')[0]}_with_boxes.jpg"
|
69 |
cv2.imwrite(image_with_boxes_path, cv2.cvtColor(image_with_boxes, cv2.COLOR_RGB2BGR))
|
70 |
|
71 |
# Render the HTML with the image and bounding boxes
|