Tools,

Unlimited-OCR on a Mac, tested

1,951 of 1,955

words found, official code on a Mac

Get the command

73 more words than Tesseract

10 scanned book pages, of 1,955 words
Run Words Time
Official code, one page at a time 1,951 297 s
Community GGUF in llama.cpp 1,949 43 s
Official code, all 10 pages in one call 1,949 355 s
Plain Tesseract 5.5.4 1,878 35 s

Unlimited-OCR is a 3.3B MIT-licensed model from Baidu, built on DeepSeek-OCR. Its official code targets NVIDIA GPUs. Both ways ran on a Mac with the fixes below.

The fast way: llama.cpp

  1. Download llama-b12391-bin-macos-arm64.tar.gz from the llama.cpp releases on GitHub and unpack it.
  2. Download the model and its vision file (3.9 GB in all):
curl -LO https://huggingface.co/sahilchachra/Unlimited-OCR-GGUF/resolve/main/Unlimited-OCR-Q8_0.gguf
curl -LO https://huggingface.co/sahilchachra/Unlimited-OCR-GGUF/resolve/main/mmproj-Unlimited-OCR-F16.gguf

Then read every page-*.jpg in the folder into book.txt:

for p in page-*.jpg; do
  ./llama-b12391/llama-mtmd-cli -m Unlimited-OCR-Q8_0.gguf --mmproj mmproj-Unlimited-OCR-F16.gguf \
    --jinja --temp 0 -n 4096 -t 2 --image "$p" -p "document parsing." < /dev/null 2> /dev/null
done | sed -E 's/<\|det\|>[^<]*<\|\/det\|>//g' > book.txt

The sed line drops the layout tags before each block. The GGUF card says stock llama.cpp cannot load these files, but b12391 did.

The official code needs two changes

pip install "torch==2.15.0" torchvision "transformers==4.57.1" einops addict easydict matplotlib requests

Save uocr.py below and run python uocr.py page.jpg. The line that moves it to the Mac GPU:

torch.Tensor.cuda = lambda self, *a, **k: self.to("mps")  # the model code calls .cuda()
The full uocr.py
"""Unlimited-OCR on a Mac GPU. Run: python uocr.py page1.jpg [page2.jpg ...] > book.txt"""

import re
import sys

import torch
from transformers import AutoModel, AutoTokenizer

NAME = "baidu/Unlimited-OCR"
torch.Tensor.cuda = lambda self, *a, **k: self.to("mps")  # the model code calls .cuda()


def load(name=NAME):
    tok = AutoTokenizer.from_pretrained(name, trust_remote_code=True)
    model = AutoModel.from_pretrained(name, trust_remote_code=True, use_safetensors=True, torch_dtype=torch.bfloat16)
    return tok, model.eval().to("mps")


def clean(raw):
    """Drop the <|det|>label [box]<|/det|> markers and the <PAGE> marks, keep the text."""
    raw = re.sub(r"<\|ref\|>.*?<\|/ref\|>", "", raw, flags=re.DOTALL)
    raw = re.sub(r"<\|det\|>.*?<\|/det\|>", "", raw, flags=re.DOTALL)
    return re.sub(r"<PAGE>", "", raw).strip()


def page(tok, model, path, out="uocr-out"):
    raw = model.infer(tok, prompt="<image>document parsing.", image_file=path, output_path=out,
                      base_size=1024, image_size=640, crop_mode=True, max_length=32768,
                      no_repeat_ngram_size=35, ngram_window=128, eval_mode=True)
    return clean(raw)


if __name__ == "__main__":
    tok, model = load()
    for p in sys.argv[1:]:
        print(page(tok, model, p), flush=True)

Keep save_results off. With it on, the model code runs Python eval() on text the model wrote.

torch 2.10.0 read nothing on my Mac

With the card's torch 2.10.0, page 1 came back as table tags and none of its 202 words:

</td></td></td></td></td></td></td></td></td></td></td></td></td></td></td></td></td></td></td></td></td></td></td></td>

In a small test on the Mac GPU, masked_scatter_ in torch 2.10.0 copied 1 value of 12. So the page image never reached the model.

torch 2.15.0 copied all 12.

All 10 pages in one call

The card's infer_multi reads a whole document in one request. It returns two values, the text and a token count:

pages = [f"page-{i:02d}.jpg" for i in range(1, 11)]
raw, tokens = model.infer_multi(tok, prompt="<image>Multi page parsing.", image_files=pages,
                                output_path="uocr-out", image_size=1024, max_length=32768,
                                no_repeat_ngram_size=35, ngram_window=1024)
print(clean(raw))

It wrote every page mark and found 1,949 words in 355 s. One page at a time was faster and read 2 more.

Unlimited-OCR-2 runs on a Mac too

Version 2 ships Triton kernels for NVIDIA GPUs, and pip has no Triton for a Mac. Its code uses them only on CUDA, so load() from uocr.py works:

tok, model = load("baidu/Unlimited-OCR-2")
print(clean(model.infer(tok, image_file="page.jpg", output_path="uocr-out", eval_mode=True)))

It found 1,912 words in 437 s: fewer than version 1, and slower. It also prints debug lines to the terminal.

Errors, and prompts that read nothing

Error Fix
Torch not compiled with CUDA enabled Use load() from uocr.py.
this custom template is not supported, try using --jinja Add --jinja, or --chat-template deepseek-ocr.
AttributeError: 'NoneType' object has no attribute 'convert' A PDF path. Pass page images.

Two other GGUF card prompts gave the wrong result:

How I tested it
  • Pages: the 10 scans of OCR in n8n, proofread Wikisource book pages, 1,955 true words, as 1920 px color JPEGs.
  • Official code: baidu/Unlimited-OCR from Hugging Face, torch 2.15.0, transformers 4.57.1, Python 3.12, on the GPU of an Apple Silicon Mac with macOS 26.6. One page at a time with the card's single-image settings.
  • llama.cpp b12391 with the Q8_0 file from sahilchachra/Unlimited-OCR-GGUF, a community conversion, not Baidu's.
  • One run at a time, lowest priority, 2 CPU threads. Other jobs shared the Mac, so times are rough.
  • Official code times leave out the model load (under 10 s). llama.cpp times include a model load for each page.
  • Score: true words found in order, with case and punctuation.
What I did not test
  • An NVIDIA GPU, vLLM, SGLang and Ollama.
  • Unlimited-OCR-2 in llama.cpp, and GGUF files other than Q8_0.
  • Tables, formulas, handwriting and non-English pages: I tested English book pages only.
Sources

Scanned pages to text, no GPU

Run it yourself. Our Apify Actor reads PDF, PNG, JPEG, WEBP and TIFF for $0.006 a page, with no model files. Its code found 1,879 of these 1,955 words.

Try the Actor

Or send us the scan. Tack, our AI, does the job for $29, up to 50 pages. First page free.

Get one page free

Questions people ask

Can Unlimited-OCR run on a Mac?

Yes. With torch 2.15.0 and one added line, the official code ran on a Mac GPU and found 1,951 of 1,955 words on 10 scanned book pages. A community GGUF in llama.cpp found 1,949 in 43 s.

Is Unlimited-OCR better than Tesseract?

On 10 scanned English book pages, the official code found 1,951 of 1,955 words in 297 s. Tesseract 5.5.4 found 1,878 in 35 s. In llama.cpp, the model found 1,949 in 43 s.

Why does Unlimited-OCR return only table tags on a Mac?

The model card pins torch 2.10.0. On my Mac (macOS 26.6), that version's masked_scatter_ failed on the GPU, so the page image never reached the language model. Install torch 2.15.0.