{
 "schema_version": 1,
 "generated": "2026-10-30",
 "id": "baidu-unlimited-ocr--parse-a-long-multi-page-document-with-unlimited-ocr-2",
 "repo": "baidu/Unlimited-OCR",
 "repo_url": "https://github.com/baidu/Unlimited-OCR",
 "repo_slug": "baidu-unlimited-ocr",
 "title": "Parse a long multi-page scan with cross-page context",
 "page_title": "How to parse a long multi-page scan with cross-page context with Unlimited OCR",
 "summary": "Load Unlimited OCR 2 in Transformers and parse all pages of a document in one request.",
 "who": "A data engineer turning long scanned reports into text where tables and sections cross page breaks.",
 "problem": "Page-by-page OCR loses context across pages and breaks tables and paragraphs that span them.",
 "outcome": "Text for the whole document from one multi-page call, saved to an output folder.",
 "steps": [
  "Install the tested versions with `pip install torch==2.13.0 torchvision pillow transformers==4.52.1 huggingface-hub==0.36.0` plus the other pinned packages in the README",
  "Load baidu/Unlimited-OCR-2 with AutoModel and AutoTokenizer using trust_remote_code=True and bfloat16 on CUDA",
  "Convert your document to page images in page order",
  "Call model.infer_multi with image_files set to the pages and save_results=True",
  "For a single page, call model.infer, which uses dynamic tiling (gundam mode)"
 ],
 "agent_prompt": "Using baidu/Unlimited-OCR-2 in Transformers as the README shows, convert <document.pdf> to page images, run infer_multi over all pages, and save the text to output/multi. Report token count and any pages that look wrong.",
 "agents": [
  "claude-code",
  "codex"
 ],
 "difficulty": "Advanced",
 "time": "1 hour",
 "basis": "readme",
 "caveat": "",
 "category": "Data and analytics",
 "tags": [
  "Data and analytics"
 ],
 "lang": "python",
 "requirements": [
  "An NVIDIA GPU (tested on an A800 80GB) with CUDA",
  "Python 3.10 with torch 2.13.0 and transformers 4.52.1, or uv for the SGLang setup",
  "PyMuPDF to convert PDFs to page images"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [
  {
   "tag": "remote-code",
   "notice": "Loading the model uses trust_remote_code=True, which runs code from the model repository; review it first."
  }
 ],
 "best": true,
 "score": 1.0,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/baidu-unlimited-ocr/parse-a-long-multi-page-document-with-unlimited-ocr-2/",
 "md": "https://dedupedai.com/use-cases/baidu-unlimited-ocr/parse-a-long-multi-page-document-with-unlimited-ocr-2/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/baidu-unlimited-ocr--parse-a-long-multi-page-document-with-unlimited-ocr-2.json",
 "api_version": "v1"
}
