-
-
Notifications
You must be signed in to change notification settings - Fork 332
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
建议: 将ppocr_keys等信息直接存储到onnx模型 #42
Comments
好主意,我去调研一下。 |
再次感谢。 |
issue,我这里先关闭了,以后有问题或者建议可以再次打开。 |
character_dict_path 这个怎么指定?报错了 rapid_ocr = RapidOCR(use_text_det=False, character_dict_path=r"F:\japan_dict.txt",keys_path=r"F:\japan_dict.txt", File "F:\pycharm2020.2\RapidStructure-0.0.0\rapidocr_onnxruntime\rapid_ocr_api.py", line 43, in init |
|
用1楼的代码可以存入字典信息了 import onnx model_path = r'L:\resnet34\4lan\res34.onnx' meta.key = 'dictionary'meta.key = 'character' meta.value = open('/path/to/ppocr_keys_v1.txt', 'r', -1, 'u8').read()meta.value = open(r'F:/japan_dict.txt', 'r', -1, 'u8').read() meta = model.metadata_props.add() model_path_save = r'L:\resnet34\4lan\res34_withDictPath.onnx' onnx.save_model(model, '/path/to/model.onnx')onnx.save_model(model, model_path_save ) 获取meta信息import json sess = ort.InferenceSession('/path/to/model.onnx')sess = ort.InferenceSession(model_path_save) chars = metamap['dictionary'].splitlines()chars = metamap['character'].splitlines() |
目前仓库最新版,已经这么干了。可下载的识别模型里面都有对应的字典了。 |
建议将ppocr_keys, rec_img_shape等信息直接存储到onnx模型
目前, ppocr_keys是单独存放在txt文件, 然后在config.yaml中配置文件路径; rec_img_shape是在config.yaml中配置
这两个参数是和onnx模型强相关的, 可以直接作为元数据存储到onnx模型内, 减少配置的需求.
尤其是ppocr_keys, 目前通过另一个文件来分发, 容易出现两边不一致的情况.
ONNX本身支持自定义元信息的存储. 使用这种方式, 部署相关的配置应该会更简单.
参考代码:
The text was updated successfully, but these errors were encountered: