Skip to main content

unlimitedocr.c

unlimitedocr.c runs the baidu/Unlimited-OCR model locally with a native C/Metal inference engine and a small Python API for OCR workflows.

Python handles the user-facing pieces — image loading, prompt construction, tokenization, and text decoding. The native library handles model loading, memory management, KV cache, logits processing, and GPU execution.

Installation

uv add unlimitedocr-c

unlimitedocr-c is published on PyPI. Version 0.4.1 is the latest stable release.

Quick start

from unlimitedocr_c import UnlimitedOCR

ocr = UnlimitedOCR()
text = ocr.generate("page.png")
print(text)
ocr.close()

Create one UnlimitedOCR instance, reuse it for as many images as you want, and call close() when finished.

from unlimitedocr_c import UnlimitedOCR

ocr = UnlimitedOCR()

for image_path in ["page-1.png", "page-2.png", "page-3.png"]:
    print(ocr.generate(image_path, profile="base"))

ocr.close()

Quantization (Q8 / Q4)

The engine supports three model profiles:

Profile Weights Model file Usage
fp16 (default) fp16 ~6.7 GB UnlimitedOCR()
mixed Q8_0 int8 weights + fp16 scales ~3.5 GB UnlimitedOCR(quant="q8")
mixed Q4 int4 nearly everywhere, Q8 attention ~1.8 GB UnlimitedOCR(quant="q4")
from unlimitedocr_c import UnlimitedOCR

ocr = UnlimitedOCR(quant="q4")
text = ocr.generate("page.png")
ocr.close()

The first use converts the Hugging Face checkpoint into a cached unlimitedocr-q8.uocr / unlimitedocr-q4.uocr model file; pass force_reconvert=True to rebuild it.

Q8 quantizes all decoder and vision-encoder weight matrices (attention, MLPs, MoE experts, LM head, embeddings, projector) with group-64 Q8_0. Norms, biases, position embeddings, convolutions, and all runtime activations stay fp16. Dequantization is fused inside the Metal kernels — quantization roughly halves model memory and speeds up token generation, which is memory-bandwidth-bound.

Mixed Q4 stores the routed MoE experts, shared experts, dense MLP, LM head, token embedding and vision encoders as group-64 Q4_0 — symmetric int4 with fp16 scales and a group-half-split nibble packing chosen for vectorized dequantization in the fused Metal kernels. Attention projections stay Q8_0 (highest quality sensitivity); norms, biases and convolutions stay fp16. On M1 Pro the routed-expert decode step measured ~2.7× faster than Q8 and the fused LM-head argmax ~1.2× faster.

Input types

generate() accepts the common image forms directly:

Input type Example
local path ocr.generate("page.png")
URL ocr.generate("https://example.com/page.jpg")
bytes ocr.generate(open("page.png", "rb").read())
file-like object ocr.generate(BytesIO(image_bytes))
PIL image ocr.generate(Image.open("page.png"))
base64/data URI string ocr.generate("data:image/png;base64,...")

Example:

from io import BytesIO
from PIL import Image
from unlimitedocr_c import UnlimitedOCR

ocr = UnlimitedOCR()

text_from_path = ocr.generate("page.png")
text_from_url = ocr.generate("https://example.com/page.jpg")
text_from_bytes = ocr.generate(open("page.png", "rb").read())
text_from_file = ocr.generate(BytesIO(open("page.png", "rb").read()))
text_from_pil = ocr.generate(Image.open("page.png"))

ocr.close()

Metadata

Release files for unlimitedocr-c 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for unlimitedocr-c 0.4.1
File Interpreter ABI Platform
unlimitedocr_c-0.4.1-py3-none-macosx_15_0_arm64.whl Python 3 none macOS 15.0+ ARM64 Details

Release files / unlimitedocr_c-0.4.1-py3-none-macosx_15_0_arm64.whl

Download URL unlimitedocr_c-0.4.1-py3-none-macosx_15_0_arm64.whl
Size 485.7 kB
Tags Python 3 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
ae8fd152bf128a2bca2c3ab872995131614ed97cffff59dd5f9bc41437428ba0
BLAKE2b-256 checksum
How to use checksums
b8df7777e8216946235dd7ef74359e526f1a2f30cd8d160833b384a167d6b271
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.4.1 This release

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page