Add model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: onnx
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
pipeline_tag: image-text-to-text
|
| 5 |
+
tags:
|
| 6 |
+
- onnx
|
| 7 |
+
- ocr
|
| 8 |
+
- translation
|
| 9 |
+
- pdf
|
| 10 |
+
base_model:
|
| 11 |
+
- deepseek-ai/DeepSeek-OCR-2
|
| 12 |
+
- Helsinki-NLP/opus-mt-es-en
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# pdftool models
|
| 16 |
+
|
| 17 |
+
ONNX exports of the models used by [pdftool](https://github.com/benbaker76/pdftool), a C++ command-line
|
| 18 |
+
tool that converts PDFs to Markdown and translates PDFs in place. They run on ONNX Runtime with no
|
| 19 |
+
Python involved.
|
| 20 |
+
|
| 21 |
+
Nothing here was trained or fine-tuned by us. Each folder is a format conversion of the original
|
| 22 |
+
weights and stays under the original author's licence.
|
| 23 |
+
|
| 24 |
+
| Folder | Size | Use | Original weights | Licence |
|
| 25 |
+
| --- | --- | --- | --- | --- |
|
| 26 |
+
| `deepseek-ocr2-fp16/` | 6.6 GB | PDF to Markdown, GPU | [deepseek-ai/DeepSeek-OCR-2](https://huggingface.co/deepseek-ai/DeepSeek-OCR-2) | Apache-2.0 |
|
| 27 |
+
| `deepseek-ocr2-fp32/` | 13 GB | PDF to Markdown, CPU | [deepseek-ai/DeepSeek-OCR-2](https://huggingface.co/deepseek-ai/DeepSeek-OCR-2) | Apache-2.0 |
|
| 28 |
+
| `opus-mt-es-en/` | 0.6 GB | Spanish to English translation | [Helsinki-NLP/opus-mt-es-en](https://huggingface.co/Helsinki-NLP/opus-mt-es-en) | Apache-2.0 |
|
| 29 |
+
|
| 30 |
+
Each folder is self-contained. Download the whole folder and keep the file names: an `.onnx` file
|
| 31 |
+
loads its weights from the `.onnx.data` file beside it.
|
| 32 |
+
|
| 33 |
+
```sh
|
| 34 |
+
hf download baker76/pdftool-models --include "deepseek-ocr2-fp16/*" --local-dir models
|
| 35 |
+
pdftool convert in.pdf -o out.md --model models/deepseek-ocr2-fp16
|
| 36 |
+
pdftool translate in.pdf -o out.pdf --model models/opus-mt-es-en
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
## DeepSeek-OCR-2
|
| 40 |
+
|
| 41 |
+
- `vision_sam_1024.onnx`, `vision_sam_768.onnx`: the SAM stage for the full-page view and the tiles.
|
| 42 |
+
- `vision_encoder.onnx`: the Qwen2-based encoder and projector.
|
| 43 |
+
- `decoder.onnx`: token embedding, image-feature merge, the 12-layer decoder with a key/value cache,
|
| 44 |
+
and the output head. The mixture-of-experts routing is evaluated densely (all experts, masked to
|
| 45 |
+
the top 6), which gives the same result as the original sparse routing.
|
| 46 |
+
- `tokenizer.json`, `config.json`: tokenizer and the prompt token ids.
|
| 47 |
+
|
| 48 |
+
On one test page the fp32 export reproduced the PyTorch model's output token for token; the fp16
|
| 49 |
+
export produced the same text with two bounding-box coordinates differing by 1.
|
| 50 |
+
|
| 51 |
+
## OPUS-MT
|
| 52 |
+
|
| 53 |
+
`encoder.onnx` and `decoder.onnx` (no cache; the decoder is re-run each step), with the original
|
| 54 |
+
`source.spm`, `target.spm` and `vocab.json`. Logits match PyTorch to within 1e-5.
|
| 55 |
+
|
| 56 |
+
The scripts that produced these files are in the pdftool repository under `tools/export/`.
|