From 9dd9e38eaba206f3a6eb431689391be6f4a5037f Mon Sep 17 00:00:00 2001 From: niten Date: Tue, 10 Jan 2023 16:07:55 -0800 Subject: [PATCH] Be more specific about where to write the outfile --- src/objectifier.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/objectifier.py b/src/objectifier.py index d9184f4..575be73 100644 --- a/src/objectifier.py +++ b/src/objectifier.py @@ -125,15 +125,17 @@ def analyze_image(request: Request, image: UploadFile): chunk = image.file.read(buffer_size) print("save complete") print("analyzing image") - result = detector.detect_objects(infile, file_hash.hexdigest() + ".png") + result = detector.detect_objects( + infile, + str(outgoing_dir / (file_hash.hexdigest() + ".png"))) print("image analyzed") remove(infile) return result_to_dict(result, base_url) -@app.get("/analyzed_images/${image_name}", response_class=FileResponse) -def get_analyzed_image(image_name): - filename = str(outgoing_dir / image_name) +@app.get("/analyzed_images/{image_name}", response_class=FileResponse) +def get_analyzed_image(image_name: str): + filename = outgoing_dir / image_name if path.isfile(filename): - return filename + return str(filename) else: - raise HTTPException(status_code=404, detail="file not found: " + filename) + raise HTTPException(status_code=404, detail="file not found: " + str(filename))