Instructions to use openbmb/MiniCPM-OCR-1.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MiniCPM-OCR
How to use openbmb/MiniCPM-OCR-1.0 with MiniCPM-OCR:
pip install "minicpm-ocr[all]" huggingface_hub # Deploy openbmb/MiniCPM-OCR-1.0 as a recognition service before running the Python example: # https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/vllm_deploy_en.md # vLLM: load the model above; use --port 8080, # --served-model-name minicpm-ocr and --max-model-len 40960. # Layout detection uses cuda:0; recognition runs on the deployed service.
from importlib.resources import files from pathlib import Path from minicpmvocr import load_config, pipelined_run from huggingface_hub import snapshot_download layout_model = snapshot_download("PaddlePaddle/PP-DocLayoutV3") cfg = load_config( str(files("minicpmvocr").joinpath("configs/minicpmvocr.yaml")), overrides={ "input": {"file_path": str(Path("demo.png").resolve())}, "engine": { "type": "vllm", "server_url": "http://127.0.0.1:8080", "model_name": "minicpm-ocr", "max_model_len": 40960, }, "layout": {"model_dir": layout_model, "device": "cuda:0"}, # Render PDFs in-process so this example also works without a main guard. "pipeline": {"overlap_layout": True, "render_workers": 1}, }, ) pipelined_run(cfg) - Notebooks
- Google Colab
- Kaggle
MiniCPM-OCR-1.0 as single CMF files for cortiq (Rust, no Python)
We packaged MiniCPM-OCR-1.0 as single CMF files that run with cortiq, a Rust inference engine with no Python: the SigLIP encoder with the slicing processor and the language model, on Vulkan/DX12/Metal or CPU. cortiq serve gives an OpenAI-compatible endpoint with image parts. These files cover the recognition step; layout detection and reading order stay in your SDK.
Files: https://huggingface.co/infosave/MiniCPM-OCR-1.0-cmf — q8_2f (1.7 GB, 300 greedy tokens of a page identical to Transformers float32) and q4tp (1.4 GB).
On one A4 page at 144 dpi an RTX PRO 4500 decodes at 254 and 267 tok/s, with 2 s from the image to the first token. An Apple M4 (10-core GPU, Metal) decodes at 73 and 102 tok/s, about 8 s to the first token.
cargo install cortiq-cli
cortiq run minicpm-ocr-1.0-q8_2f.cmf --image page.png --prompt "Text Recognition:" --max-tokens 2048
(cortiq 0.8.54)