File size: 2,420 Bytes
53ad412 f5cc865 53ad412 f5cc865 53ad412 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | ---
tags:
- image-generation
- class-conditional
- autoregressive
- imagenet
- pytorch
---
# CHARM-H w/ Rec.
[Paper: CHARM: Compressible Hilbert Order Autoregressive Model for Image Generation](https://arxiv.org/abs/2612.03308)
Class-conditional ImageNet generation with CHARM-H in fixed Hilbert order and
recursive KV cache compression. Choose the generator for the output resolution:
| Output | Generator | ImageNet FID |
| --- | --- | ---: |
| 256 x 256 | [charm-h-rec-256.safetensors](https://huggingface.co/Enhan/CHARM-H-Rec/resolve/main/charm-h-rec-256.safetensors) | 1.64 |
| 512 x 512 | [charm-h-rec-512.safetensors](https://huggingface.co/Enhan/CHARM-H-Rec/resolve/main/charm-h-rec-512.safetensors) | 1.87 |
You also need the [CHARM inference code](https://huggingface.co/Enhan/CHARM-H-Rec/resolve/main/CHARM-H-inference-source.tar.gz)
and the upstream [MaskGIT-f16 decoder weights](https://huggingface.co/fun-research/TiTok/blob/main/maskgit-vqgan-imagenet-f16-256.bin).
Both resolutions use this same decoder, including the 512 model. It is not included in the generator weights.
No ImageNet data or training code is required.
## Generate an image
Install PyTorch for your hardware and the Hugging Face CLI (`hf`).
```bash
hf download Enhan/CHARM-H-Rec CHARM-H-inference-source.tar.gz --local-dir .
tar -xzf CHARM-H-inference-source.tar.gz
python -m pip install ./charm-inference
# Set RES=512 instead to generate a 512 x 512 image.
RES=256
hf download Enhan/CHARM-H-Rec "charm-h-rec-${RES}.safetensors" --local-dir weights
hf download fun-research/TiTok maskgit-vqgan-imagenet-f16-256.bin --local-dir weights
python -m charm --model "charm-h-rec-${RES}" \
--weights "weights/charm-h-rec-${RES}.safetensors" \
--decoder weights/maskgit-vqgan-imagenet-f16-256.bin \
--class-id 88 --seed 42 --output "samples/${RES}"
```
The example writes an RGB PNG. Class IDs range from 0 to 999. The CLI defaults
to CUDA and chooses a backend automatically. For CPU inference, add
`--device cpu --backend sdpa`. See the inference package README for sampling
options and attribution.
## SHA-256
```text
2bd2d8dd6af69b3e85f9f4986b1443e84d5ddf74ee00e5eb0183a692be4a6ad0 charm-h-rec-256.safetensors
6739dec67354df9c283944c38f027b1b27e2574d1654d436cbe6603f44a9a6d4 charm-h-rec-512.safetensors
424e7f2b11d1d63691ae3fbab74cf6c417ecbe0d8f86187b71f3538c7b56f6d2 maskgit-vqgan-imagenet-f16-256.bin
```
|