Instructions to use hp-l33/ARPG with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use hp-l33/ARPG with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("hp-l33/ARPG", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Add pipeline tag, library name, project page, and link to code
#1
by nielsr HF Staff - opened
README.md
CHANGED
|
@@ -1,4 +1,108 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
|
|
|
| 3 |
---
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
pipeline_tag: unconditional-image-generation
|
| 4 |
+
library_name: pytorch
|
| 5 |
---
|
| 6 |
+
|
| 7 |
+
# Autoregressive Image Generation with Randomized Parallel Decoding
|
| 8 |
+
|
| 9 |
+
[Haopeng Li](https://github.com/hp-l33)<sup>1</sup>, Jinyue Yang<sup>2</sup>, [Guoqi Li](https://casialiguoqi.github.io)<sup>2,📧</sup>, [Huan Wang](https://huanwang.tech)<sup>1,📧</sup>
|
| 10 |
+
|
| 11 |
+
<sup>1</sup> Westlake University,
|
| 12 |
+
<sup>2</sup> Institute of Automation, Chinese Academy of Sciences
|
| 13 |
+
|
| 14 |
+
[](https://arxiv.org/abs/2503.10568) [](https://hp-l33.github.io/projects/arpg) [](https://huggingface.co/hp-l33/ARPG)
|
| 15 |
+
|
| 16 |
+
## News
|
| 17 |
+
* **2025-03-14**: The paper and code are released!
|
| 18 |
+
|
| 19 |
+
## Introduction
|
| 20 |
+
We introduce a novel autoregressive image generation framework named **ARPG**. This framework is capable of conducting **BERT-style masked modeling** by employing a **GPT-style causal architecture**. Consequently, it is able to generate images in parallel following a random token order and also provides support for the KV cache.
|
| 21 |
+
* 💪 **ARPG** achieves an FID of **1.94**
|
| 22 |
+
* 🚀 **ARPG** delivers throughput **26 times faster** than [LlamaGen](https://github.com/FoundationVision/LlamaGen)—nearly matching [VAR](https://github.com/FoundationVision/VAR)
|
| 23 |
+
* ♻️ **ARPG** reducing memory consumption by over **75%** compared to [VAR](https://github.com/FoundationVision/VAR).
|
| 24 |
+
* 🔍 **ARPG** supports **zero-shot inference** (e.g., inpainting and outpainting).
|
| 25 |
+
* 🛠️ **ARPG** can be easily extended to **controllable generation**.
|
| 26 |
+
|
| 27 |
+
## Model Zoo
|
| 28 |
+
We provide the model weights pre-trained on ImageNet-1K 256*256.
|
| 29 |
+
| Model | Param | CFG | Step | FID | IS | Weight |
|
| 30 |
+
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
| 31 |
+
| ARPG-L | 320 M | 5.0 | 64 | 2.43 | 294 | [arpg_300m.pt](https://huggingface.co/hp-l33/ARPG/blob/main/arpg_300m.pt) |
|
| 32 |
+
| ARPG-XL | 719 M | 6.0 | 64 | 2.10 | 331 | [arpg_700m.pt](https://huggingface.co/hp-l33/ARPG/blob/main/arpg_700m.pt) |
|
| 33 |
+
| ARPG-XXL | 1.3 B | 7.5 | 64 | 1.94 | 340 | [arpg_1b.pt](https://huggingface.co/hp-l33/ARPG/blob/main/arpg_1b.pt) |
|
| 34 |
+
|
| 35 |
+
## Getting Started
|
| 36 |
+
### Preparation
|
| 37 |
+
To accelerate the training process, we use the ImageNet dataset that has been pre-encoded into tokens, following the approach of [LlamaGen](https://github.com/FoundationVision/LlamaGen). You can directly download the pre-processed [dataset](https://huggingface.co/ziqipang/RandAR/blob/main/imagenet-llamagen-adm-256_codes.tar) provided by [RandAR](https://github.com/ziqipang/RandAR).
|
| 38 |
+
|
| 39 |
+
### Training
|
| 40 |
+
Taking ARPG-L as an example, the script for training using 8 A800-80GB GPUs is as follows:
|
| 41 |
+
```shell
|
| 42 |
+
torchrun \
|
| 43 |
+
--nnodes=1 --nproc_per_node=8 train_c2i.py \
|
| 44 |
+
--gpt-model ARPG-L \
|
| 45 |
+
--code-path YOUR_DATASET_PATH \
|
| 46 |
+
--epochs 400 \
|
| 47 |
+
--global-batch-size 1024 \
|
| 48 |
+
--lr 4e-4
|
| 49 |
+
```
|
| 50 |
+
Note that the learning rate is configured to be 1e-4 per 256 batch size. That is, if you set the batch size to 768, the lr should be adjusted to 3e-4.
|
| 51 |
+
|
| 52 |
+
### Evaluation
|
| 53 |
+
1. Prepare ADM evaluation script.
|
| 54 |
+
```shell
|
| 55 |
+
git clone https://github.com/openai/guided-diffusion.git
|
| 56 |
+
|
| 57 |
+
wget https://openaipublic.blob.core.windows.net/diffusion/jul-2021/ref_batches/imagenet/256/VIRTUAL_imagenet256_labeled.npz
|
| 58 |
+
```
|
| 59 |
+
2. Download the [pre-trained weights](https://huggingface.co/FoundationVision/LlamaGen/resolve/main/vq_ds16_c2i.pt) of [LlamaGen](https://github.com/FoundationVision/LlamaGen)'s tokenizer.
|
| 60 |
+
|
| 61 |
+
3. Reproduce the experimental results of ARPG:
|
| 62 |
+
```shell
|
| 63 |
+
# ARPG-L. The FID should be close to 2.43.
|
| 64 |
+
# PS: cfg-scale=5 outperforms the paper's 4.5 setting.
|
| 65 |
+
torchrun \
|
| 66 |
+
--nnodes=1 --nproc_per_node=8 sample_c2i_ddp.py \
|
| 67 |
+
--gpt-model ARPG-L \
|
| 68 |
+
--gpt-ckpt arpg_300m.pt \
|
| 69 |
+
--vq-ckpt vq_ds16_c2i.pt \
|
| 70 |
+
--cfg-scale 5.0 \
|
| 71 |
+
--step 64
|
| 72 |
+
```
|
| 73 |
+
```shell
|
| 74 |
+
# ARPG-XL. The FID should be close to 2.10.
|
| 75 |
+
torchrun \
|
| 76 |
+
--nnodes=1 --nproc_per_node=8 sample_c2i_ddp.py \
|
| 77 |
+
--gpt-model ARPG-XL \
|
| 78 |
+
--gpt-ckpt arpg_700m.pt \
|
| 79 |
+
--vq-ckpt vq_ds16_c2i.pt \
|
| 80 |
+
--cfg-scale 6.0 \
|
| 81 |
+
--step 64
|
| 82 |
+
```
|
| 83 |
+
```shell
|
| 84 |
+
# ARPG-XXL. The FID should be close to 1.94.
|
| 85 |
+
torchrun \
|
| 86 |
+
--nnodes=1 --nproc_per_node=8 sample_c2i_ddp.py \
|
| 87 |
+
--gpt-model ARPG-XXL \
|
| 88 |
+
--gpt-ckpt arpg_1b.pt \
|
| 89 |
+
--vq-ckpt vq_ds16_c2i.pt \
|
| 90 |
+
--cfg-scale 7.5 \
|
| 91 |
+
--step 64
|
| 92 |
+
```
|
| 93 |
+
Note that the unlisted parameters (such as temperature, top-k, etc.) are all the default values set in `sample_c2i_ddp.py`.
|
| 94 |
+
|
| 95 |
+
## Citation
|
| 96 |
+
If this work is helpful for your research, please give it a star or cite it:
|
| 97 |
+
```bibtex
|
| 98 |
+
@article{li2025autoregressive,
|
| 99 |
+
title={Autoregressive Image Generation with Randomized Parallel Decoding},
|
| 100 |
+
author={Haopeng Li and Jinyue Yang and Guoqi Li and Huan Wang},
|
| 101 |
+
journal={arXiv preprint arXiv:2503.10568},
|
| 102 |
+
year={2025}
|
| 103 |
+
}
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
## Acknowledgement
|
| 107 |
+
|
| 108 |
+
Thanks to [LlamaGen](https://github.com/FoundationVision/LlamaGen) for its open-source codebase. Appreciate [RandAR](https://github.com/ziqipang/RandAR) and [RAR](https://github.com/bytedance/1d-tokenizer/blob/main/README_RAR.md) for inspiring this work, and also thank [ControlAR](https://github.com/hustvl/ControlAR).
|