Code Monkey home page Code Monkey logo

instaflow's Introduction

⚡InstaFlow! One-Step Stable Diffusion with Rectified Flow

[Paper] [(🔥New) Demo in 🤗Hugging Face Space]

by Xingchao Liu, Xiwen Zhang, Jianzhu Ma, Jian Peng, Qiang Liu from Helixon Research and UT Austin

News

  • (🔥New) 2023/09/26 We provide a demo of InstaFlow-0.9B in 🤗Hugging Face Space. Try it here.

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:

  • Ultra-Fast Inference: InstaFlow models are one-step generators, which directly map noises to images and avoid multi-step sampling of diffusion models. On our machine with A100 GPU, the inference time is around 0.1 second, saving ~90% of the inference time compared to the original Stable Diffusion.
  • High-Quality: InstaFlow generates images with intricate details like Stable Diffusion, and have similar FID on MS COCO 2014 as state-of-the-art text-to-image GANs, like StyleGAN-T.
  • Simple and Efficient Training: The training process of InstaFlow merely involves supervised training. Leveraging pre-trained Stable Diffusion, it only takes 199 A100 GPU days to get InstaFlow-0.9B.

Method: Straightening Generative Probability Flows with Text-Conditioned Reflow

method_github.mov

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 probaiblity 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:

  • Straight flows require fewer steps to simulate.
  • Straight flows give better coupling between the noise distribution and the image distribution, thus allow successful distillation.

Gallery

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

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

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

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

interpolation.mp4

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          

Related Materials

We provide several related links and readings here:

Citation

@article{liu2023insta,
  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},
  journal={arXiv preprint arXiv:2309.06380},
  year={2023}
}

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.