File size: 4,473 Bytes
45b20c8 bc57cd2 45b20c8 |
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
---
datasets:
- ILSVRC/imagenet-1k
license: mit
pipeline_tag: image-to-image
library_name: pytorch
tags:
- generative-model
- image-generation
- class-conditional
- flow-based-model
- pixel-space
---
<div align="center">
<h1> PixelFlow: Pixel-Space Generative Models with Flow </h1>
[](https://arxiv.org/abs/2504.07963)
[](https://github.com/ShoufaChen/PixelFlow)
[](https://huggingface.co/spaces/ShoufaChen/PixelFlow)

</div>
> [**PixelFlow: Pixel-Space Generative Models with Flow**](https://arxiv.org/abs/2504.07963)<br>
> [Shoufa Chen](https://www.shoufachen.com), [Chongjian Ge](https://chongjiange.github.io/), [Shilong Zhang](https://jshilong.github.io/), [Peize Sun](https://peizesun.github.io/), [Ping Luo](http://luoping.me/)
> <br>The University of Hong Kong, Adobe<br>
## Introduction
We present PixelFlow, a family of image generation models that operate directly in the raw pixel space, in contrast to the predominant latent-space models. This approach simplifies the image generation process by eliminating the need for a pre-trained Variational Autoencoder (VAE) and enabling the whole model end-to-end trainable. Through efficient cascade flow modeling, PixelFlow achieves affordable computation cost in pixel space. It achieves an FID of 1.98 on 256x256 ImageNet class-conditional image generation benchmark. The qualitative text-to-image results demonstrate that PixelFlow excels in image quality, artistry, and semantic control. We hope this new paradigm will inspire and open up new opportunities for next-generation visual generation models.
## Model Zoo
| Model | Task | Params | FID | Checkpoint |
|:---------:|:--------------:|:------:|:----:|:----------:|
| PixelFlow | class-to-image | 677M | 1.98 | [🤗](https://huggingface.co/ShoufaChen/PixelFlow-Class2Image) |
| PixelFlow | text-to-image | 882M | N/A | [🤗](https://huggingface.co/ShoufaChen/PixelFlow-Text2Image) |
## Setup
### 1. Create Environment
```bash
conda create -n pixelflow python=3.12
conda activate pixelflow
```
### 2. Install Dependencies:
* [PyTorch 2.6.0](https://pytorch.org/) — install it according to your system configuration (CUDA version, etc.).
* [flash-attention v2.7.4.post1](https://github.com/Dao-AILab/flash-attention/releases/tag/v2.7.4.post1): optional, required only for training.
* Other packages: `pip3 install -r requirements.txt`
## Demo [](https://huggingface.co/spaces/ShoufaChen/PixelFlow)
We provide an online [Gradio demo](https://huggingface.co/spaces/ShoufaChen/PixelFlow) for class-to-image generation.
You can also easily deploy both class-to-image and text-to-image demos locally by:
```bash
python app.py --checkpoint /path/to/checkpoint --class_cond # for class-to-image
```
or
```bash
python app.py --checkpoint /path/to/checkpoint # for text-to-image
```
## Training
### 1. ImageNet Preparation
- Download the ImageNet dataset from [http://www.image-net.org/](http://www.image-net.org/).
- Use the [extract_ILSVRC.sh]([extract_ILSVRC.sh](https://github.com/pytorch/examples/blob/main/imagenet/extract_ILSVRC.sh)) to extract and organize the training and validation images into labeled subfolders.
### 2. Training Command
```bash
torchrun --nnodes=1 --nproc_per_node=8 train.py configs/pixelflow_xl_c2i.yaml
```
## Evaluation (FID, Inception Score, etc.)
We provide a [sample_ddp.py](sample_ddp.py) script, adapted from [DiT](https://github.com/facebookresearch/DiT), for generating sample images and saving them both as a folder and as a .npz file. The .npz file is compatible with ADM's TensorFlow evaluation suite, allowing direct computation of FID, Inception Score, and other metrics.
```bash
torchrun --nnodes=1 --nproc_per_node=8 sample_ddp.py --pretrained /path/to/checkpoint
```
## BibTeX
```bibtex
@article{chen2025pixelflow,
title={PixelFlow: Pixel-Space Generative Models with Flow},
author={Chen, Shoufa and Ge, Chongjian and Zhang, Shilong and Sun, Peize and Luo, Ping},
journal={arXiv preprint arXiv:2504.07963},
year={2025}
}
``` |