ocrtool models

ONNX models used by ocrtool, a C++ command-line tool that converts PDFs to Markdown, translates PDFs in place, identifies the fonts in an image and finds the fields on PDF forms. They run on ONNX Runtime with no Python involved.

Nothing here was trained or fine-tuned by us. Each folder is a format conversion of the original weights, or an unchanged copy, and stays under the original author's licence.

Folder Size Use Original weights Licence
deepseek-ocr2-int4/ 2.9 GB PDF to Markdown, CPU or GPU (recommended download) deepseek-ai/DeepSeek-OCR-2 Apache-2.0
deepseek-ocr2-fp16/ 6.6 GB PDF to Markdown, GPU, fastest deepseek-ai/DeepSeek-OCR-2 Apache-2.0
deepseek-ocr2-fp32/ 13 GB Full precision; the source for quantizing deepseek-ai/DeepSeek-OCR-2 Apache-2.0
opus-mt-es-en/ 0.6 GB Spanish to English translation Helsinki-NLP/opus-mt-es-en Apache-2.0
ffdetr/ 125 MB Form field detection jbarrow/FFDetr Apache-2.0
font-classify/ 64 MB Font identification storia/font-classify-onnx MIT

Each folder is self-contained. Download the whole folder and keep the file names: an .onnx file loads its weights from the .onnx.data file beside it.

hf download baker76/ocrtool-models --include "deepseek-ocr2-int4/*" --local-dir models
ocrtool convert in.pdf -o out.md --model models/deepseek-ocr2-int4
ocrtool translate in.pdf -o out.pdf --model models/opus-mt-es-en
ocrtool fonts scan.png -o fonts.json --model models/font-classify
ocrtool form detect flat.pdf -o fillable.pdf --model models/ffdetr

DeepSeek-OCR-2

  • vision_sam_1024.onnx, vision_sam_768.onnx: the SAM stage for the full-page view and the tiles.
  • vision_encoder.onnx: the Qwen2-based encoder and projector.
  • decoder.onnx: token embedding, image-feature merge, the 12-layer decoder with a key/value cache, and the output head. The mixture-of-experts routing is evaluated densely (all experts, masked to the top 6), which gives the same result as the original sparse routing.
  • tokenizer.json, config.json: tokenizer and the prompt token ids.

On one test page the fp32 export reproduced the PyTorch model's output token for token; the fp16 export produced the same text with two bounding-box coordinates differing by 1.

deepseek-ocr2-int4 is the fp32 export with the decoder's weights stored in 4 bits and the vision encoder's in 8 (ONNX Runtime MatMulNBits); the two SAM graphs are unchanged. On four test pages its text matched the fp16 model's apart from a few formatting differences. It decodes more slowly than fp16 on a GPU (about 50 against 80 tokens per second on an RTX 4090).

OPUS-MT

encoder.onnx and decoder.onnx (no cache; the decoder is re-run each step), with the original source.spm, target.spm and vocab.json. Logits match PyTorch to within 1e-5.

Font classifier

An unmodified copy of storia/font-classify-onnx at revision 86a4e77: an EfficientNet-B3 fine-tuned by Storia on synthetic images of about 3,470 Google Fonts. model.onnx takes one 320 x 320 image; model_config.yaml lists the class names and fonts_mapping.yaml the font file behind each class. google_fonts_mapping.tsv, from Storia's training repository, maps each class to the family name and variant used by Google Fonts.

Form field detector

FFDetr, the RF-DETR Medium detector trained by Joe Barrow on the CommonForms dataset, exported with RF-DETR 1.12 at its training resolution of 1024 x 1024. model.onnx returns 300 boxes (dets, centre and size as fractions of the page) and their class logits (labels); only the first three logits are trained classes: text box, choice button and signature. config.json holds the normalisation and the default score threshold (0.4). On page 1 of the IRS W-9 the export finds the same 25 fields as the PyTorch model.

The scripts that produced the exported files are in the ocrtool repository under tools/export/.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for baker76/ocrtool-models

Quantized
(10)
this model