{"id":3788,"library":"rapidocr","title":"RapidOCR","description":"RapidOCR is an open-source, multi-platform, multi-language Optical Character Recognition (OCR) toolkit designed for fast and offline deployment. It leverages various inference engines like ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT, and PyTorch, offering both speed and extensive compatibility by converting PaddleOCR models to ONNX format. The library is currently at version 3.8.1 and maintains a very active release cadence.","status":"active","version":"3.8.1","language":"en","source_language":"en","source_url":"https://github.com/RapidAI/RapidOCR","tags":["OCR","computer vision","AI","text recognition","document processing","onnx","paddleocr"],"install":[{"cmd":"pip install rapidocr onnxruntime","lang":"bash","label":"Recommended (ONNX Runtime backend)"},{"cmd":"pip install rapidocr rapidocr_openvino","lang":"bash","label":"OpenVINO backend (for Intel hardware)"},{"cmd":"pip install rapidocr rapidocr_paddle","lang":"bash","label":"PaddlePaddle backend"},{"cmd":"pip install rapidocr rapidocr_pytorch","lang":"bash","label":"PyTorch backend"}],"dependencies":[{"reason":"Required Python version","package":"python","optional":false},{"reason":"Default and recommended inference backend for balanced performance.","package":"onnxruntime","optional":false},{"reason":"For NVIDIA CUDA-enabled GPU acceleration. Requires uninstalling onnxruntime (CPU version) first.","package":"onnxruntime-gpu","optional":true},{"reason":"Alternative inference backend for Intel hardware acceleration (CPUs, VPUs, iGPUs).","package":"rapidocr_openvino","optional":true},{"reason":"Alternative inference backend for PaddlePaddle ecosystem compatibility.","package":"rapidocr_paddle","optional":true},{"reason":"Alternative inference backend for PyTorch research workflows.","package":"rapidocr_pytorch","optional":true}],"imports":[{"symbol":"RapidOCR","correct":"from rapidocr import RapidOCR"},{"note":"Required for advanced model selection introduced in v3.4.0.","symbol":"LangRec, ModelType, OCRVersion","correct":"from rapidocr import LangRec, ModelType, OCRVersion"}],"quickstart":{"code":"import os\nfrom rapidocr import RapidOCR\n\n# Initialize the OCR engine. This will automatically download models on first run.\n# Ensure 'onnxruntime' or another backend is installed (e.g., pip install rapidocr onnxruntime)\nengine = RapidOCR()\n\n# Example image from a public URL\nimg_url = \"https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/resources/test_files/ch_en_num.jpg\"\n\n# Process the image\nresult = engine(img_url)\n\n# Print the extracted text results\nfor line in result:\n    # Each line typically contains bounding box, text, and confidence\n    if len(line) >= 2:\n        print(f\"Text: {line[1]}\")\n\n# You can also visualize the results (requires OpenCV)\n# result.vis(\"vis_result.jpg\")\n# print(\"Visualization saved to vis_result.jpg\")","lang":"python","description":"This quickstart initializes the RapidOCR engine, which automatically handles model downloads on the first execution. It then performs OCR on a sample image from a URL and prints the extracted text. For visualization, ensure OpenCV is installed (e.g., `pip install opencv-python`)."},"warnings":[{"fix":"To avoid runtime downloads, pre-download models and configure `model_root_dir` (introduced in v3.8.0) or ensure local model caches are properly configured for offline usage. Setting `HF_HUB_OFFLINE=1` might also help.","message":"RapidOCR automatically downloads models upon first initialization. This can lead to unexpected network requests in offline environments or CI/CD pipelines. In some integrated setups, models might still be downloaded even if OCR processing is explicitly disabled (`do_ocr=False`).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review the official documentation's model list and explicitly specify model parameters (e.g., `params={'Rec.lang_type': LangRec.EL, 'Rec.ocr_version': OCRVersion.PPOCRV5}`) in the `RapidOCR` constructor if you need specific language models.","message":"Starting from v3.4.0, the `RapidOCR` constructor gained new `params` for explicit model selection, including `LangRec`, `ModelType`, and `OCRVersion` to support new PaddleOCRv5 models for languages like English, Thai, and Greek. Older code relying on implicit language detection or default models for these languages might need adjustment.","severity":"breaking","affected_versions":">=3.4.0"},{"fix":"Always uninstall the CPU version of ONNX Runtime before installing its GPU counterpart: `pip uninstall onnxruntime && pip install onnxruntime-gpu`. Verify GPU availability with `import onnxruntime; print(onnxruntime.get_device())`.","message":"GPU acceleration requires careful setup. If you've installed the CPU version of `onnxruntime`, you must `pip uninstall onnxruntime` before installing `onnxruntime-gpu` to ensure the correct inference provider is used. DirectML for Windows GPUs is noted to affect speed on older devices.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consider using alternative OCR engines like Tesseract or EasyOCR in such environments, or ensure a writable temporary directory is configured for RapidOCR's model downloads and caches.","message":"RapidOCR is known to have issues when deployed on read-only filesystems (e.g., Databricks environments) due to its model caching mechanism.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}