1# Single image2python inference.py weights/artisan_upscaler_bf16.safetensors input.png -o output.png
34# Directory of images5python inference.py weights/artisan_upscaler_bf16.safetensors input_dir/ -o output_dir/
67# Smaller tiles for low-VRAM GPUs8python inference.py weights/artisan_upscaler_bf16.safetensors input.png --tile 64910# torch.compile for faster throughput (slower first image)11python inference.py weights/artisan_upscaler_bf16.safetensors input.png --compile
Options
Flag
Default
Description
--tile
128
LR tile size (128 = 512px HR tiles)
--overlap
32
Overlap between tiles for seamless blending
--precision
bf16
bf16 or fp32
--compile
off
torch.compile for ~2x faster per-image throughput
--device
cuda
Device (cuda, cuda:0, cpu)
VRAM Usage
Measured with torch.compile, BF16:
Tile Size
VRAM
Notes
64
~0.3 GB
Fits on any GPU
128 (default)
~0.7 GB
Recommended
256
~3 GB
Fewer tiles, faster for large images
Images larger than the tile size are automatically split into overlapping tiles and blended with a Hann window for seamless output.
Attention Backend
The model uses neighborhood attention (15x15 local window). Two backends are supported:
PyTorch flex_attention (default) — works out of the box with PyTorch >= 2.5. Use torch.compile for best performance.
NATTEN — fused CUDA kernels, faster on Ampere/Hopper/Blackwell. Auto-detected if installed.
No configuration needed — the model picks the best available backend automatically.
Architecture
Input (H, W, 3)
|
Conv 3x3 -> shallow features (H, W, 512)
|
Multi-scale U-body:
Encoder: 3 residual groups at full res
Downsample 2x
Bottleneck: 2 residual groups at half res
Upsample 2x
Decoder: 3 residual groups at full res
|
Each residual group: 3 DATB blocks + 1x1 conv
Each DATB: LayerNorm -> NA/Channel Attn -> LayerNorm -> SGFN
|
Conv 3x3 -> residual connection
|
PixelShuffle 4x -> HR refinement (2 ResBlocks)
|
Output (4H, 4W, 3)
Training
Trained on ~4.1M images from 10 datasets:
PD12M (3.8M, 3-8 megapixel filtered)
LAION-HR (106K, clean + watermarked tracks)
FFHQ (70K faces)
Art Portraits (64K curated)
LSDIR (41K diverse)
DIV2K, Flickr2K, HQ-50K, MS ImagePairs
Degradation: random bicubic/bilinear/area downsampling with optional JPEG compression. GAN fine-tuning with hinge loss + projected discriminator from step 700K.
Files
inference.py — CLI inference (tiled, any resolution)
config.py — DATConfig dataclass
DAT.py — Model architecture
vectorized_ops.py — Windowing and masking utilities
weights/ — Model checkpoints (safetensors)