From 2b7f3c3548951a11edf57b04c5b66098a4691484 Mon Sep 17 00:00:00 2001 From: huangsx Date: Fri, 26 Jul 2024 19:19:59 +0800 Subject: [PATCH] fix JSON serialization error caused by conf=nan --- Prj-Python/hyperlpr3/command/serve.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Prj-Python/hyperlpr3/command/serve.py b/Prj-Python/hyperlpr3/command/serve.py index 5dd9243..276ec04 100644 --- a/Prj-Python/hyperlpr3/command/serve.py +++ b/Prj-Python/hyperlpr3/command/serve.py @@ -108,8 +108,9 @@ async def vehicle_license_plate_recognition(file: List[UploadFile] = File(...)): plates = catcher(img) results = list() for code, conf, plate_type, box in plates: - plate = dict(code=code, conf=float(conf), plate_type=type_list[plate_type], box=box) - results.append(plate) + if "nan" != f"{conf}": # conf=nan会导致Json序列化错误 + plate = dict(code=code, conf=float(conf), plate_type=type_list[plate_type], box=box) + results.append(plate) return BaseResponse().http_ok_response({'plate_list': results})