Page Type Classifier: printed or not printed

Classifies a full scanned page of an archival document:

  • printed: the page is printed or typewritten (a signature, page number or short handwritten note is fine);
  • not_printed: handwriting, or printed forms and tables filled in by hand.

Useful for routing pages to a printed-text OCR engine or to a handwriting (HTR) model.

Released by Zhnivo, a non-profit project preserving the archival heritage of Belarus.

Model

Architecture EfficientNet-B0 (torchvision), 2-class head
Input grayscale page, longest side 512 px, centred on a white 512ร—512 square, ImageNet normalisation (gray copied to 3 channels)
Output probability that the page is printed
Recommended threshold 0.9 (raise it to 0.98 if false "printed" answers are costly)
Hardware and speed runs on an ordinary CPU, no GPU needed: about 6-7 pages per second (over 20,000 pages 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 scanned pages of archival documents from the 18th to 20th centuries, mostly Cyrillic and Latin script (Russian in pre-reform and modern spelling, Belarusian, Polish, German). Pages include printed books and newspapers, typewritten documents, handwritten registers and files, and printed forms filled in by hand. Validation pages come from other books and files than the training pages.

Usage

pip install torch torchvision safetensors pillow numpy huggingface_hub
from huggingface_hub import snapshot_download
import sys

folder = snapshot_download("Zhnivo/page-type-classifier")
sys.path.insert(0, folder)
from inference import load_model, predict

model, cfg = load_model(folder)
for p in predict(["page.jpg"], model, cfg):
    print(p, "printed" if p >= cfg["recommended_threshold"] else "not_printed")

Prepare the input exactly as inference.py does: no stretching, white padding.

Limitations

  • Built for scans and photos of archival pages (books, registers, files). Other images are out of scope.
  • One answer per page: a page that is half printed and half handwritten gets a single label.

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
34
Safetensors
Model size
4.05M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support