--- license: cc-by-4.0 library_name: pytorch pipeline_tag: image-classification inference: false tags: - multiple-instance-learning - attention - interpretability - digital-humanities - historical-documents - korean - timm --- # Visual Feature Discovery for Colonial Korean Print: trained weights These are the trained models from the article below. They classify a scanned page from a colonial-era Korean periodical by the printshop that printed it, over four classes: 대동인쇄소, 신문관, 조선인쇄 주식회사 and 한성도서 주식회사. van de Pol, A., Prokic, J., & Mol, A. (2026). Interpretable visual feature discovery using multiple instance learning: A case study of colonial Korean print. *Computational Humanities Research*, 2, e22. https://doi.org/10.1017/chr.2026.10036 This repository is a mirror of the weights. The citable archive is the Zenodo record [10.5281/zenodo.20015055](https://doi.org/10.5281/zenodo.20015055), which also holds the dataset metadata, the fold definitions and the patch-embedding and cluster files. The code is at [aronvandepol/visual-feature-discovery](https://github.com/aronvandepol/visual-feature-discovery). ## Files | Files | Model | Evaluation protocol | Size each | |---|---|---|---:| | `attrimil_p16s8_flash_fold{0-4}.pth` | AttriMIL, 16x16 patches, stride 8 | held-out book (GroupKFold) | 12 MB | | `attrimil_p8s4_flash_fold{0-4}.pth` | AttriMIL, 8x8 patches, stride 4 | held-out book (GroupKFold) | 12 MB | | `convnextv2_base_book_split_fold{0-4}.pth` | ConvNeXtV2 Base, full page at 896x896 | held-out book (GroupKFold) | 351 MB | | `convnextv2_base_page_split_fold{0-4}.pth` | ConvNeXtV2 Base, full page at 896x896 | page-random (KFold) | 351 MB | | `swin_s3_base_224_book_split_fold{0-4}.pth` | Swin S3 Base 224, text-only page cutouts | held-out book (GroupKFold) | 282 MB | | `swin_s3_base_224_page_split_fold{0-4}.pth` | Swin S3 Base 224, text-only page cutouts | page-random (KFold) | 282 MB | Each `.pth` file is the best checkpoint of its fold by validation loss, with the optimizer state removed. It holds `state_dict`, `hyper_parameters`, `epoch` and `pytorch-lightning_version`. `eval/` has the per-fold results behind the table below. `ZENODO_ASSETS.md` lists the SHA-256 checksum and best epoch of every weight file. ## Results Five-fold mean accuracy with sample standard deviation, computed from the per-fold files in `eval/`. The means are those of the article's comparison table. The article prints different standard deviations for the two baselines. | Model | Held-out book | Page-random | |---|---:|---:| | AttriMIL 16x16, stride 8 | 84.52 ± 2.19% | | | AttriMIL 8x8, stride 4 | 83.60 ± 3.24% | | | ConvNeXtV2 Base | 81.98 ± 2.40% | 98.05 ± 0.24% | | Swin S3 Base 224 | 84.11 ± 1.81% | 98.15 ± 0.17% | The held-out-book column is the one to read. Under page-random splits, pages of one book fall on both sides of the split, and the baselines score 14 to 16 points higher. ## Loading The checkpoints need the model classes from the code repository. ```python # run from a checkout of aronvandepol/visual-feature-discovery import torch from huggingface_hub import hf_hub_download from src.models.lightning_attrimil import LightningAttriMIL path = hf_hub_download("aronvandepol/visual-feature-discovery", "attrimil_p8s4_flash_fold0.pth") ckpt = torch.load(path, map_location="cpu", weights_only=True) model = LightningAttriMIL(**ckpt["hyper_parameters"]) model.load_state_dict(ckpt["state_dict"]) model.eval() ``` The baselines are plain `timm` models. Their keys carry a `model.` prefix from the Lightning wrapper (`LightningTIMM` in `src/models/lightning_timm.py`). ```python import timm, torch from huggingface_hub import hf_hub_download path = hf_hub_download("aronvandepol/visual-feature-discovery", "convnextv2_base_book_split_fold0.pth") ckpt = torch.load(path, map_location="cpu", weights_only=True) hp = ckpt["hyper_parameters"] net = timm.create_model(hp["model_name"], pretrained=False, num_classes=hp["num_classes"]) net.load_state_dict({k.removeprefix("model."): v for k, v in ckpt["state_dict"].items()}) net.eval() ``` ## Data The page images come from the Hyundam Mun'go collection (formerly Adan Mungo) and the corpus is not redistributed here or on Zenodo. Ten sample pages for testing ship with the code. The Zenodo record's `dataset_metadata.parquet` gives the catalog link of each of the 57,583 pages. ## License The weights are released under CC-BY-4.0. The code is under the MIT License.