haidog-yaqub/MeanFlow

PyTorch implementation of MeanFlow & iMF (one-step generative modeling).

What it solves

MeanFlow addresses the need for high-quality, one-step generative modeling. Traditional generative models often require multiple iterative steps to produce high-quality images, which can be slow. This project provides a framework to train models capable of generating results in a single step.

How it works

This project is a PyTorch implementation of the MeanFlow and Improved MeanFlow (iMF) research papers. It uses a dual-head Diffusion Transformer (DiT) architecture where one head handles MeanFlow calculations and the other manages flow matching. The framework supports Classifier-Free Guidance (CFG) distillation, allowing users to control generation quality via a scale parameter. It includes configuration-based training for various datasets, including MNIST, CIFAR-10, and latent ImageNet.

Who it’s for

This repository is intended for researchers and developers working on fast generative modeling who prefer a PyTorch implementation over the original JAX-based code. It is suitable for those looking to experiment with one-step generation for images, audio, or voice conversion tasks.

Highlights

  • Implements both original MeanFlow and the more stable Improved MeanFlow (iMF).
  • Supports single-GPU and multi-GPU training via Hugging Face Accelerate.
  • Includes Classifier-Free Guidance (CFG) for improved generation control.
  • Provides a modular configuration system for easy experimentation with different datasets.
  • Compatible with latent image training using VAEs.

Related

  • Project
  • Project
  • Project
  • Project
  • Project