folio-newspaper-line-detector
text line detector for historical newspapers
2 min readupdated
This lightweight ONNX-based model finds horizontal text lines on newspaper page scans (in TIFF, PNG, or JPEG formats) and runs on a standard CPU. It outputs bounding box coordinates for each line and can export annotations in PAGE XML format, which is convenient for downstream text correction or optical character recognition (OCR). The model weights weigh only about 2 MB, and running it requires Python and the basic Hugging Face Hub library. The tool will be useful for archive researchers, historians, and developers of print digitization systems.
Key features
- Runs on a CPU without requiring powerful graphics cards.
- Exports results to the standard PAGE XML format for integration with OCR systems.
- Returns exact bounding box coordinates in the original image resolution.
- Compact weight size (2.03 MB) and fast execution speed (less than a second per page).
What you can do
- Automatically find and highlight text lines on scanned newspaper pages.
- Create PAGE XML files for subsequent text recognition in combination with compatible OCR models.
- Generate images with overlaid boxes of detected lines for visual quality inspection of the layout.
Example
python -m pip install huggingface_hub
hf download foliokestrel/folio-newspaper-line-detector model.onnx config.json detect_lines.py geometry.py requirements.txt examples/newspaper.tif --local-dir newspaper-lines
cd newspaper-lines
python -m pip install -r requirements.txt
python detect_lines.py examples/newspaper.tif --overlay preview.png > boxes.json
Read more
DetailsArchitecture: convolutional detector with 506,083 parameters, trained from scratch.
Performance: achieved an F1 score of 83.78% on Austrian test pages (compared to 71.40% for standard Tesseract).
Limitations: does not determine article boundaries or reading order in adjacent columns.
License: weights, examples, and data are distributed under CC BY 4.0, code under Apache 2.0.










Comments