# Unlimited-OCR

> Open OCR model that turns images and multi-page PDFs into structured text in one pass

- Repository: https://github.com/baidu/Unlimited-OCR
- Category: Models & local AI
- Stars: 28,230 · Forks: 2,992 · Language: Python · License: MIT
- Experience: Some experience
- Page: https://ir.adyog.com/repos/baidu/unlimited-ocr/

Classic OCR tools read one page at a time and often lose layout, tables and reading order. Unlimited-OCR is a model that looks at page images and writes out the parsed document, and it is built to handle long inputs such as many pages in a single request.

You give it an image or a list of page images with a short prompt like 'document parsing.' or 'Multi page parsing.' For a single image there are two modes, 'gundam' (cropped, 640 px) and 'base' (1024 px). Multi-page and PDF input uses base mode only. A PDF is first turned into page images with PyMuPDF, then parsed together.

The README says it aims to push DeepSeek-OCR one step further and credits DeepSeek-OCR, DeepSeek-OCR-2 and PaddleOCR. It ships with a no-repeat n-gram setting to stop the model looping on long outputs. The code is MIT licensed and the weights are on Hugging Face and ModelScope.

## What it does

- **Multi-page and PDF parsing**: Pass several page images, or a PDF converted to images, and get one parsed result for the whole document.
- **Two single-image modes**: Choose 'gundam' (cropped, image size 640) or 'base' (image size 1024) for a single image.
- **Three ways to run it**: Use Hugging Face transformers on an NVIDIA GPU, a vLLM Docker image, or an SGLang server with an OpenAI-compatible API.
- **Batch script**: infer.py starts an SGLang server and sends concurrent requests for a folder of images or a PDF.
- **Training and hosting options**: The release notes say it supports training with ms-swift and is available on Baidu Cloud, ModelScope and a Hugging Face demo.

## What you could build

- Convert a scanned PDF report into parsed text in a single multi-page run.
- Batch-process a folder of document images with infer.py and a few concurrent requests.
- Serve an OCR endpoint with vLLM or SGLang and call it from your own app.
- Compare its output against DeepSeek-OCR on your own documents.
- Fine-tune the model on your own document types with ms-swift.

## Who it's for

Suits developers and ML students who have an NVIDIA GPU and are comfortable with Python and Hugging Face models.

## Get started

Set up Python 3.12 with CUDA and the pinned packages listed in the README (torch, transformers, PyMuPDF and others). Then load baidu/Unlimited-OCR with transformers and call model.infer on an image or model.infer_multi on page images. For serving, follow the vLLM recipe or the SGLang steps.

```
docker pull vllm/vllm-openai:unlimited-ocr
```
```
docker pull vllm/vllm-openai:unlimited-ocr-cu129
```

Tags: ocr, document-parsing, vision-language, pdf, vllm
