ONNX PaddleOCR
Project description
ONNX PaddleOCR
这是一个基于 ONNX 的 PaddleOCR 实现,支持文字检测和识别功能。
特性
- 支持多种语言文字识别
- 基于 ONNX,无需安装 PaddlePaddle 和 paddleocr
- 支持 GPU 加速(需要 onnxruntime-gpu)
- 轻量级部署
安装
pip install onnx-paddleocr # pip安装
uv add onnx-paddleocr # uv安装
使用方法
命令行使用
pipx install onnx-paddleocr # pipx安装
uv tool install onnx-paddleocr # uv安装
ocr --help # 帮助信息
ocr ./images/test.jpg # 示例:识别图片
Python API 使用
from onnx_ocr import ONNXPaddleOcr
import cv2
# 初始化OCR
model = ONNXPaddleOcr(
use_angle_cls=False,
use_gpu=False,
cpu_threads=16,
det_model_dir="", # 不指定默认:~/.onnx/models/ppocrv5_server/det/det.onnx
rec_model_dir="", # 不指定默认:~/.onnx/models/ppocrv5_server/rec/rec.onnx
)
# 读取图片
img = cv2.imread('./images/test.jpg')
# 执行OCR
result = ocr.ocr(img)
# 输出结果
for line in result[0]:
print(f"文本: {line[1][0]}, 置信度: {line[1][1]}")
模型文件
模型采用ppocrv5_server文件不会包含在安装包中,首次运行时程序会自动从 GitHub Releases 下载所需模型文件到本地用户目录下的:~/.onnx/models/ppocrv5_server
如果您希望手动下载模型,请访问以下链接:
将这些文件放置在如下目录结构中:
~/.onnx/models/
└── ppocrv5_server/
├── det/
│ └── det.onnx
└── rec/
└── rec.onnx
部分参数说明
| 参数 | 默认值 | 说明 |
|---|---|---|
| --use-angle-cls | False | 是否使用角度分类器 |
| --use-gpu | False | 是否使用 GPU |
| --det-model | ~/.onnx/models/ppocrv5_server/det/det.onnx | 检测模型路径 |
| --rec-model | ~/.onnx/models/ppocrv5_server/rec/rec.onnx | 识别模型路径 |
许可证
本项目采用 MIT 许可证。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
onnx_paddleocr-0.1.0.tar.gz
(6.0 MB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file onnx_paddleocr-0.1.0.tar.gz.
File metadata
- Download URL: onnx_paddleocr-0.1.0.tar.gz
- Upload date:
- Size: 6.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6edf87e2c7f625c04dc8854081add784852808efa4e027dd139a9b90896ef102
|
|
| MD5 |
5800f893774c41165c7d7bafcaa9da3b
|
|
| BLAKE2b-256 |
b77a7e4a93c33f6b9e9345b2cea4c9277d88edf3345d5c6bdcca2c1231836ba5
|
File details
Details for the file onnx_paddleocr-0.1.0-py3-none-any.whl.
File metadata
- Download URL: onnx_paddleocr-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb2d83a14ead9d23b14796caa89bccee006a3ee6f95b5363c2e093f0ae951266
|
|
| MD5 |
52cf72a446cb0a256422d92da7229e5b
|
|
| BLAKE2b-256 |
03f0e03dd604368ddd9da06f7b4288ca65c8cf2b1cccdf4b87fc680940291778
|