Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在使用识别模型ch_PP-OCRv3部署http服务时,返回结果会出现json序列号报错 #291

Open
YanceyHo opened this issue Nov 10, 2023 · 0 comments

Comments

@YanceyHo
Copy link

当使用 scripts/flask-serve.py 脚本部署 rec_model_name='ch_PP-OCRv3' 的http服务时会出现如下错误

raise TypeError(f"Object of type {type(o).__name__} is not JSON serializable")
TypeError: Object of type float32 is not JSON serializable

经排查发现是此处漏掉了score的类型转换,此处的score类型是np.float32无法序列化

for _one in res:
    _one['position'] = _one['position'].tolist()
    _one['score'] = float(_one['score'])  #此处score也要加上转换
    if 'cropped_img' in _one:
        _one.pop('cropped_img')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant