📄 Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.
因models体积太大,仓库回退,去除models,另找地方存放
benjaminwan82b52739e25a
diff --git a/.gitignore b/.gitignorenew file mode 100644index 0000000..016ae31--- /dev/null+++ b/.gitignore@@ -0,0 +1,137 @@+# Created by .ignore support plugin (hsz.mobi)+### Python template+# Byte-compiled / optimized / DLL files+__pycache__/+*.py[cod]+*$py.class++# C extensions+*.so++# Distribution / packaging+.Python+build/+develop-eggs/+dist/+downloads/+eggs/+.eggs/+lib/+lib64/+parts/+sdist/+var/+wheels/+pip-wheel-metadata/+share/python-wheels/+*.egg-info/+.installed.cfg+*.egg+MANIFEST++# PyInstaller+# Usually these files are written by a python script from a template+# before PyInstaller builds the exe, so as to inject date/other infos into it.+*.manifest+*.spec++# Installer logs+pip-log.txt+pip-delete-this-directory.txt++# Unit test / coverage reports+htmlcov/+.tox/+.nox/+.coverage+.coverage.*+.cache+nosetests.xml+coverage.xml+*.cover+*.py,cover+.hypothesis/+.pytest_cache/++# Translations+*.mo+*.pot++# Django stuff:+*.log+local_settings.py+db.sqlite3+db.sqlite3-journal++# Flask stuff:+instance/+.webassets-cache++# Scrapy stuff:+.scrapy++# Sphinx documentation+docs/_build/++# PyBuilder+target/++# Jupyter Notebook+.ipynb_checkpoints++# IPython+profile_default/+ipython_config.py++# pyenv+.python-version++# pipenv+# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.+# However, in case of collaboration, if having platform-specific dependencies or dependencies+# having no cross-platform support, pipenv may install dependencies that don't work, or not+# install all needed dependencies.+#Pipfile.lock++# PEP 582; used by e.g. github.com/David-OConnor/pyflow+__pypackages__/++# Celery stuff+celerybeat-schedule+celerybeat.pid++# SageMath parsed files+*.sage.py++# Environments+.env+.venv+env/+venv/+ENV/+env.bak/+venv.bak/++# Spyder project settings+.spyderproject+.spyproject++# Rope project settings+.ropeproject++# mkdocs documentation+/site++# mypy+.mypy_cache/+.dmypy.json+dmypy.json++# Pyre type checker+.pyre/++#idea+.idea+/test_imgs+/models+diff --git a/android/readme.txt b/android/readme.txtnew file mode 100644index 0000000..b3a4252--- /dev/null+++ b/android/readme.txt@@ -0,0 +1 @@+placeholder\ No newline at end of filediff --git a/commonlib/readme.txt b/commonlib/readme.txtnew file mode 100644index 0000000..b3a4252--- /dev/null+++ b/commonlib/readme.txt@@ -0,0 +1 @@+placeholder\ No newline at end of filediff --git a/include/precomp.h b/include/precomp.hnew file mode 100644index 0000000..6f70f09--- /dev/null+++ b/include/precomp.h@@ -0,0 +1 @@+#pragma oncediff --git a/ios/readme.txt b/ios/readme.txtnew file mode 100644index 0000000..b3a4252--- /dev/null+++ b/ios/readme.txt@@ -0,0 +1 @@+placeholder\ No newline at end of filediff --git a/pc/readme.txt b/pc/readme.txtnew file mode 100644index 0000000..b3a4252--- /dev/null+++ b/pc/readme.txt@@ -0,0 +1 @@+placeholder\ No newline at end of filediff --git a/python/bpocr.py b/python/bpocr.pynew file mode 100644index 0000000..8415991--- /dev/null+++ b/python/bpocr.py@@ -0,0 +1,2 @@+import onnx+import onnxruntime as ortdiff --git a/python/readme.txt b/python/readme.txtnew file mode 100644index 0000000..b3a4252--- /dev/null+++ b/python/readme.txt@@ -0,0 +1 @@+placeholder\ No newline at end of filediff --git a/readme.md b/readme.mdindex 54c91e7..91f370d 100644--- a/readme.md+++ b/readme.md@@ -1,10 +1,21 @@-访问: [中文版](readme_cn.md)+访问: [中文版](readme_cn.md) Chinese Name: 白富美OCR-BaiPiaoOCR means a PiaoLiang( A Chinese word means Beautiful in English ) OCR Engine From Baidu, it's based on PaddleOCR & OnnxRuntime.+Author: benjaminwan, znsoftm++BaiPiaoOCR means an OCR Engine who is fair-skinned,rich and beautiful From Baidu, it's based on PaddleOCR & OnnxRuntime.++Note: The project is derived from https://github.com/PaddlePaddle/PaddleOCRWe create the project to transfer PaddleOCR's model into the version of Onnx model to deploy the model on almost every devices, such as x86 PC, Android & IOS.-We are using Paddle2ONNX (https://github.com/PaddlePaddle/Paddle2ONNX) to transform its model to Onnx format.+We are using Paddle2ONNX (https://github.com/PaddlePaddle/Paddle2ONNX) to transform it to Onnx format.+++++You can visualize the model by https://github.com/lutzroeder/netron/+Welcome to our Group on QQ: 887298230+or visit: https://jq.qq.com/?_wv=1027&k=P9b3olx6diff --git a/readme_cn.md b/readme_cn.mdindex ded7286..dab32be 100644--- a/readme_cn.md+++ b/readme_cn.md@@ -1,9 +1,25 @@- 百漂OCR, 本意为“北漂”,由于库主的普通话不好,写成了Bai漂(南方人,你们懂的)+ 本项目欢迎提交issue, 欢迎PR.++ 为什么要创建这个项目? 百度paddlepaddle工程化不是太好,为了方便大家在各种端上进行ocr推理,我们将它转换为onnx格式,使用python/c++/java/swift 将它移植到各个平台。++ 预计支持以下平台:++ Windows /Linux/ IOS/ android/Java++ 白富美OCR, 模型来源于百度,富人家的千金 -- 白富美。-有人理解为白piao来的OCR模型开发的OCR项目,这个理解也对味。--反正大家明白意思就好了。+基于百度的开源PaddleOCR,任何人可以使用本推理库,也可以根据自己的需求使用百度的paddlepaddle 框架进行模型优化。+++**关于模型训练 :**++https://zhuanlan.zhihu.com/p/268761718+++**关于授权:**++OCR模型版权归百度所有,其它工程代码版权归本仓库所有者所有。 本软件采用LGPL 授权方式,欢迎大家贡献代码,提交issue 甚至pr.+您可以通过QQ群联系到我们: 887298230-关于授权: OCR模型版权归百度所有,其它工程代码版权归本仓库所有者所有。 本软件采用LGPL 授权方式,欢迎大家贡献代码,提交issue 甚至pr.diff --git a/tools/modelconvert.py b/tools/modelconvert.pynew file mode 100644index 0000000..b8f5560--- /dev/null+++ b/tools/modelconvert.py@@ -0,0 +1,33 @@+import os+import onnx++def WalkDir(dirlist,filelist,dirname):+ try:+ ls=os.listdir(dirname)+ except:+ print(" Access Deny.")+ else:+ for fn in ls:+ temp=os.path.join(dirname,fn)+ if (os.path.isdir(temp)):+ dirlist.append(temp)+ # WalkDir(dirlist,filelist,temp)+ else:+ if temp.endswith(".onnx"):+ filelist.append(temp)+ return dirlist,filelist++def ConvertModel(srcfile, dstfile):+ onnx_model = onnx.load(srcfile)+ onnx_model.graph.input[0].type.tensor_type.shape.dim[2].dim_param = '?' # w涓哄姩鎬佽緭鍏?+ onnx_model.graph.input[0].type.tensor_type.shape.dim[3].dim_param = '?'+ onnx.save(onnx_model, dstfile)+++dirlist=[]+filelist=[]+WalkDir(dirlist,filelist,os.getcwd())++for file in filelist:+ dstfile=file+".new"+ ConvertModel(file,dstfile)diff --git a/tools/test.py b/tools/test.pynew file mode 100644index 0000000..8af02a5--- /dev/null+++ b/tools/test.py@@ -0,0 +1,8 @@+import numpy as np+import onnx+import onnxruntime as ort+x=np.random.rand(1,3,32,256)+session = ort.InferenceSession("ch_ppocr_mobile_v2.0_det_infer.onnx.new")+onnx_inputs = { session.get_inputs()[0].name: x.astype(np.float32)}+onnx_outputs=session.run(None, onnx_inputs)+print(onnx_outputs)