{"id":27606877,"url":"https://github.com/shibing624/imgocr","last_synced_at":"2026-04-11T17:21:05.975Z","repository":{"id":268650909,"uuid":"905052625","full_name":"shibing624/imgocr","owner":"shibing624","description":"Python3 package for Chinese/English OCR, with paddleocr-v4 onnx model(~14MB). 基于ppocr-v4-onnx模型推理，可实现 CPU 上毫秒级的 OCR 精准预测，通用场景中英文OCR达到开源SOTA。","archived":false,"fork":false,"pushed_at":"2025-01-22T09:07:05.000Z","size":28891,"stargazers_count":74,"open_issues_count":2,"forks_count":10,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-22T21:07:00.533Z","etag":null,"topics":["chinese-ocr","ocr","ocr-python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shibing624.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-18T04:16:33.000Z","updated_at":"2025-04-19T13:04:33.000Z","dependencies_parsed_at":"2024-12-18T05:35:45.960Z","dependency_job_id":null,"html_url":"https://github.com/shibing624/imgocr","commit_stats":null,"previous_names":["shibing624/imgocr"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shibing624%2Fimgocr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shibing624%2Fimgocr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shibing624%2Fimgocr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shibing624%2Fimgocr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shibing624","download_url":"https://codeload.github.com/shibing624/imgocr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250324687,"owners_count":21411946,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chinese-ocr","ocr","ocr-python"],"created_at":"2025-04-22T21:07:06.875Z","updated_at":"2026-04-11T17:21:05.969Z","avatar_url":"https://github.com/shibing624.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[**🇨🇳中文**](https://github.com/shibing624/imgocr/blob/main/README.md) | [**🌐English**](https://github.com/shibing624/imgocr/blob/main/README_EN.md) | [**📖文档/Docs**](https://github.com/shibing624/imgocr/wiki) \n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/shibing624/imgocr\"\u003e\n    \u003cimg src=\"https://github.com/shibing624/imgocr/blob/main/docs/imgocr-logo.png\" height=\"150\" alt=\"Logo\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n-----------------\n\n# imgocr: Image OCR toolkit\n[![PyPI version](https://badge.fury.io/py/imgocr.svg)](https://badge.fury.io/py/imgocr)\n[![Downloads](https://static.pepy.tech/badge/imgocr)](https://pepy.tech/project/imgocr)\n[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)](CONTRIBUTING.md)\n[![License Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)\n[![python_version](https://img.shields.io/badge/Python-3.6%2B-green.svg)](requirements.txt)\n[![GitHub issues](https://img.shields.io/github/issues/shibing624/imgocr.svg)](https://github.com/shibing624/imgocr/issues)\n[![Wechat Group](https://img.shields.io/badge/wechat-group-green.svg?logo=wechat)](#Contact)\n\n\n**imgocr**：Python3 package for Chinese/English OCR, with paddleocr-v4/paddleocr-v5 onnx model(~20MB).\n\n**imgocr**：基于PaddleOCR-v5-onnx模型（~20MB）推理，性能更高，可实现 CPU 上毫秒级的 OCR 精准预测，在通用场景上达到开源SOTA。\n\n\n## Showcase\n\n\n| 银行存根 | ![银行存根](https://github.com/shibing624/imgocr/blob/main/examples/ocr_results/00111002.jpg)     |\n|------|-----------------------------------------------------------------------------------------------|\n| 表格   | ![表格](https://github.com/shibing624/imgocr/blob/main/examples/ocr_results/00015504.jpg)       |\n| 火车票  | ![火车票](https://github.com/shibing624/imgocr/blob/main/examples/ocr_results/00056221.jpg)      |\n| 英文论文 | ![英文论文](https://github.com/shibing624/imgocr/blob/main/examples/ocr_results/eng_paper.png)    |\n| 手写中文 | ![手写中文](https://github.com/shibing624/imgocr/blob/main/examples/ocr_results/handwrite_zh.jpg) |\n| 手写英文 | ![手写中文](https://github.com/shibing624/imgocr/blob/main/examples/ocr_results/handwrite_en.jpg) |\n\n\n## Benchmark\n\nPP-OCRv4串联系统由文本检测模型和文本识别模型串联完成，首先输入预测图片，经过文本检测模型获取全部的检测框。根据检测框坐标在原图中抠出文本行，并进行矫正，最后将全部文本行送入文本识别模型，得到文本结果。\n\n整个流程如下图所示：\n\n\u003cimg src=\"https://github.com/shibing624/imgocr/blob/main/docs/ppocrv4_framework.png\" width=\"800\" alt=\"ppocr-v4\"\u003e\n\nOCR 检测/识别 benchmark：\n\n| 模型                   | 检测 mAP(%) | 识别 Acc(%) | GPU 推理耗时(ms) | CPU 推理耗时(ms) | 模型存储大小(MB) | 下载地址                                                                   |\n|----------------------|-----------|-----------|--------------|--------------|------------|------------------------------------------------------------------------|\n| PP-OCRv4-mobile   | 63.8      | 78.74     | 2.71         | 79.11        | 14         | [v4-mobile-model](https://modelscope.cn/models/lili666/imgocr/summary) |\n| PP-OCRv4-server\t | 69.2\t     | 85.19\t    | 24.92\t       | 2742.31\t     | 207        | [v4-server-model](https://modelscope.cn/models/lili666/imgocr/summary) |\n| PP-OCRv5-mobile(默认)\t | 79.0\t     | 81.29\t    | 6.36\t        | 82.11\t       | 20         | [v5-mobile-model](https://modelscope.cn/models/lili666/imgocr/summary) |\n| PP-OCRv5-server\t | 83.8\t     | 86.38\t    | 28.15\t       | 2900.12\t     | 160        | [v5-server-model](https://modelscope.cn/models/lili666/imgocr/summary) |\n\n\n\u003e GPU 推理耗时基于 NVIDIA Tesla T4 机器，精度类型为 FP32，CPU 推理速度基于 Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz，精度类型为 FP32。\n\n\u003e OCR 评估集是 PaddleOCR 自建的中文数据集，覆盖街景、网图、文档、手写多个场景，其中文本识别包含1.1w张图片，检测包含500张图片。\n\n\n\n## Demo\n\nHuggingFace Demo: https://huggingface.co/spaces/shibing624/imgocr\n\n![](https://github.com/shibing624/imgocr/blob/main/docs/imgocr_hf.png)\n\nrun example: [examples/gradio_demo.py](https://github.com/shibing624/imgocr/blob/main/examples/gradio_demo.py) to see the demo:\n```shell\npython examples/gradio_demo.py\n```\n\n## Install\n\n无需安装paddlepaddle、paddleocr等深度学习库，仅需安装onnxruntime，即可用imgocr调用。\n\n```shell\npip install onnxruntime # pip install onnxruntime-gpu for gpu\npip install imgocr\n```\n\nor\n\n```shell\ngit clone https://github.com/shibing624/imgocr.git\ncd imgocr\npip install onnxruntime # pip install onnxruntime-gpu for gpu\npip install -r requirements.txt\npip install .\n```\n\n## Usage\n\n### OCR识别\n\nexample: [examples/ocr_demo.py](https://github.com/shibing624/imgocr/blob/main/examples/ocr_demo.py)\n\n```python\nfrom imgocr import ImgOcr\nm = ImgOcr(use_gpu=False, is_efficiency_mode=True)\nresult = m.ocr(\"data/11.jpg\")\nprint(\"result:\", result)\nfor i in result:\n    print(i['text'])\n```\n\n\u003e `is_efficiency_mode`: 是否使用高效率模型，默认`True`，使用高效率模型(v5-mobile，20MB)，速度更快，精度稍低，该模型已经内置集成在`imgocr/models`文件夹下。如果需要更高精度，设置为False，使用高精度模型(v5-server，160MB)，代码会自动下载到`imgocr/models`文件夹。\n\noutput:\n```shell\nresult: [{'box': [[28.0, 37.0], [302.0, 39.0], [302.0, 72.0], [27.0, 70.0]], 'text': '纯臻营养护发素', 'score': 0.9978395700454712}, {'box': [[26.0, 83.0], [173.0, 83.0], [173.0, 104.0], [26.0, 104.0]], 'text': '产品信息/参数', 'score': 0.9898329377174377}, {'box': [[27.0, 112.0], [331.0, 112.0], [331.0, 135.0], [27.0, 135.0]], 'text': '（45元/每公斤，100公斤起订）', 'score': 0.9659210443496704}, {'box': [[25.0, 143.0], [281.0, 143.0], [281.0, 165.0], [25.0, 165.0]], 'text': '每瓶22元，1000瓶起订）', 'score': 0.9928666353225708}, {'box': [[26.0, 179.0], [300.0, 179.0], [300.0, 195.0], [26.0, 195.0]], 'text': '【品牌】：代加工方式/OEMODM', 'score': 0.9843945503234863}, {'box': [[26.0, 210.0], [234.0, 210.0], [234.0, 227.0], [26.0, 227.0]], 'text': '【品名】：纯臻营养护发素', 'score': 0.9963161945343018}, {'box': [[25.0, 239.0], [241.0, 239.0], [241.0, 259.0], [25.0, 259.0]], 'text': '【产品编号】：YM-X-3011', 'score': 0.9848018884658813}, {'box': [[413.0, 232.0], [430.0, 232.0], [430.0, 306.0], [413.0, 306.0]], 'text': 'ODMOEM', 'score': 0.9908049702644348}, {'box': [[24.0, 271.0], [180.0, 271.0], [180.0, 290.0], [24.0, 290.0]], 'text': '【净含量】：220ml', 'score': 0.9892324209213257}, {'box': [[26.0, 303.0], [251.0, 303.0], [251.0, 319.0], [26.0, 319.0]], 'text': '【适用人群】：适合所有肤质', 'score': 0.9909228682518005}, {'box': [[26.0, 335.0], [344.0, 335.0], [344.0, 352.0], [26.0, 352.0]], 'text': '【主要成分】：鲸蜡硬脂醇、燕麦β-葡聚', 'score': 0.9828647971153259}, {'box': [[26.0, 364.0], [281.0, 364.0], [281.0, 384.0], [26.0, 384.0]], 'text': '糖、椰油酰胺丙基甜菜碱、泛醌', 'score': 0.9505177140235901}, {'box': [[368.0, 368.0], [477.0, 368.0], [477.0, 389.0], [368.0, 389.0]], 'text': '（成品包材）', 'score': 0.992072343826294}, {'box': [[26.0, 397.0], [360.0, 397.0], [360.0, 414.0], [26.0, 414.0]], 'text': '【主要功能】：可紧致头发磷层，从而达到', 'score': 0.9904329180717468}, {'box': [[28.0, 429.0], [370.0, 429.0], [370.0, 445.0], [28.0, 445.0]], 'text': '即时持久改善头发光泽的效果，给干燥的头', 'score': 0.9874186515808105}, {'box': [[27.0, 458.0], [137.0, 458.0], [137.0, 479.0], [27.0, 479.0]], 'text': '发足够的滋养', 'score': 0.9987384676933289}]\n纯臻营养护发素\n产品信息/参数\n（45元/每公斤，100公斤起订）\n每瓶22元，1000瓶起订）\n【品牌】：代加工方式/OEMODM\n【品名】：纯臻营养护发素\n【产品编号】：YM-X-3011\nODMOEM\n【净含量】：220ml\n【适用人群】：适合所有肤质\n【主要成分】：鲸蜡硬脂醇、燕麦β-葡聚\n糖、椰油酰胺丙基甜菜碱、泛醌\n（成品包材）\n【主要功能】：可紧致头发磷层，从而达到\n即时持久改善头发光泽的效果，给干燥的头\n发足够的滋养\n```\n![](https://github.com/shibing624/imgocr/blob/main/examples/ocr_results/11.jpg)\n\n### 命令行模式（CLI）\n\n支持批量做OCR识别\n\ncode: [cli.py](https://github.com/shibing624/imgocr/blob/main/imgocr/cli.py)\n\n```\n\u003e imgocr -h                                    \nusage: cli.py [-h] --image_dir IMAGE_DIR [--output_dir OUTPUT_DIR]\n              [--chunk_size CHUNK_SIZE] [--use_gpu USE_GPU]\n\nimgocr cli\n\noptions:\n  -h, --help            show this help message and exit\n  --image_dir IMAGE_DIR\n                        input image dir path, required\n  --output_dir OUTPUT_DIR\n                        output ocr result dir path, default outputs\n  --chunk_size CHUNK_SIZE\n                        chunk size, default 10\n  --use_gpu USE_GPU     use gpu, default False\n```\n\nrun：\n\n```shell\npip install imgocr -U\nimgocr --image_dir data\n```\n\n\u003e 输入图片目录（--image_dir， required）\n\n## Contact\n\n- Issue(建议)：[![GitHub issues](https://img.shields.io/github/issues/shibing624/imgocr.svg)](https://github.com/shibing624/imgocr/issues)\n- 邮件我：xuming: xuming624@qq.com\n- 微信我：加我*微信号：xuming624, 备注：姓名-公司-NLP* 进NLP交流群。\n\n\u003cimg src=\"https://github.com/shibing624/imgocr/blob/main/docs/wechat.jpeg\" width=\"200\" /\u003e\n\n\n## Citation\n\n如果你在研究中使用了imgocr，请按如下格式引用：\n\nAPA:\n```latex\nXu, M. imgocr: Image OCR toolkit (Version 0.0.1) [Computer software]. https://github.com/shibing624/imgocr\n```\n\nBibTeX:\n```latex\n@misc{imgocr,\n  author = {Ming Xu},\n  title = {imgocr: Image OCR toolkit},\n  year = {2024},\n  publisher = {GitHub},\n  journal = {GitHub repository},\n  howpublished = {\\url{https://github.com/shibing624/imgocr}},\n}\n```\n\n## License\n\n\n授权协议为 [The Apache License 2.0](LICENSE)，可免费用做商业用途。请在产品说明中附加imgocr的链接和授权协议。\n\n\n## Contribute\n项目代码还很粗糙，如果大家对代码有所改进，欢迎提交回本项目，在提交之前，注意以下两点：\n\n - 在`tests`添加相应的单元测试\n - 使用`python -m pytest -v`来运行所有单元测试，确保所有单测都是通过的\n\n之后即可提交PR。\n\n## References\n- [RapidOCR](https://github.com/RapidAI/RapidOCR)  \n- [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)  \n- [Paddle2ONNX](https://github.com/PaddlePaddle/Paddle2ONNX)\n- [ppocr-onnx](https://github.com/triwinds/ppocr-onnx)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshibing624%2Fimgocr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshibing624%2Fimgocr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshibing624%2Fimgocr/lists"}