{"id":5710,"library":"rapidocr-onnxruntime","title":"RapidOCR-ONNXRuntime","description":"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.","status":"active","version":"1.4.4","language":"en","source_language":"en","source_url":"https://github.com/RapidAI/RapidOCR","tags":["OCR","AI","OnnxRuntime","Deep Learning","Text Recognition","Cross-platform"],"install":[{"cmd":"pip install rapidocr-onnxruntime","lang":"bash","label":"Default installation"}],"dependencies":[{"reason":"Core inference engine for ONNX models.","package":"onnxruntime","optional":false},{"reason":"For GPU acceleration (instead of or in addition to onnxruntime).","package":"onnxruntime-gpu","optional":true},{"reason":"Image processing operations.","package":"opencv-python","optional":false},{"reason":"Numerical operations, array handling.","package":"numpy","optional":false},{"reason":"Image manipulation.","package":"Pillow","optional":false},{"reason":"Polygon clipping for text box processing.","package":"pyclipper","optional":false},{"reason":"Configuration file parsing.","package":"PyYAML","optional":false},{"reason":"Python 2 and 3 compatibility utilities.","package":"six","optional":false},{"reason":"Progress bar for operations.","package":"tqdm","optional":false}],"imports":[{"note":"The primary user-facing class `RapidOCR`, which internally uses `rapidocr-onnxruntime` as its ONNX backend, is typically imported from the higher-level `rapidocr` package. Direct imports from `rapidocr_onnxruntime` are not for general API use.","wrong":"from rapidocr_onnxruntime import RapidOCR","symbol":"RapidOCR","correct":"from rapidocr import RapidOCR"}],"quickstart":{"code":"from rapidocr import RapidOCR\nfrom PIL import Image\nimport requests\nfrom io import BytesIO\n\n# Initialize the OCR engine\nengine = RapidOCR()\n\n# Example image URL (replace with your image path or URL)\nimg_url = \"https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/resources/test_files/ch_en_num.jpg\"\n\n# Download and open the image\nresponse = requests.get(img_url)\nimage = Image.open(BytesIO(response.content))\n\n# Perform OCR\nresult = engine(image)\n\n# Print the OCR results\nprint(result)\n\n# Optionally, visualize the result (requires OpenCV installed and a display environment)\n# import cv2\n# import numpy as np\n# image_np = np.array(image)\n# for box, text, score in result:\n#     box = np.array(box).astype(np.int32).reshape((-1, 1, 2))\n#     cv2.polylines(image_np, [box], True, (0, 255, 0), 2)\n#     cv2.putText(image_np, text, (box, box - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)\n# cv2.imshow(\"OCR Result\", image_np)\n# cv2.waitKey(0)\n# cv2.destroyAllWindows()","lang":"python","description":"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."},"warnings":[{"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.","message":"The `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.","severity":"gotcha","affected_versions":"<=1.4.4"},{"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.","message":"For 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.","severity":"gotcha","affected_versions":"All"},{"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.","message":"While 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.","severity":"gotcha","affected_versions":"All"},{"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.","message":"Some 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.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}