WTF is with Python map?
This commit is contained in:
parent
77813871a2
commit
50a22caea1
|
@ -85,8 +85,8 @@ def detection_to_dict(d):
|
||||||
|
|
||||||
def result_to_dict(res, base_url):
|
def result_to_dict(res, base_url):
|
||||||
return {
|
return {
|
||||||
"labels": map(lambda d: d.label, res.detections),
|
"labels": list(map(lambda d: d.label, res.detections)),
|
||||||
"detections": map(detection_to_dict, res.detections),
|
"detections": list(map(detection_to_dict, res.detections)),
|
||||||
"output": base_url + res.outfile,
|
"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")
|
result = detector.detect_objects(infile, file_hash.hexdigest() + ".png")
|
||||||
print("image analyzed")
|
print("image analyzed")
|
||||||
remove(infile)
|
remove(infile)
|
||||||
ret = result_to_dict(result, base_url)
|
return result_to_dict(result, base_url)
|
||||||
print(ret)
|
|
||||||
return ret
|
|
||||||
|
|
||||||
@app.get("/analyzed_images/${image_name}", response_class=FileResponse)
|
@app.get("/analyzed_images/${image_name}", response_class=FileResponse)
|
||||||
def get_analyzed_image(image_name):
|
def get_analyzed_image(image_name):
|
||||||
|
|
Loading…
Reference in New Issue