YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

Unlimited-OCR Fork

This repository is a fork/local adaptation of Baidu's Unlimited-OCR model:

Read the original model card and upstream repository first for model details, license, intended usage, limitations, citation, and full inference guidance.

Local Setup

uv sync

Run a basic local load/inference smoke test:

uv run python test_inference.py \
  --model . \
  --image assets/Unlimited-OCR.png \
  --prompt '<image>document parsing.'

ONNX Export

Export the local model checkout to ONNX:

uv run --with onnx --with onnxscript python scripts/export_onnx.py \
  --model . \
  --image-sequence-length 512 \
  --output onnx/unlimited_ocr.onnx

The default ONNX target exports an image prefill forward graph. It does not export the Python generate() loop or PIL preprocessing from model.infer(). ONNX export uses float16 on CUDA and float32 on CPU when --dtype auto is used. bfloat16 exports are not compatible with ONNX Runtime for this graph's convolution nodes. The image ONNX graph is fixed-length because the model's MoE routing is data-dependent. Increase --image-sequence-length if prompt tokens plus generated tokens exceed the default capacity. The exporter traces with padded attention-mask slots; re-export old ONNX files if inference returns no visible text. ONNX export uses a dense tensor-only MoE route for correctness, so it can be slower than the PyTorch expert-dispatch path.

Text-only export:

uv run --with onnx --with onnxscript python scripts/export_onnx.py \
  --target text \
  --dynamic-text \
  --output onnx/unlimited_ocr_text.onnx

ONNX Inference

Run greedy ONNX Runtime inference:

uv run --with onnxruntime python scripts/inference_onnx.py \
  --onnx onnx/unlimited_ocr.onnx \
  --model . \
  --image assets/Unlimited-OCR.png \
  --prompt '<image>document parsing.'

For a CUDA/float16 ONNX graph, run inference with onnxruntime-gpu so CUDAExecutionProvider is available.

Notes

  • Generated ONNX files are written under onnx/ and are ignored by git.
  • Large model weights are expected to be present in this checkout or fetched from the original model source.
Downloads last month
176
Safetensors
Model size
3B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support