Folio SBB Print OCR
Transcribe historical printed lines from a scan or a PAGE layout on a CPU. The 5.34 MB ONNX reader produces a diplomatic transcription that preserves historical glyphs, including the private-use ligatures in Berlin State Library’s OCR-D ground truth. The PAGE command also writes a search copy that expands familiar ligatures such as ch and ct into ordinary letters.
On 1,393 masked lines from twelve Berlin catalogue works held out of fine-tuning, this model made 2,429 edits in 65,800 reference characters (3.69%). Mannheim frak2021 achieved 15.72% in its best tested setting. With common glyphs expanded on both sides of the comparison, the rates were 3.50% and 6.19%. On the separate RIDGES and DTA19 book benchmarks, Mannheim and the parent Folio Early reader both performed better. Per-work scores and all tested modes · Results on other books
Read a line or a segmented page
python -m pip install huggingface_hub
hf download foliokestrel/folio-sbb-print-ocr --local-dir sbb-reader
cd sbb-reader
python -m pip install -r requirements.txt
python folio_fraktur.py examples/line.png
python read_page.py examples/layout.xml --output readings.tsv

The example page contains 27 line polygons and has its transcriptions removed. The TSV gives the XML path, region ID, line ID, diplomatic reading and search copy for each line. On the pictured line the search copy reads cri codicis locis manifestum est. Adducta ea sunt et explanata in. The reference spells locïs with a diaeresis, which the model missed. Original work, line ID and exact Unicode strings
For your own layout, pass one or more PAGE XML paths. Each XML points to its raster using imageFilename. For a separately stored image, use python read_page.py layout.xml --image scan.tif --output readings.tsv. A page needs horizontal TextLine polygons in TextRegion elements. The TSV follows the source region and line order and retains IDs for joining against a catalogue or annotation tool. Raster dimensions are checked before recognition. For cropped line images, the Python runtime can reuse one model session.
from PIL import Image
from folio_fraktur import FrakturReader
from search_text import search_text
reader = FrakturReader(".")
with Image.open("examples/line.png") as image:
diplomatic = reader(image)
print(diplomatic)
print(search_text(diplomatic))
Search and compare on your own collection
The two text fields support different uses. For example, the diplomatic field uses U+F502 for a joined ch. The search copy expands that character to ch, folds long ſ to s and represents a vowel with a superscript e as an umlaut. It preserves unlisted private-use characters and historical spellings. Search folding is a small documented set of substitutions. Search transformations · OCR-D encoding table
In an exact-token search test on the twelve works, we took 494 reference words of at least four characters that occurred in at least two works. Searching the diplomatic predictions found 1,533 of 2,600 relevant word–line pairs (59.0%). Searching the expanded copy found 2,372 (91.2%). It returned seven additional pairs absent from the transcribed references. These are searches derived from the test transcriptions. Query definitions, counts and scores · Search evaluation code
For a local comparison, make a UTF-8 TSV with image and reference columns and an optional group column. Image paths are relative to the TSV. With transcribed PAGE XML, the included sample exporter will create the TSV and masked PNGs. The comparison command reports strict CER, search CER and complete line matches. To include Mannheim, install its optional native binding and traineddata following the training guide. The default native mode here is raw-line. Mannheim download and checksum
PYTHONPATH=. python training/page_sample.py my-transcribed-page.xml --mask --output my-lines
python compare_lines.py my-lines/sample.tsv --folio SBB . --report local-scores.json
python compare_lines.py my-lines/sample.tsv --folio SBB . \
--tesseract Mannheim frak2021 --tessdata tessdata --tesseract-psm raw-line
Accuracy and limits
Strict CER is the number of character substitutions, insertions and deletions divided by the number of reference characters, after NFC and whitespace normalization. The search column applies the same additional glyph expansions to both predictions and references. Every reader received the same masked grayscale crops in the frozen comparison. The resize rows are a subsequent input sensitivity check. A lower CER is better.
| Reader and setting | Strict CER | Search CER | Exact diplomatic lines / 1,393 | Empty readings |
|---|---|---|---|---|
| Folio SBB Print OCR | 3.69% | 3.50% | 590 | 0 |
| Mannheim frak2021, raw line | 15.72% | 6.19% | 123 | 2 |
| Mannheim, raw line resized to 48 px with white margins | 25.77% | 19.75% | 88 | 2 |
| Mannheim, single line resized to 48 px with white margins | 27.00% | 19.00% | 115 | 153 |
| Mannheim, single line at source size | 32.25% | 24.68% | 117 | 201 |
| Folio Early | 39.58% | 32.01% | 31 | 4 |
The source-size raw-line comparison followed inspection of empty outputs in the original single-line setting. It improved Mannheim’s result considerably. Folio SBB still had lower strict CER on each of the twelve works. Giving each work equal weight, strict CER was 3.81% for Folio SBB and 15.58% for Mannheim raw-line. The Folio alphabet omitted 29 distinct test characters, accounting for 53 occurrences. The source collection contains multiple languages and typefaces. This evaluation measures recognition of annotated lines. It supplies no accuracy estimate for finding those lines on a new page. Frozen comparison and unseen characters · Diplomatic references and predictions
Transfer depends on both the scan and its transcription convention. On the four reserved RIDGES books (2,017 lines), strict CER was 13.72% for Folio SBB, 1.10% for Folio Early and 0.85% for Mannheim single-line. On DTA19 (1,344 lines), the corresponding rates were 11.85%, 0.60% and 0.52%. For Folio SBB, expanding glyphs lowered its transfer CER to 3.54% and 2.76% respectively. Transfer measurements
Training and rights
Folio Kestrel fine-tuned the Folio Early reader on masked line crops from 45 SBB works. Another eight works determined the choice of checkpoint. All twelve test works were held out of fine-tuning and checkpoint selection. An earlier baseline study had examined a different page from each of the test works. All pages used in that study were excluded from this trial. The supplied CPU reader reproduced 774 of 775 validation strings from GPU decoding. Starting with the original TIFFs and PAGE polygons reproduced all 1,393 recorded CPU test predictions across 78 pages. Training recipe and work splits · PAGE replay
The Berlin ground truth and scans are from OCR-D-GT-VD-SBB, published by Staatsbibliothek zu Berlin. Zenodo credits Konstantin Baierer, Maria Federbusch, Mike Gerber, Jörg Lehmann and Clemens Neudecker. Folio Kestrel removed transcriptions and word/glyph elements from the example layout, renamed the image reference and cropped the example line. The example TIFF retains its original bytes. The source images, SBB labels and SBB-derived evaluation tables use CC BY 4.0. The fine-tuned weights inherit CC BY-SA 4.0 from the Folio Early initializer trained on GT4HistOCR. The GT4HistOCR transfer table also uses CC BY-SA 4.0. The contributed code uses Apache 2.0. Berlin source · SBB data license · GT4HistOCR source · Original source notice · Weight license · Code license