Spread Classifier: two-page spread or single page
Decides whether a scan shows a two-page spread of a bound book or register, or a single page or sheet. Spreads can then be cut into two pages before layout analysis and text recognition.
Works in a pair with Zhnivo/spread-gutter-locator: this model finds the spreads, the gutter locator finds the line where each spread should be cut into two pages.
Released by Zhnivo, a non-profit project preserving the archival heritage of Belarus.
Model
| Architecture | EfficientNet-B0 (torchvision) with a single-logit head |
| Input | RGB scan, longest side 512 px, centred on a gray (128) 512ร512 square, ImageNet normalisation |
| Output | logit that the scan is a two-page spread |
| Recommended threshold | logit > 4.5 means spread (lower it to find more spreads at the cost of more false cuts) |
| Hardware and speed | runs on an ordinary CPU, no GPU needed: about 5 scans per second (around 17,000 an hour) on a laptop CPU (AMD Ryzen 7, 6 threads), including reading the scans |
| Files | model.safetensors, config.json, inference.py |
Training data
Trained on several thousand scans of printed and handwritten books, registers and archival files, mostly from the 19th and 20th centuries: two-page spreads and single pages or sheets, including large tables and forms. Validation scans come from other books than the training scans.
Usage
pip install torch torchvision safetensors pillow numpy huggingface_hub
from huggingface_hub import snapshot_download
import sys
folder = snapshot_download("Zhnivo/spread-classifier")
sys.path.insert(0, folder)
from inference import load_model, predict
model, cfg = load_model(folder)
for z in predict(["scan.jpg"], model, cfg):
print(z, "spread" if z > cfg["recommended_logit_threshold"] else "single")
Prepare the input exactly as inference.py does: no stretching, gray padding.
Limitations
- Built for scans and photos of archival books, registers and files. Other images are out of scope.
- Large single sheets folded or creased in the middle (wide tables) are the most common false spreads.
- The model only says whether to cut, not where.
License and attribution
MIT, free for any use. If you use the model, a link to the project zhnivo.com is appreciated.
- Downloads last month
- 52