Registry / ai-ml / rapidocr-onnxruntime

rapidocr-onnxruntime

JSON →
library1.4.4pypypi✓ verified 10d ago

RapidOCR-ONNXRuntime is a Python library providing cross-platform Optical Character Recognition (OCR) capabilities, leveraging the ONNX Runtime inference engine for high-speed and efficient offline deployments. It converts PaddleOCR models to the ONNX format, offering a performant solution for text recognition. The library supports multiple programming languages, with its Python interface primarily integrated into the broader RapidOCR ecosystem. The current PyPI version is 1.4.4, released in January 2025, and the associated GitHub project is actively maintained with frequent updates.

pip install rapidocr-onnxruntime
INSTALL
IMPORT
SIG · RAPIDOCR-ONNXRUNTI
R
rapidocr-onnxruntime
ai-mlpythonv1.4.4
Install
10.5s avg
Import
Disk
414MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.4.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
timeout
glibc
py 3.103.95 runs
installs and imports cleanly · install 10.5s · import 0.000s · 443MB
414MB installed
● package 414MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RapidOCR
from rapidocr_onnxruntime import RapidOCR
from rapidocr import RapidOCR

This quickstart demonstrates how to initialize the RapidOCR engine and perform OCR on an image. The `RapidOCR` class handles model loading and inference using the ONNX Runtime backend provided by `rapidocr-onnxruntime`. The example downloads an image from a URL, processes it, and prints the detected text along with bounding box information.

from rapidocr import RapidOCR from PIL import Image import requests from io import BytesIO # Initialize the OCR engine engine = RapidOCR() # Example image URL (replace with your image path or URL) img_url = "https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/resources/test_files/ch_en_num.jpg" # Download and open the image response = requests.get(img_url) image = Image.open(BytesIO(response.content)) # Perform OCR result = engine(image) # Print the OCR results print(result) # Optionally, visualize the result (requires OpenCV installed and a display environment) # import cv2 # import numpy as np # image_np = np.array(image) # for box, text, score in result: # box = np.array(box).astype(np.int32).reshape((-1, 1, 2)) # cv2.polylines(image_np, [box], True, (0, 255, 0), 2) # cv2.putText(image_np, text, (box, box - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2) # cv2.imshow("OCR Result", image_np) # cv2.waitKey(0) # cv2.destroyAllWindows()
Debug
Known issues
gotchaThe `rapidocr-onnxruntime` package (PyPI version 1.4.4) is a core component and backend for the broader `RapidOCR` project on GitHub, which uses a `v3.x.x` versioning scheme. The user-facing API is primarily accessed through the `rapidocr` package (e.g., `from rapidocr import RapidOCR`), which integrates this ONNX Runtime backend.
fix
Always install `rapidocr-onnxruntime` if you intend to use the ONNX Runtime backend, and import the `RapidOCR` class from the `rapidocr` package for typical usage. Refer to the official RapidOCR GitHub documentation for the most current usage patterns.
affects: <=1.4.4
gotchaFor GPU acceleration, installing `onnxruntime-gpu` is necessary. Simply installing `rapidocr-onnxruntime` will often default to `onnxruntime` (CPU). Additionally, `onnxruntime-directml` (which might be the default on some Windows systems) can lead to slower performance on older hardware.
fix
Explicitly install `onnxruntime-gpu` for GPU inference (e.g., `pip install rapidocr-onnxruntime onnxruntime-gpu`). For optimal performance, especially on Windows, consider the specific `onnxruntime` variant that best suits your hardware.
affects: All
gotchaWhile RapidOCR supports Chinese and English by default, using other languages or custom models often requires specific configurations or 'self-service conversion' of models. Directly using models not from the RapidAI/RapidOCR repository may lead to compatibility issues or require manual patching of configurations.
fix
Consult the RapidOCR documentation's 'Model List' and 'User Guide' sections for details on supported languages and the process for integrating custom or additional language models.
affects: All
gotchaSome users have reported that the `TextDetector` component within RapidOCR, when using the ONNX Runtime backend, can be slower for text detection tasks compared to PaddleOCR's native implementation.
fix
If text detection speed is critical and appears to be a bottleneck, consider experimenting with different `onnxruntime` configurations (e.g., thread counts) or evaluating alternative OCR engines, especially if migrating from PaddleOCR.
affects: All
Upgrade
Version history
1.4.4latest on PyPI · released Jan 17, 2025
Audit
Dependencies
onnxruntimerequiredCore inference engine for ONNX models.
onnxruntime-gpuoptionalFor GPU acceleration (instead of or in addition to onnxruntime).
opencv-pythonrequiredImage processing operations.
numpyrequiredNumerical operations, array handling.
PillowrequiredImage manipulation.
pyclipperrequiredPolygon clipping for text box processing.
PyYAMLrequiredConfiguration file parsing.
sixrequiredPython 2 and 3 compatibility utilities.
tqdmrequiredProgress bar for operations.
Agent activity
284 hits · last 30 days
node
261
Meta
2
Bingbot
2
Perplexity
1
Resources
rapidocr-onnxruntime — pip install rapidocr-onnxruntime · libregistry