HAT SRx4 Engravings
Fine-tuned HAT base model for 4x super-resolution of historical engravings and black-and-white printed illustrations.
The selected checkpoint corresponds to 5,000 fine-tuning iterations. The recommended inference file is net_g_best.safetensors, which contains only the params_ema model weights. The original BasicSR/HAT checkpoint is also preserved as net_g_best.pth.
Visual tests on held-out historical illustrations showed clear improvement over the base pretrained model, with no meaningful visible gains from later checkpoints up to 50,000 iterations.
Visual Comparison
The sheet below compares traditional interpolation, the base HAT SRx4 ImageNet-pretrained model, and the selected fine-tuned checkpoint on held-out historical illustrations.
Model
- Architecture: HAT base
- Scale: 4x
- Base checkpoint:
HAT_SRx4_ImageNet-pretrain.pth - Fine-tuning checkpoint:
net_g_5000.pth - Published checkpoint names:
net_g_best.safetensors,net_g_best.pth - Parameter key:
params_ema - Training loss: L1
- Training framework: BasicSR + HAT
- License: Apache License 2.0
This is a fine-tuned checkpoint for the original HAT architecture, not a new model architecture. Cite and refer to the upstream project when reusing it:
- Original repository: https://github.com/XPixelGroup/HAT
- Paper: Activating More Pixels in Image Super-Resolution Transformer, CVPR 2023
- Authors: Xiangyu Chen, Xintao Wang, Jiantao Zhou, Yu Qiao, and Chao Dong
Intended Use
This model is intended for visual upscaling of scanned engravings, line art, and historical printed illustrations. It is not a factual restoration model and should not be used as evidence that details were present in the original print.
Limitations
- May alter or regularize micro-textures in dense hatching.
- May sharpen paper noise or scanning artifacts.
- Not trained for colorized engravings, photographs, handwriting, or modern raster graphics.
- Visual inspection is recommended before production use.
Files
net_g_best.safetensors # recommended inference weights, params_ema only
net_g_best.pth # original BasicSR/HAT checkpoint with params and params_ema
train_config.yml # training configuration used for the fine-tune
inference.py # tiled inference helper
checkpoints/ # historical numbered checkpoints from training
Inference
This repository contains the selected checkpoint and a tiled inference helper. The script expects the HAT/BasicSR environment used during training, with HAT available through the HAT_PATH environment variable or in a local hat/ folder next to inference.py.
Use net_g_best.safetensors when a loader supports HAT safetensors directly. It stores only the final params_ema tensors and avoids Python pickle serialization. Use net_g_best.pth with the provided inference.py helper or BasicSR/HAT tooling that expects the original checkpoint format.
Install the Python dependencies, clone the original HAT repository, and point HAT_PATH to it:
git clone https://github.com/XPixelGroup/HAT.git
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -r requirements.txt
$env:HAT_PATH="C:\path\to\HAT"
Example:
python inference.py `
--input path\to\images `
--output path\to\output `
--checkpoint net_g_best.pth `
--tile-size 128 `
--tile-pad 16
For large scans, tiled inference is recommended to avoid exhausting VRAM. The script processes images serially.
ComfyUI
The recommended ComfyUI file is net_g_best.safetensors. It is a HAT/BasicSR state dict containing the params_ema weights. It is not a Stable Diffusion upscaler checkpoint.
To try it in ComfyUI, place net_g_best.safetensors in:
ComfyUI/models/upscale_models/
Then use the standard upscale workflow with Load Image, UpscaleModelLoader, ImageUpscaleWithModel, and Save Image.
If ComfyUI does not recognize the file, update ComfyUI and its upscale-model dependencies, especially spandrel and spandrel-extra-arches. If it still does not recognize the file, the installed upscale backend does not support this exact HAT checkpoint format. In that case, use inference.py from this repository, or create/use a ComfyUI custom node that instantiates the original HAT architecture with the settings in train_config.yml and loads the safetensors state dict.
Training Notes
The model was fine-tuned on curated engraving crops with synthetic Real-ESRGAN-style degradations. Validation used fixed LQ/GT pairs generated from held-out crops. External visual testing was performed on historical illustrations not included in training.
Checkpoint selection favored visual fidelity in hatching, line stability, and avoidance of invented texture over raw iteration count.
The checkpoints/ folder preserves the numbered training history. The selected production model is net_g_best.safetensors / net_g_best.pth / checkpoints/net_g_5000.pth.
License
This fine-tuned model is released under the Apache License 2.0. The upstream HAT architecture and pretrained checkpoint are also distributed under Apache License 2.0 by the original HAT authors.
Dataset Manifest
The curated training split is documented separately as a reconstruction manifest:
https://huggingface.co/datasets/PhSchneider/rijksmuseum-engraving-crops
That dataset repository stores crop coordinates, split files, hashes, and preprocessing metadata rather than redistributing the full crop image set.
