WTF is with Python map?

This commit is contained in:
niten 2023-01-10 15:51:09 -08:00
parent 77813871a2
commit 50a22caea1
1 changed files with 3 additions and 5 deletions

View File

@ -85,8 +85,8 @@ def detection_to_dict(d):
def result_to_dict(res, base_url):
return {
"labels": map(lambda d: d.label, res.detections),
"detections": map(detection_to_dict, res.detections),
"labels": list(map(lambda d: d.label, res.detections)),
"detections": list(map(detection_to_dict, res.detections)),
"output": base_url + res.outfile,
}
@ -128,9 +128,7 @@ def analyze_image(request: Request, image: UploadFile):
result = detector.detect_objects(infile, file_hash.hexdigest() + ".png")
print("image analyzed")
remove(infile)
ret = result_to_dict(result, base_url)
print(ret)
return ret
return result_to_dict(result, base_url)
@app.get("/analyzed_images/${image_name}", response_class=FileResponse)
def get_analyzed_image(image_name):