Skip to content

ocr: add --longest-edge 2048 default to granite-docling-v2 recipes - #219

Merged
davanstrien merged 1 commit into
mainfrom
feat/granite-docling-v2-max-edge
Dec 1, 2026
Merged

davanstrien merged 1 commit into
mainfrom
feat/granite-docling-v2-max-edge

Conversation

@davanstrien

Copy link
Copy Markdown
Owner

Adds --longest-edge (default 2048, matching lighton-ocr3-saturate.py; never upscales; 0 disables resize) and SERVING["longest_edge"] = 2048 to both ocr/granite-docling-v2-saturate.py and ocr/granite-docling-v2-bucket.py.

Why

  • The ibm-granite/granite-docling-v2-2b model card recommends 144 DPI (~1,200–1,800 px for typical book/A4 pages).
  • Feeding raw 300–400 DPI scans (>2048 px) triggers the processor's 49-tile (12,660 prompt tokens) dense tiling mode, where the model silently drops 450–700 character chunks mid-paragraph and runs ~3.7× slower on prefill.
  • Capping at 2048 px drops those pages to the 3×4 + 1 (3,368 prompt tokens) grid, eliminating the silent mid-paragraph omissions while preserving small print better than 1536/1280 px.

Validation

  • Verified SERVING parses with ast.literal_eval in both scripts.
  • Unit-checked page_png downscaling (2400×3200 → 1536×2048), no-upscale (800×1000 preserved), and --longest-edge 0 passthrough.
  • Full 2,165-page BHL rerun running on HF Jobs (6b0ef19b54072e8b7174ec6a).

@davanstrien
davanstrien merged commit 6635315 into main Dec 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant