Move to idiomatic python instead of map
...And strip newline from labels.
This commit is contained in:
parent
4302d1d706
commit
686cfefc06
|
@ -39,7 +39,7 @@ file_cleanup_delay = to_int(get_envvar('OBJECTIFIER_CLEANUP_DELAY'))
|
|||
|
||||
yolo_labels = []
|
||||
with open(yolo_labels_file, "r") as f:
|
||||
yolo_labels = f.readlines()
|
||||
yolo_labels = [line.strip() for line in f.readlines()]
|
||||
|
||||
incoming_dir = Path(get_envvar_or_fail('CACHE_DIRECTORY'))
|
||||
outgoing_dir = Path(get_envvar_or_fail('STATE_DIRECTORY'))
|
||||
|
@ -77,7 +77,7 @@ cleanup_thread.start()
|
|||
|
||||
def detection_to_dict(d):
|
||||
return {
|
||||
"label": str(d.label),
|
||||
"label": d.label,
|
||||
"confidence": d.confidence,
|
||||
"box": {
|
||||
"x": d.box[0],
|
||||
|
@ -89,8 +89,8 @@ def detection_to_dict(d):
|
|||
|
||||
def result_to_dict(res, base_url):
|
||||
return {
|
||||
"labels": list(map(lambda d: str(d.label), res.detections)),
|
||||
"detections": list(map(detection_to_dict, res.detections)),
|
||||
"labels": [detection.label for detection in res.dectections],
|
||||
"detections": [detection_to_dict(dectection) for detection in res.detections],
|
||||
"output": base_url + basename(res.outfile),
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue