Skip to content
ModelListedExternal
Download

Vit Historical Page

Scope: Processing of images, training and evaluation of ViT model, input file/directory processing, class 🏷️ (category) results of top N predictions output, predictions summarizing into a tabular format, HF 😊 hub...

KindOtherBase modelgoogle/vit-base-patch16-224VersionRevision 543216dBgrade

Model source

Kind
Other
File size
308 MB
Base model
google/vit-base-patch16-224
Version
vRevision 543216d
Updated
Sep 17, 2026
Downloads
67
Source
Hugging Face

Source description

Image classification using fine-tuned ViT - for historical :bowtie: documents sorting

Goal: solve a task of archive page images sorting (for their further content-based processing)

Scope: Processing of images, training and evaluation of ViT model, input file/directory processing, class 🏷️ (category) results of top N predictions output, predictions summarizing into a tabular format, HF 😊 hub support for the model

Versions 🏁

There are currently 2 version of the model available for download, both of them have the same set of categories, but different data annotations. The latest v4.3 is considered to be default and can be found in the main branch of HF 😊 hub [^1] πŸ”—

VersionBasePagesPDFsDescription
v2.0vit-base-patch16-224100733896annotations with mistakes, more heterogenous data
v2.1vit-base-patch16-224119405002main: more diverse pages in each category, less annotation mistakes
v2.2vit-base-patch16-224158555730same data as v2.1 + some restored pages from v2.0
v3.2vit-base-patch16-384158555730same data as v2.2, but a bit larger model base with higher resolution
v5.2vit-large-patch16-384158555730same data as v2.2, but the largest model base with higher resolution
v1.2efficientnetv2_s.in21k158555730same data as v2.2, but the smallest model base (CNN)
v4.2efficientnetv2_l.in21k_ft_in1k158555730same data as v2.2, CNN base model smaller than the largest, may be more accurate
v2.3vit-base-patch16-2243862537328new data annotation phase data, more single-page documents used, transformer model
v3.3vit-base-patch16-3843862537328same data as v2.3, but a bit larger model base with higher resolution
v5.3vit-large-patch16-3843862537328same data as v2.3, but the largest model base with higher resolution
v1.3efficientnetv2_m.in21k_ft_in1k3862537328same data as v2.3, but the smallest model base (CNN)
v4.3regnety_160.swag_ft_in1k3862537328same data as v2.3, CNN base model bigger than the smallest, may be more accurate
v2.4vit-base-patch16-2243830737316only cc-by nc 4 licensed dats samples were kept in vX.4 versions data
v3.4vit-base-patch16-3843830737316same data as v2.4, but a bit larger model base with higher resolution
v5.4vit-large-patch16-3843830737316same data as v2.4, but the largest model base with higher resolution
v1.4efficientnetv2_m.in21k_ft_in1k3830737316same data as v2.4, but the smallest model base (CNN)
v4.4regnety_160.swag_ft_in1k3830737316same data as v2.4, CNN base model bigger than the smallest, may be more accurate
VersionParameters (M)Resolution (px)Revision
efficientnetv2_s.in21k48300v1.X
efficientnetv2_m.in21k_ft_in1k54384v1.3
vit-base-patch16-22487224v2.X
vit-base-patch16-38487384v3.X
regnety_160.swag_ft_in1k84224v4.3
vit-large-patch16-384305384v5.X
regnety_640.seer281384v6.3
Base ModelRevisionmax_catBest_Prec (%)Best_Acc (%)FoldNote
google/vit-base-patch16-224v2.314,00098.7998.795OK & Small
google/vit-base-patch16-384v3.314,00098.9298.922Good & Small
google/vit-large-patch16-384v5.314,00099.1299.122Best & Large
microsoft/dit-base-finetuned-rvlcdipv9.314,00098.7198.723
microsoft/dit-large-finetuned-rvlcdipv10.314,00098.6698.663
microsoft/dit-largev11.314,00098.5398.532
timm/regnety_120.sw_in12k_ft_in1kv12.314,00098.2998.293
timm/regnety_160.swag_ft_in1kv4.314,00099.1799.161Best & Small
timm/regnety_640.seev6.314,00098.7998.795OK & Large
timm/tf_efficientnetv2_l.in21k_ft_in1kv8.314,00098.6298.625
timm/tf_efficientnetv2_m.in21k_ft_in1kv1.314,00098.8398.831Good & Small
timm/tf_efficientnetv2_s.in21kv7.314,00097.9097.871
Ensemble (Best 5 Models)--14,000N/AN/A--Combined

Model description πŸ“‡

architecture.png

πŸ”² Fine-tuned model repository: vit-historical-page [^1] πŸ”—

πŸ”³ Base model repository:

  • Google's vit-base-patch16-224, vit-base-patch16-384, and vit-large-patch16-284 [^2] [^6] [^7] πŸ”—
  • timm's regnety_160.swag_ft_in1k, efficientnetv2_s.in21k, efficientnetv2_m.in21k_ft_in1k, and efficientnetv2_l.in21k_ft_in1k [^11] [^8] [^12] [^9] πŸ”—

Data πŸ“œ

The dataset is provided under Public Domain license, and consists of 48,499 PNG images of pages from 37,328 archival documents. The source image files and their annotation can be found in the LINDAT repository [^10] πŸ”—.

Manual ✍️ annotation was performed beforehand and took some time βŒ›, the categories πŸͺ§ tabulated below were formed from different sources of the archival documents originated in the 1920-2020 years span.

CategoryDataset 0Dataset 1Dataset 2Dataset 3
DRAW1090 (9.1%)1368 (8.8%)1472 (9.3%)2709 (5.6%)
DRAW_L1091 (9.1%)1383 (8.9%)1402 (8.8%)2921 (6.0%)
LINE_HW1055 (8.8%)1113 (7.2%)1115 (7.0%)2514 (5.2%)
LINE_P1092 (9.1%)1540 (9.9%)1580 (10.0%)2439 (5.0%)
LINE_T1098 (9.2%)1664 (10.7%)1668 (10.5%)9883 (20.4%)
PHOTO1081 (9.1%)1632 (10.5%)1730 (10.9%)2691 (5.5%)
PHOTO_L1087 (9.1%)1087 (7.0%)1088 (6.9%)2830 (5.8%)
TEXT1091 (9.1%)1587 (10.3%)1592 (10.0%)14227 (29.3%)
TEXT_HW1091 (9.1%)1092 (7.1%)1092 (6.9%)2008 (4.1%)
TEXT_P1083 (9.1%)1540 (9.9%)1633 (10.3%)2312 (4.8%)
TEXT_T1081 (9.1%)1476 (9.5%)1482 (9.3%)3965 (8.2%)
Unique PDFs50015694572937328
Total Pages11,94015,48215,85448,499

The table above shows category distribution for different model versions, where the last column (Dataset 3) corresponds to the latest vX.3 models data, which actually used 14,000 pages of TEXT category, while other columns cover all the used samples - specifically 80% as training πŸ’ͺ, and 10% each as development and test πŸ† sets. The early model version used 90% of the data as training πŸ’ͺ and the remaining 10% as both development and test πŸ† set due to the lack of annotated (manually classified) pages.

[!NOTE] Disproportion of the categories πŸͺ§ in both training and evaluation data is NOT intentional, but rather a result of the source data nature.

Training set of the model: 8950 images for v2.0

Training set of the model: 10745 images for v2.1

Training set of the model: 14565 images for v2.X

Training set of the model: 38625 images for vX.3

Plus, the test sets:

Evaluation set: 1586 images (taken from v2.2 annotations)

Evaluation set: 4823 images (for vX.3 models)

Categories 🏷️

Label️Description
DRAWπŸ“ˆ - drawings, maps, paintings, schematics, or graphics, potentially containing some text labels or captions
DRAW_LπŸ“ˆπŸ“ - drawings, etc but presented within a table-like layout or includes a legend formatted as a table
LINE_HWβœοΈπŸ“ - handwritten text organized in a tabular or form-like structure
LINE_PπŸ“ - printed text organized in a tabular or form-like structure
LINE_TπŸ“ - machine-typed text organized in a tabular or form-like structure
PHOTOπŸŒ„ - photographs or photographic cutouts, potentially with text captions
PHOTO_LπŸŒ„πŸ“ - photos presented within a table-like layout or accompanied by tabular annotations
TEXTπŸ“° - mixtures of printed, handwritten, and/or typed text, potentially with minor graphical elements
TEXT_HWβœοΈπŸ“„ - only handwritten text in paragraph or block form (non-tabular)
TEXT_PπŸ“„ - only printed text in paragraph or block form (non-tabular)
TEXT_TπŸ“„ - only machine-typed text in paragraph or block form (non-tabular)

dataset_timeline.png

Data preprocessing

During training the following transforms were applied randomly with a 50% chance:

  • transforms.ColorJitter(brightness 0.5)
  • transforms.ColorJitter(contrast 0.5)
  • transforms.ColorJitter(saturation 0.5)
  • transforms.ColorJitter(hue 0.5)
  • transforms.Lambda(lambda img: ImageEnhance.Sharpness(img).enhance(random.uniform(0.5, 1.5)))
  • transforms.Lambda(lambda img: img.filter(ImageFilter.GaussianBlur(radius=random.uniform(0, 2))))

Training Hyperparameters

  • eval_strategy "epoch"
  • save_strategy "epoch"
  • learning_rate 5e-5
  • per_device_train_batch_size 8
  • per_device_eval_batch_size 8
  • num_train_epochs 3
  • warmup_ratio 0.1
  • logging_steps 10
  • load_best_model_at_end True
  • metric_for_best_model "accuracy"

Results πŸ“Š

RevisionTop-1Top-3
v1.297.7399.87
v2.297.5499.94
v3.296.4999.94
...

Sources

1 source
Hugging FacePrimaryVersion 543216d6b7e12552b164372e9124ceb168b06b98
huggingface.co/ufal/vit-historical-page/tree/543216d6b7e12552b164372e9124ceb168b06b98

Verified Sep 3

Model artifacts

1 artifact

model.safetensors

safetensors Β· 308 MB Β· SHA-256 6b18e89783df…0ea1 Β· Hugging Face

Download

Source excerpts

2 excerpts

--- library_name: transformers tags: - page - classification - timm base_model: - google/vit-base-patch16-224 - google/vit-base-patch16-384 - google/vit-large-patch16-384 pipeline_tag: image-classification license: mit --- # Image classification using fine-tuned ViT - for historical :bowtie: documents sorting ### Goal: solve a task of archive page images sorting (for their further content-based processing) **Scope:** Processing of images, training and evaluation of ViT model, input file/directory processing, class 🏷️ (category) results of top N predictions output, predictions summarizing into a tabular format, HF 😊 hub support for the model ## Versions 🏁 There are currently 2 version of the model available for download, both of them have the same set of categories, but different data annotations. The latest `v4.3` is considered to be default and can be found in the `main` branch of HF 😊 hub [^1] πŸ”— | Version | Base | Pages | PDFs | Description | |--------:|------------------------------------|:-----:|:---------:|:-----------------------------------------------------------------------------------| | `v2.0` | `vit-base-patch16-224` | 10073 | **3896** | annotations with mistakes, more heterogenous data | | `v2.1` | `vit-base-patch16-224` | 11940 | **5002** | `main`: more diverse pages in each category, less annotation mistakes | | `v2.2` | `vit-base-patch16-224` | 15855 | **5730** | same data as `v2.1` + some restored pages from `v2.0` | | `v3.2` | `vit-base-patch16-384` | 15855 | **5730** | same data as `v2.2`, but a bit larger model base with higher resolution | | `v5.2` | `vit-large-patch16-384` | 15855 | **5730** | same data as `v2.2`, but the largest model base with higher resolution | | `v1.2` | `efficientnetv2_s.in21k` | 15855 | **5730** | same data as `v2.2`, but the smallest model base (CNN) | | `v4.2` | `efficientnetv2_l.in21k_ft_in1k` | 15855 | **5730** | same data as `v2.2`, CNN base model smaller than the largest, may be more accurate | | `v2.3` | `vit-base-patch16-224` | 38625 | **37328** | new data annotation phase data, more single-page documents used, transformer model | | `v3.3` | `vit-base-patch16-384` | 38625 | **37328** | same data as `v2.3`, but a bit larger model base with higher resolution | | `v5.3` | `vit-large-patch16-384` | 38625 | **37328** | same data as `v2.3`, but the largest model base with higher resolution | | `v1...

Source context: 67 downloads Β· 4 likes Β· Pipeline image-classification Β· Library transformers Β· Repo ufal/vit-historical-page