Home

Awesome

<div align="center">

[ICLR2024] ⚡InstaFlow! One-Step Stable Diffusion with Rectified Flow

[Paper] [Demo in 🤗Hugging Face Space] [Code and Pre-trained Models][Colab Notebook]

by Xingchao Liu, Xiwen Zhang, Jianzhu Ma, Jian Peng, Qiang Liu

</div>

News

Introduction

Diffusion models have demonstrated remarkable promises in text-to-image generation. However, their efficacy is still largely hindered by computational constraints stemming from the need of iterative numerical solvers at the inference time for solving the diffusion/flow processes.

InstaFlow is an ultra-fast, one-step image generator that achieves image quality close to Stable Diffusion, significantly reducing the demand of computational resources. This efficiency is made possible through a recent Rectified Flow technique, which trains probability flows with straight trajectories, hence inherently requiring only a single step for fast inference.

InstaFlow has several advantages:

Gallery

One-step generation with InstaFlow-0.9B (0.09s per image, $512 \times 512$)

<p align="middle"> <img src='github_misc/gallery/09B_img_1.png' width='192'> <img src='github_misc/gallery/09B_img_2.png' width='192'> <img src='github_misc/gallery/09B_img_3.png' width='192'> <img src='github_misc/gallery/09B_img_4.png' width='192'> </p>

One-step generation with InstaFlow-1.7B (0.12s per image, $512 \times 512$)

<p align="middle"> <img src='github_misc/gallery/17B_img_1.png' width='192'> <img src='github_misc/gallery/17B_img_2.png' width='192'> <img src='github_misc/gallery/17B_img_3.png' width='192'> <img src='github_misc/gallery/17B_img_4.png' width='192'> </p>

One-step generation with InstaFlow-0.9B (0.09s) + SDXL-Refiner ($1024 \times 1024$)

<p align="middle"> <img src='github_misc/gallery/09B_refine_1.png' width='384'> <img src='github_misc/gallery/09B_refine_2.png' width='384'> </p>

Latent space interpolation of one-step InstaFlow-0.9B (0.09s per image, $512 \times 512$)

<div align="center">

https://github.com/gnobitab/InstaFlow/assets/1157982/e8c41d7c-aa1d-4ac3-b96f-5cda847331fe

</div>

LoRA

One-step InstaFlow is compatible with pre-trained LoRAs. We thank individual contributor Dr. Hanshu Yan for providing and testing the Rectified Flow+LoRA pipeline!

InstaFlow seems to have higher diversity than SDXL-Turbo.

https://github.com/gnobitab/InstaFlow/assets/1157982/8f12960e-116d-486a-a2e9-448d745394c2

ControlNet

One-step InstaFlow is fully compatible with pre-trained ControlNets. We thank individual contributor Dr. Hanshu Yan for providing and testing the Rectified Flow+ControlNet pipeline!

Below are One-Step Generation with InstaFlow-0.9B + ControlNet:

Comparison with SD 1.5 on our A100 machine

For an intuitive understanding, we used the same A100 server and took screenshots from the Gridio interface of random generation with different models. InstaFlow-0.9B is one-step, while SD 1.5 adopts 25-step DPMSolver. It takes around 0.3 second to download the image from the server. The text prompt is "A photograph of a snowy mountain near a beautiful lake under sunshine."

            InstaFlow-0.9B                          Stable Diffusion 1.5          

Method: Straightening Generative Probability Flows with Text-Conditioned Reflow

<div align="center">

https://github.com/gnobitab/InstaFlow/assets/1157982/897e2d1a-eff9-44bf-ab89-bc26bbc0d8a7

</div> <p align="middle"> <img src='github_misc/method_new.jpg' width='550'> </p>

Our pipeline consists of three steps:

  1. Generate (text, noise, image) triplets from pre-trained Stable Diffusion
  2. Apply text-conditioned reflow to yield 2-Rectified Flow, which is a straightened generative probability flow.
  3. Distill from 2-Rectified Flow to get One-Step InstaFlow. Note that distillation and reflow are orthogonal techniques.

As captured in the video and the image, straight flows have the following advantages:

Related Materials

We provide several related links and readings here:

Citation

@inproceedings{liu2023instaflow,
  title={Instaflow: One step is enough for high-quality diffusion-based text-to-image generation},
  author={Liu, Xingchao and Zhang, Xiwen and Ma, Jianzhu and Peng, Jian and Liu, Qiang},
  booktitle={International Conference on Learning Representations},
  year={2024}
}

Thanks

Our training scripts are modified from one of the fine-tuning examples in Diffusers. Other parts of our work also heavily relies on the 🤗 Diffusers library.