diff --git a/README.md b/README.md index bd149bc..bcc8a3a 100755 --- a/README.md +++ b/README.md @@ -69,8 +69,8 @@ - [Wiki](https://github.com/RapidAI/RapidOCR/wiki) - [ONNXRuntime推理调优指南](https://github.com/RapidAI/RapidOCR/wiki/ONNXRuntime%E6%8E%A8%E7%90%86%E8%B0%83%E4%BC%98%E6%8C%87%E5%8D%97) - [RapidOCR调优尝试教程](https://github.com/RapidAI/RapidOCR/wiki/RapidOCR%E8%B0%83%E4%BC%98%E5%B0%9D%E8%AF%95%E6%95%99%E7%A8%8B) + - [config.yaml参数详解](https://github.com/RapidAI/RapidOCR/wiki/config_parameter) - [Python范例](https://github.com/RapidAI/RapidOCR/blob/main/python/README.md) - - [rapidocr_openvino](https://github.com/RapidAI/RapidOCR/blob/main/python/rapidocr_openvino/README.md) - [C++范例(Windows/Linux/macOS)](https://github.com/RapidAI/RapidOCR/blob/main/cpp) - [RapidOcrOnnx](https://github.com/RapidAI/RapidOcrOnnx) - [RapidOcrNcnn](https://github.com/RapidAI/RapidOcrNcnn) @@ -95,15 +95,14 @@ - [LGPMA_Infer](https://github.com/SWHL/LGPMA_Infer): 表格结构还原 | [博客解读论文和源码](http://t.csdn.cn/QNN3S) - [文档图像矫正-PaperEdge](https://github.com/cvlab-stonybrook/PaperEdge) | [Demo](https://huggingface.co/spaces/SWHL/PaperEdgeDemo) - [图像文字擦除-CTRNet](https://github.com/lcy0604/CTRNet) | [Demo](https://huggingface.co/spaces/SWHL/CTRNetDemo) -- [模型相关](https://github.com/RapidAI/RapidOCR/blob/main/docs/models.md) - - [模型转换](https://github.com/RapidAI/RapidOCR/blob/main/docs/models.md#模型转换) - - [模型下载及效果对比](https://github.com/RapidAI/RapidOCR/blob/main/docs/models.md#模型下载) -- [常见问题 FAQ](https://github.com/RapidAI/RapidOCR/blob/main/docs/FAQ.md) +- [模型相关](https://github.com/RapidAI/RapidOCR/wiki/%E6%A8%A1%E5%9E%8B%E7%9B%B8%E5%85%B3) +- [常见问题 FAQ](https://github.com/RapidAI/RapidOCR/wiki/FAQ) -## 近期更新([more](https://github.com/RapidAI/RapidOCR/blob/main/docs/change_log.md)) +## 近期更新([more](https://github.com/RapidAI/RapidOCR/wiki/%E6%9B%B4%E6%96%B0%E6%97%A5%E5%BF%97)) #### ❤2023-05-20 ocrweb update: - 增加桌面版RapidOCRWeb,详情可参见[RapidOCRWeb桌面版使用教程](https://github.com/RapidAI/RapidOCR/wiki/%5BRapidOCRWeb%5D-%E6%A1%8C%E9%9D%A2%E7%89%88%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B) +- 对仓库文档做了整理,大部分文档放到了[Wiki](https://github.com/RapidAI/RapidOCR/wiki) #### 🌹2023-05-14 ocrweb v0.1.5 update: - 增加界面版返回坐标框的返回值([issue #85](https://github.com/RapidAI/RapidOCR/issues/85)) - API模式增加base64格式传入 diff --git a/docs/FAQ.md b/docs/FAQ.md deleted file mode 100644 index 711df68..0000000 --- a/docs/FAQ.md +++ /dev/null @@ -1,51 +0,0 @@ -## 常见问题 -#### Q: 请问这个能在32位C#中用嘛? -**A:** C#可以32位,要用32位的dll,但nuget上的onnxruntime不支持win7。 - -#### Q: Windows系统下,装完环境之后,运行示例程序之后,报错OSError: [WinError 126] 找不到指定的模組 -**A:** 原因是Shapely库没有正确安装,如果是在Windows,可以在[Shapely whl](https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely)下载对应的whl包,离线安装即可;另外一种解决办法是用conda安装也可。 - -#### Q: Linux部署python的程序时,`import cv2`时会报`ImportError: ligGL.so.1: cannot open shared object file: No such file or directory`? -**A:** [解决方法](https://stackoverflow.com/a/63978454/3335415 -) 有两个(来自群友ddeef): - 1. 安装`opencv-python-headless`取代`opencv-python`; - 2. 运行`sudo apt-get install -y libgl1-mesa-dev` - -#### Q: 询问下,我编译出来的进程在win7下面通过cmd调用,发生了崩溃的情况? -**A:** 不支持win7 (by @如果我有時光機) - -#### Q: 能不能搞个openmmlab类似的那个提取信息的? -**A:** 这个目前正在调研测试当中,如果mmocr中关键信息提取效果还可以,后期会考虑整合进来。 - -#### Q: RapidOCR和PaddleOCR是什么关系呢? -**A:** RapidOCR是将PaddleOCR的预训练模型转为onnx模型,不依赖paddle框架,方便各个平台部署。 - -#### Q: onnxruntime arm32 有人编译过吗? 我编译成功了,但是使用的时候libonnxruntime.so:-1: error: file not recognized: File format not recognized 应该是版本不匹配 -**A:** 没遇到过。我是直接在当前平台编译的,我们用的是arm。估计是平台不兼容,建议在本身平台上编译。没遇到过问题。通常出在交叉编译方式下。 - -#### Q: 请问一下c++ demo必须要vs2017及以上版本吗? -**A:** 最好用vs2019 - -#### Q: 可以达到百度EasyEdge Free App的效果吗? -**A:** edge的模型应该没有开源。百度开源的模型里server det的识别效果可以达到,但是模型比较大。 - -#### Q: 我用c++推理onnx貌似是cpu推理的,gpu没有反应? -**A:** 如果想用GPU的话,需要安装onnxruntime-gpu版,自己在onnxruntime的代码中添加EP (execution provider)。我们的定位是通用,只用cpu推理。 - -#### Q: 您好,我想部署下咱们的ocr识别,有提供linux版本的ocr部署包吗? -**A:** linux版本的自己编译即可, 可以参考我们的action中的脚本;其实编译非常容易,安装个opencv后,在cmakelists.txt中修改一下onnxruntime的路径即可,具体参考这个: https://github.com/RapidOCR/RapidOCR/blob/main/.github/workflows/make-linux.yml - -#### Q: onnxruntime编译好的C++库,哪里可以下载到? -**A:** 从这里:https://github.com/RapidOCR/OnnxruntimeBuilder/releases/tag/1.7.0 - -#### Q: 目前简单测试环境是 Win10 + Cygwin + gcc + 纯C编程,可以在C程序中直接接入简单OCR功能吗? -**A:** 直接使用API就行,API就是由c导出的 - -#### Q: 模型下载地址 -**A:** [百度网盘](https://pan.baidu.com/s/1PTcgXG2zEgQU6A_A3kGJ3Q?pwd=jhai) | [Google Drive](https://drive.google.com/drive/folders/1x_a9KpCo_1blxH1xFOfgKVkw1HYRVywY?usp=sharing) - -#### Q: onnxruntime 1.7 下出错:onnxruntime::SequentialExecutor::Execute] Non-zero status code returned while running ScatterND node. Name:'ScatterND@1' Status Message: updates -**A:** 由于模型只支持`onnxruntime=1.5.0`导致,请更新模型,下载地址见`Q3` - -#### Q: 边缘总有一行文字无法识别,怎么办? -**A:** 在 padding 参数中添加一个值 ,默认是0,你可以添加5或10, 甚至更大,直到能识别为止。注意不要添加过大,会浪费内存。 \ No newline at end of file diff --git a/docs/README_en.md b/docs/README_en.md index c2e236a..3d3d8f7 100644 --- a/docs/README_en.md +++ b/docs/README_en.md @@ -61,8 +61,8 @@ - [Wiki](https://github.com/RapidAI/RapidOCR/wiki) - [ONNXRuntime inference optim](https://github.com/RapidAI/RapidOCR/wiki/ONNXRuntime%E6%8E%A8%E7%90%86%E8%B0%83%E4%BC%98%E6%8C%87%E5%8D%97) - [RapidOCR Optim](https://github.com/RapidAI/RapidOCR/wiki/RapidOCR%E8%B0%83%E4%BC%98%E5%B0%9D%E8%AF%95%E6%95%99%E7%A8%8B) + - [config.yaml parameter](https://github.com/RapidAI/RapidOCR/wiki/config_parameter) - [Python demo](https://github.com/RapidAI/RapidOCR/blob/main/python/README.md) - - [rapidocr_openvino](https://github.com/RapidAI/RapidOCR/blob/main/python/rapidocr_openvino/README.md) - [C++ demo(Windows/Linux/macOS)](https://github.com/RapidAI/RapidOCR/blob/main/cpp) - [RapidOcrOnnx](https://github.com/RapidAI/RapidOcrOnnx) - [RapidOcrNcnn](https://github.com/RapidAI/RapidOcrNcnn) @@ -96,7 +96,7 @@ - [Model Download](https://github.com/RapidAI/RapidOCR/blob/main/docs/models.md#模型下载) - [FAQ](https://github.com/RapidAI/RapidOCR/blob/main/docs/FAQ.md) -## Recently updates([more](https://github.com/RapidAI/RapidOCR/blob/main/docs/change_log_en.md)) +## Recently updates([more](https://github.com/RapidAI/RapidOCR/wiki/Changelog)) #### ❤2023-05-20 ocrweb update: - Add desktop version of RapidOCRWeb, for details, please refer to [RapidOCRWeb desktop version tutorial](https://github.com/RapidAI/RapidOCR/wiki/%5BRapidOCRWeb%5D-%E6%A1%8C%E9%9D%A2%E7%89%88%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B) #### 🌹 2023-05-14 ocrweb v0.1.5 update: diff --git a/docs/change_log.md b/docs/change_log.md deleted file mode 100644 index 87cb1fd..0000000 --- a/docs/change_log.md +++ /dev/null @@ -1,152 +0,0 @@ -#### ❤2023-05-20 ocrweb update: -- 增加桌面版RapidOCRWeb,详情可参见[RapidOCRWeb桌面版使用教程](https://github.com/RapidAI/RapidOCR/wiki/%5BRapidOCRWeb%5D-%E6%A1%8C%E9%9D%A2%E7%89%88%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B) - -#### 🌹2023-05-14 ocrweb v0.1.5 update: -- 增加界面版返回坐标框的返回值([issue #85](https://github.com/RapidAI/RapidOCR/issues/85)) -- API模式增加base64格式传入 -- 详情参见:[link](https://github.com/RapidAI/RapidOCR/blob/main/ocrweb/README.md) - -#### 🏸2023-04-16 ocrweb v0.1.1 update: -- API部署改为FastAPI库支持 -- 将API模式与Web解耦合,可通过`pip install rapidocr_web[api]`来选择性安装 -- 详情参见:[link](https://github.com/RapidAI/RapidOCR/blob/main/ocrweb/README.md) - -#### 🎮2023-03-11 v1.2.2 update: -- 修复实例化python中RapidOCR类传入参数错误 - -#### 🧢2023-03-07 v1.2.1 update: -- `rapidocr`系列包更新到`v1.2.0` -- 优化python下rapidocr系列包的接口传入参数,支持实例化类时,动态给定各个参数,更加灵活。 -- 如果不指定,则用`config.yaml`下的默认参数。 -- 具体可参见:[传入参数](https://github.com/RapidAI/RapidOCR/blob/0a603b4e8919386f3647eca5cdeba7620b4988e0/python/README.md#%E6%8E%A8%E8%8D%90pip%E5%AE%89%E8%A3%85%E5%BF%AB%E9%80%9F%E4%BD%BF%E7%94%A8) - -#### ⛸2023-02-16 update: -- 优化ocrweb部分代码,可直接pip安装,快速使用,详情参见[README](../ocrweb/README.md)。 -- 优化python中各个部分的推理代码,更加紧凑,同时易于维护。 - -#### 🎉2023-01-21 update: -- \[python\] 添加含有文字的图像方向分类模块,具体参见[Rapid Orientation](../python/rapid_structure/docs/README_Orientation.md) - -#### ⚽2022-12-19 update: -- \[python\] 添加表格结构还原模块,具体参见[Rapid Table](../python/rapid_structure/docs/README_Table.md) - -#### 🤖2022-12-14 update: -- \[python\] 将配置参数和模型移到模块里面,同时将模型打到whl包内,可以直接pip安装使用,更加方便快捷。 -- 详情参见:[README](../python/README.md#推荐pip安装快速使用) - -#### 🧻2022-11-20 update: -- \[python\] 添加版面分析部分,支持中文、英文和表格三种版面的检测分析。详情参见:[Rapid Structure](../python/rapid_structure/README.md)部分。 - -#### 🎃2022-11-01 update: -- 添加Hugging Face Demo, 增加可以调节超参数的功能,详情可访问[Hugging Face Demo](https://huggingface.co/spaces/SWHL/RapidOCRDemo) - -#### 🚩2022-10-01 udpate: -- 修复python部分下一些较小bugs -- merge来自[AutumnSun1996](https://github.com/AutumnSun1996)的[OCRWeb实现的多语言部署](https://github.com/RapidAI/RapidOCR/pull/46)demo,详情参见:[ocrweb_mutli-README](../ocrweb_multi/README.md) -- 添加onnxruntime-gpu推理速度较慢于CPU的问题说明,详情参见:[onnxruntime-gpu版相关说明](../python/README.md#onnxruntime-gpu版相关说明) - -#### 🛴2022-09-01 update: -- 由于openvino发布了2022.2.0.dev20220829版本,该版本解决了`cls`部分模型推理的问题。至此,基于openvino的rapidocr完成了统一,全部由openvino推理引擎完成。 -- 详细使用方法参见:[python/README](../python/README.md#源码使用步骤) - -#### 🧸2022-08-17 update: -- python/ocrweb部分 v1.1.0发布,详情参见[v1.1.0](https://github.com/RapidAI/RapidOCR/releases/tag/v1.1.0) - -#### 🕶2022-08-14 update: -- ocrweb部分增加以API方式部署调用的功能,可以通过发送POST请求,来获得OCR识别结果。 -- 详情参见:[API方式调用](../ocrweb/README.md#以api方式运行和调用) - -#### ✨2022-07-07 update: -- 修复python版中v3 rec推理bug,并将v3 rec与v2 rec合并为同一套推理代码,更加简洁和方便 -- 添加python模块下的单元测试 -- 该页面添加[致谢模块](../README.md#致谢),感谢为这个项目作出贡献的小伙伴。 - -#### 😁2022-07-05 update: -- 添加对单行文本的处理能力,对于单行文本,可自行设定阈值,不过检测模块,直接识别即可。详情参见[README](./python/README.md#configyamlconfigyaml中常用参数介绍) -- 优化python部分代码逻辑,更优雅简洁。 - -#### 🏝2022-06-30 update: -- python推理部分,增加参数选择使用GPU推理的配置选项,在正确安装`onnxruntime-gpu`版本前提下,可以一键使用(Fix [issue#30](https://github.com/RapidAI/RapidOCR/issues/30)) -- 具体基于GPU的推理情况,需要等我后续整理一下,再更新出来 -- 详情参见:[onnxruntime-gpu版推理配置](./python/README.md#onnxruntime-gpu版推理配置) - -#### 📌2022-06-25 update: -- 重新整理python部分推理代码,将常用调节参数全部放到yaml文件中,便于调节,更加容易使用 -- 详情参见:[README](./python/README.md) - -#### 🍿2022-05-15 udpate: -- 增加PaddleOCR v3 rec模型转换后的ONNX模型,直接去网盘下载替换即可。([百度网盘](https://pan.baidu.com/s/1mkirNltJS481In4g81jP3w?pwd=zy37) | [Google Drive](https://drive.google.com/drive/folders/1x_a9KpCo_1blxH1xFOfgKVkw1HYRVywY?usp=sharing)) -- 增加文本识别模型各个版本效果对比表格,详情点击[各个版本ONNX模型效果对比](#各个版本onnx模型效果对比)。v3的文本识别模型从自己构建测试集上的指标来看不如之前的好。 - -#### 😀2022-05-12 upadte -- 增加PaddleOCR v3 det模型转换的ONNX模型,直接去网盘下载,替换即可。([百度网盘](https://pan.baidu.com/s/1mkirNltJS481In4g81jP3w?pwd=zy37) | [Google Drive](https://drive.google.com/drive/folders/1x_a9KpCo_1blxH1xFOfgKVkw1HYRVywY?usp=sharing)) -- 增加各个版本文本检测模型效果对比表格,详情点击[各个版本ONNX模型效果对比](#各个版本onnx模型效果对比)。v3的文本检测模型从指标来看是好于之前的v2的,推荐使用。 - -#### 🎧2022-04-04 udpate: -- 增加python下的基于OpenVINO推理引擎的支持 -- 给出OpenVINO和ONNXRuntime的性能对比表格 -- 详情参见:[python/README](./python/README.md) - -#### 2022-02-24 udpate: -- 优化python目录下的推理代码 -- 添加调用不同语言模型的推理代码示例 -- 详情参见:[python/onnxruntime_infer/README](./python/onnxruntime_infer/README.md) - -#### 2021-12-18 udpate: -- 添加[Google Colab Demo](https://colab.research.google.com/github/RapidAI/RapidOCR/blob/main/RapidOCRDemo.ipynb) - -#### 2021-11-28 udpate: -- 更新[ocrweb](http://rapidocr.51pda.cn:9003/)部分 - - 添加显示各个阶段处理时间 - - 更新说明文档 - - 更换文本检测模型为`ch_PP-OCRv2_det_infer.onnx`,推理更快,更准 - -#### 2021-11-13 udpate: -- 添加python版本中文本检测和识别可调节的超参数,主要有`box_thresh|unclip_ratio|text_score`,详情见[参数调节](python/README.md#相关调节参数) -- 将文本识别中字典位置以参数方式给出,便于灵活配置,详情见[keys_path](python/rapidOCR.sh) - -#### 2021-10-27 udpate: -- 添加使用onnxruntime-gpu版推理的代码(不过gpu版本的onnxruntime不太好用,按照[官方教程](https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html)配置,感觉没有调用起来GPU) -- 具体使用步骤参见: [onnxruntime-gpu推理配置](python/README.md) - -#### 2021-09-13 udpate: -- 添加基于`python`的whl文件,便于使用,详情参见`release/python_sdk` - -#### 2021-09-11 udpate: -- 添加PP-OCRv2新增模型onnx版本 - - 使用方法推理代码不变,直接替换对应模型即可。 -- 经过在自有测试集上评测: - - PP-OCRv2检测模型效果有大幅度提升,模型大小没变。 - - PP-OCRv2识别模型效果无明显提升,模型大小增加了3.58M。 -- 模型上传到[百度网盘 提取码:30jv](https://pan.baidu.com/s/1qkqWK4wRdMjqGGbzR-FyWg) - -#### 2021-08-07 udpate: -- [x] PP-Structure 表格结构和cell坐标预测 正在整理中 -- 之前做的,未完成的,欢迎提PR - - [ ] 打Dokcer镜像 - - [x] 尝试onnxruntime-gpu推理 - -#### 2021-07-17 udpate: -- 完善README文档 -- 增加**英文、数字识别**onnx模型,具体参见`python/en_number_ppocr_mobile_v2_rec`,用法同其他 -- 整理一下[模型转onnx](#模型转onnx) - -#### 2021-07-04 udpate: -- 目前仓库下的python程序已经可以在树莓派4B上,成功运行,详细信息请进群,询问群主 -- 更新整体结构图,添加树莓派的支持 - -#### 2021-06-20 udpate: -- 优化ocrweb中识别结果显示,同时添加识别动图演示 -- 更新`datasets`目录,添加一些常用数据库链接(搬运一下^-^) -- 更新[FAQ](./FAQ.md) - -#### 2021-06-10 udpate: -- 添加server版文本识别模型,详情见[提取码:30jv](https://pan.baidu.com/s/1qkqWK4wRdMjqGGbzR-FyWg) - -#### 2021-06-08 udpate: -- 整理仓库,统一模型下载路径 -- 完善相关说明文档 - -#### 2021-03-24 udpate: -- 新模型已经完全兼容ONNXRuntime 1.7 或更高版本。 特别感谢:@Channingss -- 新版onnxruntime比1.6.0 性能提升40%以上。 diff --git a/docs/change_log_en.md b/docs/change_log_en.md deleted file mode 100644 index 5ecc58a..0000000 --- a/docs/change_log_en.md +++ /dev/null @@ -1,155 +0,0 @@ -#### ❤2023-05-20 ocrweb update: -- Add desktop version of RapidOCRWeb, for details, please refer to [RapidOCRWeb desktop version tutorial](https://github.com/RapidAI/RapidOCR/wiki/%5BRapidOCRWeb%5D-%E6%A1%8C%E9%9D%A2%E7%89%88%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B) - -#### 🌹 2023-05-14 ocrweb v0.1.5 update: -- Add the return value of the interface version's return coordinate box ([issue #85](https://github.com/RapidAI/RapidOCR/issues/85)) -- API mode adds base64 format input -- For details, please refer to: [link](https://github.com/RapidAI/RapidOCR/blob/main/ocrweb/README.md) - -#### 🏸2023-04-16 ocrweb v0.1.1 update: -- API deployment changed to FastAPI library support. -- Decouple the API mode from the Web, which can be installed selectively through `pip install rapidocr_web[api]`. -- See details for [link](https://github.com/RapidAI/RapidOCR/blob/main/ocrweb/README.md). - -#### 🎮2023-03-11 v1.2.2 update: -- Fix the incoming parameter error of RapidOCR class in instantiation python - -#### 🧢2023-03-07 v1.2.1 update: -- `rapidocr` series package updated to `v1.2.0` -- Optimize the interface input parameters of the rapidocr series package under python, and support the dynamic setting of each parameter when instantiating a class, which is more flexible. -- If not specified, the default parameters under `config.yaml` will be used. -- For details, please refer to: [Input parameters](https://github.com/RapidAI/RapidOCR/blob/0a603b4e8919386f3647eca5cdeba7620b4988e0/python/README.md#%E6%8E%A8%E8%8D%90pip%E5%AE%89%E8%A3%85%E5%BF%AB%E9%80%9F%E4%BD%BF%E7%94%A8) - -#### ⛸ 2023-02-16 update: -- Optimize some codes of ocrweb, which can be directly installed by pip and used quickly. For details, please refer to [README](../ocrweb/README.md). -- Optimize the inference code of each part in python, which is more compact and easy to maintain. - -#### 🎉 2023-01-21 update: -- \[python\] Add an image orientation classification module containing text. For details, see [Rapid Orientation](../python/rapid_structure/docs/README_Orientation.md) - -#### ⚽2022-12-19 update: -- \[python\] Add the table recovery module, See [Rapid Table](../python/rapid_structure/docs/README_Table.md) for details. - -#### 🤖2022-12-14 update: -- \[python\] Move the configuration parameters and model into the module, and at the same time put the model into the whl package, which can be directly installed and used by pip, which is more convenient and quicker. -- For details, see: [README](../python/README.md#推荐pip安装快速使用) - -#### 🧻2022-11-20 update: -- \[python\] Add the layout analysis part, which supports the detection and analysis of three layouts: Chinese, English and tables. See: [Rapid Structure](../python/rapid_structure/README.md) section for details. - -#### 🎃2022-11-01 update: -- Add Hugging Face Demo, add module that can adjust hyperameters, for details, please visit [Hugging Face Demo](https://huggingface.co/spaces/SWHL/RapidOCRDemo). - -#### 🚩2022-10-01 update: -- Fix some minor bugs under python section. -- Merge the [OCRWeb Implementation of Multilingual Deployment](https://github.com/RapidAI/RapidOCR/pull/46) demo from [AutumnSun1996](https://github.com/AutumnSun1996), see for details: [ocrweb_mutli-README](../ocrweb_multi/README.md) -- Add a description of the problem that onnxruntime-gpu inference speed is slower than CPU. For details, please refer to: [onnxruntime-gpu version related instructions](../python/README.md#onnxruntime-gpu版相关说明) - -#### 🛴2022-09-01 update: -- Since openvino released version 2022.2.0.dev20220829, this version solves the problem of `cls` partial model inference. So far, the openvino-based rapidocr has been unified, and it is all completed by the openvino inference engine. -- For detailed usage, see: [python/README](../python/README.md#源码使用步骤). - -#### 🧸2022-08-17 update: -- The python/ocrweb part v1.1.0 is released, see the [link]((https://github.com/RapidAI/RapidOCR/releases/tag/v1.1.0)) for details. - -#### 🕶2022-08-14 update: -- The ocrweb part adds the function of deploying calls by API, and you can send POST requests to get OCR recognition results. -- For details, see: [API deploy](../ocrweb/README.md#以api方式运行和调用) - -#### 🎧2022-07-10 update: -- Add test case for onnxruntime-gpu → [link](../python/README.md#onnxruntime-gpu version inference configuration) -- Add benchamark test set → [link](../images/README.md) -- Add actions to automatically publish whl packages, when modifying python/rapidocr_onnxruntime, it will automatically update the published whl packages. See [WHL README](../docs/doc_whl_en.md) - -#### ✨2022-07-07 update: -- Fix the bug of v3 rec inference in python version, and merge v3 rec and v2 rec into the same set of inference code, which is more concise and convenient. -- Add unit test under python module. -- Add [Acknowledgement module](../docs/README_en.md#Acknowledgement) to this page to thank the partners who contributed to this project. - -#### 😁2022-07-05 update: -- Add the ability to handle single line text, for single line text, you can set your own threshold, but the detection module, direct recognition can be. For details, see [README](../python/README.md#configyamlconfigyaml中常用参数介绍) -- Optimize some code logic of python, more elegant and concise. - -#### 🏝2022-06-30 update: -- In the python inference section, add a configuration option for whether to use GPU inference, which can be used with one click if the `onnxruntime-gpu` version is correctly installed (Fix [issue#30](https://github.com/RapidAI/RapidOCR/issues/30)) -- The specific GPU-based reasoning will need to wait for me to sort it out and update it later. -- For details, see: [onnxruntime-gpu version reasoning configuration](../python/README.md#onnxruntime-gpu version reasoning configuration) - -#### 📌2022-06-25 update: -- Reorganize some of the python inference code, put all the common adjustment parameters into the yaml file, easy to adjust, easier to use, see: [README](../python/README.md) -- The old inference code is located in the branch: [old_python_infer](https://github.com/RapidAI/RapidOCR/tree/old_python_infer) - -#### 🍿2022-05-15 udpate: -- Add the ONNX model converted from the PaddleOCR v3 rec model, just go to the network disk to download and replace it. ([Baidu Netdisk](https://pan.baidu.com/s/1mkirNltJS481In4g81jP3w?pwd=zy37) | [Google Drive](https://drive.google.com/drive/folders/1x_a9KpCo_1blxH1xFOfgKVkw1HYRVywY?usp=sharing )) -- Added a comparison table of the effects of each version of the text recognition model. For details, click [Comparison of the effects of various versions of ONNX models] (#Comparison of the effects of various versions of onnx models). The text recognition model of v3 is not as good as the previous one in terms of the indicators on the test set constructed by itself. - -#### 😀2022-05-12 udpate: -- Add the ONNX model converted from the PaddleOCR v3 det model, download it directly from the network disk, and replace it. ([Baidu Netdisk](https://pan.baidu.com/s/1mkirNltJS481In4g81jP3w?pwd=zy37) | [Google Drive](https://drive.google.com/drive/folders/1x_a9KpCo_1blxH1xFOfgKVkw1HYRVywY?usp=sharing )) -- Added a comparison table of text detection model effects of various versions. For details, click [Comparison of the effects of various versions of ONNX models] (#Comparison of the effects of various versions of onnx models). The text detection model of v3 is better than the previous v2 in terms of the indicators on the test set constructed by itself, and it is recommended to use it. - -#### 2022-02-24 udpate: -- Optimize the inference code of the python part. -- Add inference code examples that use the different language models. -- For details, see: [python/README](../python/README.md) - -#### 2021-12-18 udpate: -- Add [Google Colab Demo](https://colab.research.google.com/github/RapidAI/RapidOCR/blob/main/RapidOCRDemo.ipynb). -- Change the default det model of the `python/rapidOCR.sh` - -#### 2021-11-28 udpate: -- Update the [ocrweb](http://rapidocr.51pda.cn:9003/) part - - Add the display of the inference time of each stage. - - Add docs of the ocrweb. - - Change the det model(`ch_PP-OCRv2_det_infer.onnx`), faster and more accurate. - -#### 2021-11-13 udpate: -- Add adjustable super parameters for text detection and recognition in Python version, mainly `box_thresh|unclip_ratio|text_score`, see [parameter adjustment](../python/README.md#相关调节参数) for details -- The dictionary position in text recognition is given in parameter mode to facilitate flexible configuration. See [keys_path](python/rapidOCR.sh) for details - -#### 2021-10-27 udpate: -- Add the code that uses the onnxruntime GPU version of infering follow the [official tutorial](https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html) Configuration. (however, the onnxruntime GPU version is not stable to use) - -- See: `python/README.md` for specific steps. - -#### 2021-09-13 udpate: -- Add a whl file based on `Python` for ease of use. See `release/python` for details. - -#### 2021-09-11 udpate: -- Add `PP-OCRv2` new model onnx version. -- The infering code of the method is unchanged, and the corresponding model can be directly replaced. -- After evaluation on its own test set: - - The effect of `PP-OCRv2` detection model has been greatly improved, and the model size has not changed. - - The effect of `PP-OCRv2` recognition model was not significantly improved, and the model size increased by 3.58M. - -- Upload the model to [Baidu online disk extraction code: 30jv](https://pan.baidu.com/s/1qkqWK4wRdMjqGGbzR-FyWg) or [Google Drive](https://drive.google.com/drive/folders/1x_a9KpCo_1blxH1xFOfgKVkw1HYRVywY?usp=sharing) - -#### 2021-08-07 udpate: -- [x] PP structure table structure and cell coordinate prediction are being sorted out. - -- Previously done, unfinished, welcome to PR - - [ ] make dokcer image - - [x] try onnxruntime GPU reasoning - -#### 2021-07-17 udpate: -- Improve the README document -- Add **English, number recognition**onnx model, please refer to `python/en_number_ppocr_mobile_v2_rec` for details, the usage is the same as others -- Organize [Model to onnx](#model-related) - -#### 2021-07-04 udpate: -- The python program under the repository can be successfully run on the Raspberry Pi 4B. For more information, please enter the QQ group and ask the group owner -- Update the overall structure diagram and add support for Raspberry Pi - -#### 2021-06-20 udpate: -- Optimize the display of recognition results in ocrweb, and add recognition animations to demonstrate at the same time -- Update the `datasets` directory, add some commonly used database links - -#### 2021-06-10 udpate: -- Add server version text recognition model, see details [Extract code:30jv](https://pan.baidu.com/s/1qkqWK4wRdMjqGGbzR-FyWg) - -#### 2021-06-08 udpate: -- Organize the warehouse and unify the model download path -- Improve related documentation - -#### 2021-03-24 udpate: -- The new model is fully compatible with ONNXRuntime 1.7 or higher. Special thanks: @Channingss -- The performance of the new version of onnxruntime is improved by more than 40% compared to 1.6.0. \ No newline at end of file diff --git a/docs/models.md b/docs/models.md deleted file mode 100644 index d6bbd71..0000000 --- a/docs/models.md +++ /dev/null @@ -1,41 +0,0 @@ -## 模型相关 -- [模型相关](#模型相关) - - [模型转换](#模型转换) - - [模型下载](#模型下载) - - [各个版本ONNX模型效果对比](#各个版本onnx模型效果对比) - - [文本检测模型(仅供参考)](#文本检测模型仅供参考) - - [文本识别模型(仅供参考)](#文本识别模型仅供参考) - -### 模型转换 -- [PaddleOCRModelConverter](https://github.com/RapidAI/PaddleOCRModelConverter) -- [Paddle2OnnxConvertor](https://github.com/RapidAI/Paddle2OnnxConvertor) -- [手把手教你使用ONNXRunTime部署PP-OCR](https://aistudio.baidu.com/aistudio/projectdetail/1479970?channelType=0&channel=0) - -### 模型下载 -- 可以直接下载使用的模型 ([百度网盘](https://pan.baidu.com/s/1PTcgXG2zEgQU6A_A3kGJ3Q?pwd=jhai) | [Google Drive](https://drive.google.com/drive/folders/1x_a9KpCo_1blxH1xFOfgKVkw1HYRVywY?usp=sharing)) - -|模型名称|模型简介|模型大小|备注| -|:---:|:---:|:---:|:---:| -|⭐ ch_PP-OCRv3_det_infer.onnx|轻量文本检测模型|2.23M|较v1轻量检测,精度有较大提升 from [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.5/README_ch.md#pp-ocr%E7%B3%BB%E5%88%97%E6%A8%A1%E5%9E%8B%E5%88%97%E8%A1%A8%E6%9B%B4%E6%96%B0%E4%B8%AD)| -|⭐ ch_PP-OCRv2_rec_infer.onnx|轻量文本识别模型|7.79M|| - -### 各个版本ONNX模型效果对比 -#### 文本检测模型(仅供参考) -- 测试集:自己构建`中英文(111个,包含卡证、文档和自然图像)` - -| 模型 | infer_Speed(s/img) | precision | recall | hmean | 模型大小 | -| :---------------------------------: | :----------------: | :-------: | :----: | :----: | :------: | -| ch_ppocr_mobile_v2.0_det_infer.onnx | 0.4345742 | 0.7277 | 0.8413 | 0.7785 | 2.3M | -| ch_PP-OCRv2_det_infer.onnx | 0.5116553 | 0.7817 | 0.8472 | 0.8123 | 2.3M | -| ch_PP-OCRv3_det_infer.onnx | 0.5723512 | **0.7740** | **0.8837** | **0.8237** | 2.4M | - -#### 文本识别模型(仅供参考) -- 测试集: 自己构建`中英文(168个)` - -| 模型 | infer_Speed(s/img) | Score | Exact_Match | Char_Match | 模型大小 | -| :---------------------------------: | :------------------: | :-------: | :--------------: | :-------------: | :--: | -| ch_ppocr_mobile_v2.0_rec_infer.onnx | 0.0111 | **0.7287** | **0.5595** | 0.8979 | 4.3M | -| ch_PP-OCRv2_rec_infer.onnx | 0.0193 | 0.6955 | 0.4881 | **0.9029** | 8.0M | -| ch_PP-OCRv3_rec_infer.onnx | 0.0145 | 0.5537 | 0.3274 | 0.7800 | 11M | -| ch_PP-OCRv3_rec_train_student.onnx | 0.0157 | 0.5537 | 0.3274 | 0.7800 | 11M | -| ch_PP-OCRv3_rec_train_teacher.onnx | 0.0140 | 0.5381 | 0.3095 | 0.7667 | 11M | diff --git a/docs/related_projects.md b/docs/related_projects.md deleted file mode 100644 index c855b5a..0000000 --- a/docs/related_projects.md +++ /dev/null @@ -1,71 +0,0 @@ -
-目录 - -- [相关项目](#相关项目) - - [版面分析](#版面分析) - - [表格识别](#表格识别) - - [视频OCR](#视频ocr) - - [卡证OCR](#卡证ocr) - - [印章OCR](#印章ocr) - -
- -## 相关项目 -- 以下几个方向,每个都是比较独立的方向,但是却和OCR有着千丝万缕的关系,关于它们的资料就像散落在天空中的星星一般,散发着微弱的光芒,这里要做的就是将这些点点光芒聚集起来。 -- 这里将会汇总出以下几个OCR周边项目的一些文档和资源,包括学术动态和一些工程化代码。 -- 欢迎各位小伙伴提供PR。 - -### 版面分析 -- 相关论文和帖子: - - [版面分析方法汇总](https://zhuanlan.zhihu.com/p/392058153) -- 相关工程: - - [PaddleOCR Layout](https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.5/ppstructure/layout/README_ch.md) - - [海康DAVAR VSR](https://github.com/hikopensource/DAVAR-Lab-OCR/tree/main/demo/text_layout/VSR) -- 数据集汇总: - - 英文版面分析数据集: - - [PubLayNet](https://github.com/ibm-aur-nlp/PubLayNet): IBM构建,34万张图像,分为5类:text, title list table figure。 - - [DocBank](https://doc-analysis.github.io/docbank-page/index.html):微软亚洲研究院构建,50万英文文档图像,分为12类:摘要、作者、标题、公式、图形、页脚、列表、段落、参考、节标题、表格和文章标题。 - - - 中文版面分析数据集: - - [CDLA](https://github.com/buptlihang/CDLA):中文文档版面分析数据集,面向中文文献类(论文)场景,总共6000张(5000训练,1000测试),分为10类:正文、标题、图片、图片标题、表格、表格标题、页眉、页脚、注释和公式。 - -### 表格识别 -- 相关论文和帖子: - - [OCR之表格结构识别综述](https://blog.csdn.net/shiwanghualuo/article/details/123726879) - - [合合信息:表格识别与内容提炼技术理解及研发趋势](https://blog.csdn.net/INTSIG/article/details/123000010?spm=1001.2014.3001.5502) - - [论文阅读: (ICDAR2021 海康威视)LGPMA(表格识别算法)及官方源码对应解读](https://blog.csdn.net/shiwanghualuo/article/details/125047732?spm=1001.2014.3001.5501) -- 相关工程: - - [海康官方LGPMA源码](https://github.com/hikopensource/DAVAR-Lab-OCR/tree/main/demo/table_recognition/lgpma) - - [LGPMA Inference](https://github.com/SWHL/LGPMA_Infer) - - [PaddleOCR Table](https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.5/ppstructure/table/README_ch.md) -- 数据集汇总: - - 英文表格识别数据集: - - [PubTabNet](https://github.com/ibm-aur-nlp/PubTabNet): IBM构建,568k+文档图像数据,包括表格图像和对应的HTML标注。 - -### 视频OCR -- 相关论文和帖子: - - [【NeurIPS2021】A Bilingual, OpenWorld Video Text Dataset and End-to-end Video Text Spotter with Transformer](https://arxiv.org/abs/2112.04888) | [博客解读](https://blog.csdn.net/shiwanghualuo/article/details/122712872?spm=1001.2014.3001.5501) - - [【ACM MM 2019】You only recognize once: Towards fast video text spotting](https://arxiv.org/pdf/1903.03299) -- 相关工程: - - [video-subtitle-extractor](https://github.com/YaoFANGUK/video-subtitle-extractor): 一款将视频中的硬字幕提取为外挂字幕文件(srt格式)的软件 - - [RapidVideOCR](https://github.com/SWHL/RapidVideOCR): 提取视频中硬字幕 -- 数据集汇总: - - [BOVText: A Large-Scale, Bilingual Open World Dataset for Video Text Spotting](https://github.com/weijiawu/BOVText-Benchmark): 快手科技、浙江大学和北京邮电大学合作提出,大规模双语开放场景下的视频文本基准数据集,该数据集主要提供了2000+视频,1,750,000帧开放视频场景的视频。同时,还提供了丰富的标注类型(标题、字幕、场景文本等)。该数据集支持四个任务:视频帧检测、视频帧识别、视频文本跟踪和端到端视频文本识别。 - -### 卡证OCR -- 相关论文和帖子: -- 相关工程: - - [fake_certificate_generator](https://github.com/deep-practice/fake_certificate_generator): 假的证件合成器,包括身份证、驾驶证、营业执照。 -- 数据集汇总: - - 暂无,一般这类数据较为敏感,通常都合成假数据来使用。 - -### 印章OCR -- 相关论文和帖子: - - [【技术新趋势】合合信息:复杂环境下ocr与印章识别技术理解及研发趋势](https://blog.csdn.net/INTSIG/article/details/125203307) - - [基于文字分割的印章识别技术](https://hanspub.org/journal/PaperInformation.aspx?paperID=40945) -- 相关工程: - - [JS生成印章](https://github.com/niezhiliang/canvas-draw-seal) - - [Python绘制透明背景印章](https://www.bilibili.com/read/cv15847481/) - - [在线印章合成大全网站](http://www.395.net.cn/) -- 数据集汇总: - - 暂无 \ No newline at end of file diff --git a/python/README.md b/python/README.md index eef8b38..ef3cdbb 100755 --- a/python/README.md +++ b/python/README.md @@ -13,10 +13,6 @@ - [简介和说明](#简介和说明) - [(推荐)pip安装快速使用](#推荐pip安装快速使用) - [源码使用步骤](#源码使用步骤) - - [`config.yaml`中常用参数介绍](#configyaml中常用参数介绍) - - [onnxruntime-gpu版相关说明](#onnxruntime-gpu版相关说明) - - [onnxruntime-gpu版推理配置](#onnxruntime-gpu版推理配置) - - [OpenVINO GPU推理配置](#openvino-gpu推理配置) @@ -249,138 +245,3 @@ ```bash python demo.py ``` - -### [`config.yaml`](https://github.com/RapidAI/RapidOCR/blob/main/python/rapidocr_onnxruntime/config.yaml)中常用参数介绍 -- `Global`部分 - | 参数名称 | 取值范围 | 默认值 | 作用 | - |------------: | :----------: | :-----: | :----------------------------------------------| - | `text_score` | [0, 1] | 0.5 | 文本识别结果置信度,值越大,把握越大 | - | `use_angle_cls` | `bool` | `true` | 是否使用文本行的方向分类 | - | `print_verbose` | `bool` | `true` | 是否打印各个部分耗时信息 | - | `min_height` | `int` | 30 | 图像最小高度(单位是像素)
低于这个值,会跳过文本检测阶段,直接进行后续识别 | - |`width_height_ratio`| `int`| 8| 如果输入图像的宽高比大于`width_height_ratio`,则会跳过文本检测,直接进行后续识别
`width_height_ratio=-1`:不用这个参数 | - - - `min_height`是用来过滤只有一行文本的图像(如下图),这类图像不会进入文本检测模块,直接进入后续过程。 - - ![](https://github.com/RapidAI/RapidOCR/releases/download/v1.1.0/single_line_text.jpg) - -- `Det`部分 - | 参数名称 | 取值范围 | 默认值 | 作用 | - | ------------: | :----------: | :-----: | :----------------------------------------------| - | `use_cuda` | `bool` | `false` | 是否使用CUDA,加速推理 | - |`limit_side_len`| - | 736 | 限制图像边的长度的像素值 | - |`limit_type`| `[min, max]` | `min` | 限制图像的最小边长度还是最大边为`limit_side_len`
示例解释:当`limit_type=min`和`limit_side_len=736`时,图像最小边小于736时,
会将图像最小边拉伸到736,另一边则按图像原始比例等比缩放。 | - | `thresh` | [0, 1] | 0.3 | 图像中文字部分和背景部分分割阈值
值越大,文字部分会越小 | - | `box_thresh` | [0, 1] | 0.5 | 文本检测所得框是否保留的阈值,值越大,召回率越低 | - |`max_candidates`| - | 1000 | 图像中最大可检测到的文本框数目,一般够用| - | `unclip_ratio` | [1.6, 2.0] | 1.6 | 控制文本检测框的大小,值越大,检测框整体越大 | - |`use_dilation`| `bool` | `true` | 是否使用形态学中的膨胀操作,一般采用默认值即可 | - |`score_mode` | `string`| `fast` | `fast`是求rectangle区域的平均分数,容易造成弯曲文本漏检,`slow`是求polygon区域的平均分数,会更准确,但速度有所降低,可按需选择 | - -- `Cls`部分 - | 参数名称 | 取值范围 | 默认值 | 作用 | - | ------------: | :----------: | :-----: | :----------------------------------------------| - |`cls_img_shape`| - |`[3, 48, 192]`| 输入方向分类模型的图像Shape(CHW) | - |`cls_batch_num`| - | 6 | 批次推理的batch大小,一般采用默认值即可,太大并没有明显提速,效果还可能会差 | - |`cls_thresh`|`[0, 1]`|0.9| 方向分类结果的置信度| - |`label_list`| - | `[0, 180]` | 方向分类的标签,0°或者180°,**该参数不能动** | - -- `Rec`部分 - | 参数名称 | 取值范围 | 默认值 | 作用 | - | ------------: | :----------: | :-----: | :----------------------------------------------| - |`rec_img_shape`| - |`[3, 48, 320]`| 输入文本识别模型的图像Shape(CHW) | - |`rec_batch_num`| - | 6 | 批次推理的batch大小,一般采用默认值即可,太大并没有明显提速,效果还可能会差 | - -### onnxruntime-gpu版相关说明 -- 目前已知在onnxruntime-gpu上测试过的小伙伴,反映都是GPU推理速度比在CPU上慢很多。经过探索,初步确定原因为onnxruntime在推理动态图输入时,速度就会慢很多。关于该问题,已经提了相关issue,具体可参见[onnxruntime issue#13198](https://github.com/microsoft/onnxruntime/issues/13198) -- 为了便于比较onnxruntime上推理的基准比较,简单整理了一个[AI Studio: TestOrtInfer](https://aistudio.baidu.com/aistudio/projectdetail/4634684?contributionType=1&sUid=57084&shared=1&ts=1664700017761)项目,小伙伴想要测试的,可以直接Fork来运行查看。 - -### onnxruntime-gpu版推理配置 -1. **onnxruntime-gpu**需要严格按照与CUDA、cuDNN版本对应来安装,具体参考[文档](https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements),**这一步关乎后面是否可以成功调用GPU**。 - - 以下是安装示例: - - 所用机器环境情况: - - `nvcc-smi`显示**CUDA Driver API**版本:11.7 - - `nccc -V`显示**CUDA Runtime API**版本:11.6 - - 以上两个版本的对应关系,可参考[博客](https://blog.csdn.net/weixin_39518984/article/details/111406728) - - 具体安装命令如下: - ```bash - conda install cudatoolkit=11.6.0 - conda install cudnn=8.3.2.44 - pip install onnxruntime-gpu==1.12.0 - ``` - - 验证是否可以`onnxruntime-gpu`正常调用GPU - 1. 验证`get_device()`是否可返回GPU - ```python - import onnxruntime as ort - - print(ort.get_device()) - # GPU - ``` - 2. 如果第一步满足了,继续验证`onnxruntime-gpu`加载模型时是否可以调用GPU - ```python - import onnxruntime as ort - - providers = [ - ('CUDAExecutionProvider', { - 'device_id': 0, - 'arena_extend_strategy': 'kNextPowerOfTwo', - 'gpu_mem_limit': 2 * 1024 * 1024 * 1024, - 'cudnn_conv_algo_search': 'EXHAUSTIVE', - 'do_copy_in_default_stream': True, - }), - 'CPUExecutionProvider', - ] - - # download link: https://github.com/openvinotoolkit/openvino/files/9355419/super_resolution.zip - model_path = 'super_resolution.onnx' - session = ort.InferenceSession(model_path, providers=providers) - - print(session.get_providers()) - # 如果输出中含有CUDAExecutionProvider,则证明可以正常调用GPU - # ['CUDAExecutionProvider', 'CPUExecutionProvider'] - ``` -2. 更改[`config.yaml`](https://github.com/RapidAI/RapidOCR/blob/main/python/rapidocr_onnxruntime/config.yaml)中对应部分的参数即可,详细参数介绍参见[官方文档](https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html)。 - ```yaml - use_cuda: true - CUDAExecutionProvider: - device_id: 0 - arena_extend_strategy: kNextPowerOfTwo - gpu_mem_limit: 2 * 1024 * 1024 * 1024 - cudnn_conv_algo_search: EXHAUSTIVE - do_copy_in_default_stream: true - ``` - -3. 推理情况 - 1. 下载基准测试数据集(`test_images_benchmark`),放到`tests/benchmark`目录下。 - - [百度网盘](https://pan.baidu.com/s/1R4gYtJt2G3ypGkLWGwUCKg?pwd=ceuo) | [Google Drive](https://drive.google.com/drive/folders/1IIOCcUXdWa43Tfpsiy6UQJmPsZLnmgFh?usp=sharing) - - 最终目录结构如下: - ```text - tests/benchmark/ - ├── benchmark.py - ├── config_gpu.yaml - ├── config.yaml - └── test_images_benchmark - ``` - 2. 运行以下代码(`python`目录下运行): - ```shell - # CPU - python tests/benchmark/benchmark.py --yaml_path config.yaml - - # GPU - python tests/benchmark/benchmark.py --yaml_path config_gpu.yaml - ``` - 3. 运行相关信息汇总:(以下仅为个人测试情况,具体情况请自行测试) - - 环境 - |测试者|设备|OS|CPU|GPU|onnxruntime-gpu| - |:--|:--|:--|:--|:--|:--| - |[1][zhsunlight](https://github.com/zhsunlight)|宏碁(Acer) 暗影骑士·威N50-N93游戏台式机|Windows|十代i5-10400F 16G 512G SSD|NVIDIA GeForce GTX 1660Super 6G|1.11.0| - |[2][SWHL](https://github.com/SWHL)|服务器|Linux|AMD R9 5950X|NVIDIA GeForce RTX 3090|1.12.1| - - 耗时 - |对应上面序号|CPU总耗时(s)|CPU平均耗时(s/img)|GPU总耗时(s)|GPU平均耗时(s/img)|| - |:---:|:---:|:---:|:---:|:---:|:---:| - |[1]|296.8841|1.18282|646.14667|2.57429| - |[2]|149.35427|0.50504|250.81760|0.99927| - -### OpenVINO GPU推理配置 -- 官方参考文档:[docs](https://docs.openvino.ai/latest/api/ie_python_api/_autosummary/openvino.runtime.Core.html?highlight=compile_model#openvino.runtime.Core.compile_model) -- 考虑到openvino只能使用自家显卡推理,通用性不高,这里暂不作相关配置说明。 diff --git a/python/rapidocr_openvino/README.md b/python/rapidocr_openvino/README.md deleted file mode 100644 index 9c6aef5..0000000 --- a/python/rapidocr_openvino/README.md +++ /dev/null @@ -1,97 +0,0 @@ -## rapidocr_openvino - -❗❗❗注意:基于目前`openvino==2022.3.0`版,存在申请内存不释放的问题,这也就意味着当推理图像很大时,推理完之后,内存会一直占用。详情可参见[issue11939](https://github.com/openvinotoolkit/openvino/issues/11939) - -
-目录 - -- [rapidocr\_openvino](#rapidocr_openvino) - - [安装](#安装) - - [模型问题](#模型问题) - - [关于OpenVINO](#关于openvino) - - [OpenVINO与ONNXRuntime性能对比](#openvino与onnxruntime性能对比) - - [OpenVINO与ONNXRuntime推理代码写法对比](#openvino与onnxruntime推理代码写法对比) -
- - -#### 安装 -```bash -$ pip install openvino - -# 里面含有mo -$ pip install openvino-dev -``` - -#### 模型问题 -- 因为OpenVINO可以直接推理ONNX模型,故这里暂时不作转换,直接推理之前ONNX模型即可 -- 这里仍然给出转换的代码,用作参考: - ```bash - mo --input_model models/ch_PP-OCRv2_det_infer.onnx --output_dir models/IR/ - - mo --input_model models/ch_PP-OCRv2_det_infer.onnx \ - --output_dir models/IR/static \ - --input_shape "[1,3,12128,800]" - ``` - - -#### 关于OpenVINO -- OpenVINO可以直接推理IR、ONNX和PaddlePaddle模型,具体如下(图来源:[link](https://docs.openvino.ai/latest/openvino_docs_OV_UG_OV_Runtime_User_Guide.html#doxid-openvino-docs-o-v-u-g-o-v-runtime-user-guide)): - -
- -
- -- 和ONNXRuntime同时推理同一个ONNX模型,OpenVINO推理速度更快 -- 但是从对比来看,OpenVINO占用内存更大,其原因是拿空间换的时间 - - 当指定`input_shape`在一个区间范围时,推理时内存占用会减少一些 - - 示例命令: - ```bash - mo --input_model models/ch_PP-OCRv2_det_infer.onnx \ - --output_dir models/IR/static \ - --input_shape "[1,3,960:1200,800]" - ``` - -#### OpenVINO与ONNXRuntime性能对比 -- 推理设备:`Windows 64位 Intel(R) Core(TM) i5-4210M CPU @ 2.60GHz 2.59 GHz` -- [测试图像宽高](https://drive.google.com/file/d/1iJcGvOVIdUlyOS52bBdvO8uzx8QORo5M/view?usp=sharing): `12119x810` - -| 测试模型 | 推理框架 | 占用内存(3次平均) | 推理时间(3次平均) | -| ------------------------------------ | -------------------- | ----------------- | ----------------- | -| `ch_PP-OCRv2_det_infer.onnx` | `ONNXRuntime=1.10.0` | 0.8G | 5.354s | -| `ch_PP-OCRv2_det_infer.onnx` | `openvino=2022.1.0` | 3.225G | 2.53s | -| `ch_PP-OCRv2_det_infer.xml` FP32 动态图 | `openvino=2022.1.0` | 3.175G | 2.0455s | - - -#### OpenVINO与ONNXRuntime推理代码写法对比 -NOTE: 以`ch_ppocr_mobile_v2_det`中推理代码为例子 - -- ONNXRuntime - ```python - import onnxruntime - - # 声明 - sess_opt = onnxruntime.SessionOptions() - sess_opt.log_severity_level = 4 - sess_opt.enable_cpu_mem_arena = False - session = onnxruntime.InferenceSession(det_model_path, sess_opt) - input_name = session.get_inputs()[0].name - output_name = session.get_outputs()[0].name - - # 推理 - preds = session.run([output_name], {input_name: img}) - ``` - -- OpenVINO - ```python - from openvino.runtime import Core - - # 初始化 - ie = Core() - model_onnx = ie.read_model(det_model_path) - compile_model = ie.compile_model(model=model_onnx, device_name='CPU') - vino_session = compile_model.create_infer_request() - - # 推理 - vino_session.infer(inputs=[img]) - vino_preds = vino_session.get_output_tensor().data - ```