# PPOCR-ONNX
## 简介
利用 onnxruntime 及 PaddleOCR 提供的模型, 对图片中的文字进行检测与识别.
### 使用模型
- 文字检测: `ch_PP-OCRv3_det_infer`
- 方向分类: `cls mobile v2`
- 文字识别: `ch_PP-OCRv2_rec_infer`
## 参考
- [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)
- [手把手教你使用ONNXRunTime部署PP-OCR](https://aistudio.baidu.com/aistudio/projectdetail/1479970)
- `ch_PP-OCRv3_det_infer` 及 `ch_PP-OCRv2_rec_infer` 模型来自 [RapidAI/RapidOCR](https://github.com/RapidAI/RapidOCR)
## 安装
```bash
pip install ppocr-onnx
```
## 使用
```python
from ppocronnx.predict_system import TextSystem
import cv2
text_sys = TextSystem()
# 识别单行文本
res = text_sys.ocr_single_line(cv2.imread('single_line_text.png'))
print(res)
# 批量识别单行文本
res = text_sys.ocr_lines([cv2.imread('single_line_text.png')])
print(res[0])
# 检测并识别文本
img = cv2.imread('test.png')
res = text_sys.detect_and_ocr(img)
for boxed_result in res:
print("{}, {:.3f}".format(boxed_result.ocr_text, boxed_result.score))
```
Raw data
{
"_id": null,
"home_page": "https://github.com/triwinds/ppocr-onnx",
"name": "ppocr-onnx",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "triwinds",
"author_email": "triwinds@foxmail.com",
"download_url": "https://files.pythonhosted.org/packages/cc/dc/445da1216d93dbc24b558325dc23e0d063a09df393fff9e4689f77605302/ppocr-onnx-0.0.3.9.tar.gz",
"platform": null,
"description": "# PPOCR-ONNX\r\n\r\n\r\n## \u7b80\u4ecb\r\n\r\n\u5229\u7528 onnxruntime \u53ca PaddleOCR \u63d0\u4f9b\u7684\u6a21\u578b, \u5bf9\u56fe\u7247\u4e2d\u7684\u6587\u5b57\u8fdb\u884c\u68c0\u6d4b\u4e0e\u8bc6\u522b.\r\n\r\n### \u4f7f\u7528\u6a21\u578b\r\n\r\n - \u6587\u5b57\u68c0\u6d4b: `ch_PP-OCRv3_det_infer`\r\n - \u65b9\u5411\u5206\u7c7b: `cls mobile v2`\r\n - \u6587\u5b57\u8bc6\u522b: `ch_PP-OCRv2_rec_infer`\r\n\r\n## \u53c2\u8003\r\n\r\n - [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)\r\n - [\u624b\u628a\u624b\u6559\u4f60\u4f7f\u7528ONNXRunTime\u90e8\u7f72PP-OCR](https://aistudio.baidu.com/aistudio/projectdetail/1479970)\r\n - `ch_PP-OCRv3_det_infer` \u53ca `ch_PP-OCRv2_rec_infer` \u6a21\u578b\u6765\u81ea [RapidAI/RapidOCR](https://github.com/RapidAI/RapidOCR)\r\n\r\n## \u5b89\u88c5\r\n\r\n```bash\r\npip install ppocr-onnx\r\n```\r\n\r\n## \u4f7f\u7528\r\n\r\n```python\r\nfrom ppocronnx.predict_system import TextSystem\r\nimport cv2\r\n\r\ntext_sys = TextSystem()\r\n\r\n# \u8bc6\u522b\u5355\u884c\u6587\u672c\r\nres = text_sys.ocr_single_line(cv2.imread('single_line_text.png'))\r\nprint(res)\r\n\r\n# \u6279\u91cf\u8bc6\u522b\u5355\u884c\u6587\u672c\r\nres = text_sys.ocr_lines([cv2.imread('single_line_text.png')])\r\nprint(res[0])\r\n\r\n# \u68c0\u6d4b\u5e76\u8bc6\u522b\u6587\u672c\r\nimg = cv2.imread('test.png')\r\nres = text_sys.detect_and_ocr(img)\r\nfor boxed_result in res:\r\n print(\"{}, {:.3f}\".format(boxed_result.ocr_text, boxed_result.score))\r\n```\r\n",
"bugtrack_url": null,
"license": "Apache 2.0",
"summary": "\u5229\u7528 onnxruntime \u53ca PaddleOCR \u63d0\u4f9b\u7684\u6a21\u578b, \u5bf9\u56fe\u7247\u4e2d\u7684\u6587\u5b57\u8fdb\u884c\u68c0\u6d4b\u4e0e\u8bc6\u522b.",
"version": "0.0.3.9",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e5761198f531939532509ff6616b44eda6d3b913f305ff8868eb14406268b484",
"md5": "df41ff300e63b20385d802e3ee901366",
"sha256": "a5c5d89e94b847b31bcacbc07a54cb5cb11eda719b32f5e66a32cd2a7dfd75f0"
},
"downloads": -1,
"filename": "ppocr_onnx-0.0.3.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "df41ff300e63b20385d802e3ee901366",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 10497033,
"upload_time": "2023-01-10T13:01:47",
"upload_time_iso_8601": "2023-01-10T13:01:47.031387Z",
"url": "https://files.pythonhosted.org/packages/e5/76/1198f531939532509ff6616b44eda6d3b913f305ff8868eb14406268b484/ppocr_onnx-0.0.3.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ccdc445da1216d93dbc24b558325dc23e0d063a09df393fff9e4689f77605302",
"md5": "4e5a097862795d3ed5633b58b8de0228",
"sha256": "7148c6a035e01a8e0a37389ac68dd59c1271e799c52348051319dfd0a076359d"
},
"downloads": -1,
"filename": "ppocr-onnx-0.0.3.9.tar.gz",
"has_sig": false,
"md5_digest": "4e5a097862795d3ed5633b58b8de0228",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 10496582,
"upload_time": "2023-01-10T13:01:50",
"upload_time_iso_8601": "2023-01-10T13:01:50.265664Z",
"url": "https://files.pythonhosted.org/packages/cc/dc/445da1216d93dbc24b558325dc23e0d063a09df393fff9e4689f77605302/ppocr-onnx-0.0.3.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-10 13:01:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "triwinds",
"github_project": "ppocr-onnx",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "onnxruntime",
"specs": []
},
{
"name": "numpy",
"specs": []
},
{
"name": "opencv-python",
"specs": []
},
{
"name": "shapely",
"specs": []
},
{
"name": "pyclipper",
"specs": []
},
{
"name": "pillow",
"specs": []
},
{
"name": "requests",
"specs": []
}
],
"lcname": "ppocr-onnx"
}