@@ -192,16 +192,8 @@ const json = await convertFileAsync('report.docx', { to: 'json' })
192192
193193Declarative formats (Markdown, HTML, DOCX, XLSX, …) work out of the box. The
194194PDF/image pipeline needs pdfium + the ONNX models (not bundled), so it throws
195- until you fetch them — a one-liner from your app's directory (pdfium and OCR
196- from their own upstream releases; the layout model and TableFormer —
197- PyTorch→ONNX exports of docling-project's own models,
198- Apache-2.0/CDLA-Permissive-2.0, see [ ` MODELS_NOTICE.md ` ] ( ./MODELS_NOTICE.md ) —
199- from fleischwolf's own hosted release), straight into ` ./models ` and
200- ` ./.pdfium ` , which the package looks for by default — no env vars needed:
201-
202- ``` bash
203- curl -fsSL https://raw.githubusercontent.com/artiz/fleischwolf/master/scripts/download_dependencies.sh | sh
204- ```
195+ until you fetch them with ` scripts/download_dependencies.sh ` — see
196+ [ Getting the ML models] ( #getting-the-ml-models ) below.
205197
206198A reusable ` Pipeline ` keeps those models warm across many PDFs.
207199
@@ -211,6 +203,68 @@ Runnable Node + Bun examples are in
211203[ ` crates/fleischwolf-node/README.md ` ] ( ./crates/fleischwolf-node/README.md ) for
212204the full API.
213205
206+ ## Getting the ML models
207+
208+ The PDF/image pipeline needs native assets that aren't bundled in the crate or
209+ the npm addon: [ pdfium] ( https://pdfium.googlesource.com/pdfium/ ) (text
210+ extraction + page rendering) and three ONNX models — RT-DETR layout, PP-OCRv3
211+ recognition, and TableFormer (optional; tables fall back to geometric
212+ reconstruction without it). ` scripts/download_dependencies.sh ` fetches all of
213+ them from this repo's [ GitHub Releases] ( https://github.com/artiz/fleischwolf/releases )
214+ (tag ` models-v1 ` ) straight into ` ./models ` and ` ./.pdfium ` , relative to the
215+ current directory — both the Rust CLI/library and the Node.js/Bun bindings
216+ look there by default, so no env vars or extra setup are needed afterwards:
217+
218+ ``` bash
219+ # from a checkout of this repo, or any directory you'll run fleischwolf from:
220+ scripts/download_dependencies.sh
221+
222+ # or, without a checkout — e.g. a container build step, or a fresh npm project:
223+ curl -fsSL https://raw.githubusercontent.com/artiz/fleischwolf/master/scripts/download_dependencies.sh | sh
224+ ```
225+
226+ | Asset | Destination |
227+ | --- | --- |
228+ | pdfium (Linux x64) | ` .pdfium/lib/libpdfium.so ` |
229+ | RT-DETR layout | ` models/layout_heron.onnx ` |
230+ | PP-OCRv3 rec + dictionary | ` models/ocr_rec.onnx ` , ` models/ppocr_keys_v1.txt ` |
231+ | TableFormer (optional) | ` models/tableformer/{encoder,decoder,bbox}.onnx ` (+ ` .data ` sidecars where the export needs them) |
232+
233+ Idempotent — safe to re-run; it skips files already on disk. Pass ` --force ` to
234+ re-fetch everything, or set ` $FLEISCHWOLF_MODELS_URL ` to fetch from a
235+ different host (your own export, an internal mirror, …). pdfium is Linux x64
236+ only for now — other platforms, or building the models from source, need
237+ [ ` scripts/pdf_setup.sh ` ] ( #testing ) instead.
238+
239+ Then either:
240+
241+ ``` bash
242+ cargo run -p fleischwolf-cli -- document.pdf
243+ ```
244+
245+ or, in a Node.js/Bun app:
246+
247+ ``` bash
248+ npm i fleischwolf
249+ ```
250+
251+ ``` js
252+ import { convertFileAsync } from ' fleischwolf'
253+ const { content } = await convertFileAsync (' document.pdf' , { to: ' markdown' })
254+ console .log (content)
255+ ```
256+
257+ The layout model and TableFormer are PyTorch→ONNX exports of docling-project's
258+ own models (Apache-2.0 / CDLA-Permissive-2.0 — see
259+ [ ` MODELS_NOTICE.md ` ] ( ./MODELS_NOTICE.md ) for full attribution); pdfium and the
260+ OCR model are re-hosted, unmodified, from their own public releases — all on
261+ one host for convenience.
262+
263+ To point at files you exported or placed elsewhere instead, set the env vars
264+ directly: ` DOCLING_LAYOUT_ONNX ` , ` DOCLING_OCR_REC_ONNX ` , ` DOCLING_OCR_DICT ` ,
265+ ` DOCLING_TABLEFORMER_{ENCODER,DECODER,BBOX} ` , ` PDFIUM_DYNAMIC_LIB_PATH ` — an
266+ env var always wins over the ` ./models ` / ` ./.pdfium ` default.
267+
214268## Testing
215269
216270All commands run from the ` fleischwolf/ ` workspace root.
@@ -268,8 +322,7 @@ cargo run -p fleischwolf-cli -- --strict crates/fleischwolf/sample.html
268322cargo run -p fleischwolf-cli -- --to json crates/fleischwolf/sample.html
269323cargo run -p fleischwolf-cli -- --to json crates/fleischwolf/sample.html > out.json
270324
271- # PDF/image conversion needs the ML models: scripts/download_dependencies.sh once,
272- # then it just works — models/ and .pdfium/lib are picked up automatically.
325+ # PDF/image conversion needs the ML models — see "Getting the ML models" above.
273326scripts/download_dependencies.sh
274327cargo run -p fleischwolf-cli -- document.pdf
275328
0 commit comments