ZJUI Summer Research · Zhejiang University · 2025

MeanFlow Denoising: Clean Images in a Single Step

Hanbin Zheng Jiaming Xu Hao Ding
Advisor: Prof. Xiangming Meng, ZJUI
Ten MNIST digits after one-step MeanFlow denoising
test-set PSNR 22.6 dB

Click through the steps. One network evaluation (1 NFE) already removes most of the noise; a second one sharpens the strokes, and more steps change almost nothing.

1 stepDenoising is a single forward pass of the network
6 → 22.6 dBTest PSNR, noisy input vs. one-step output
24.1 dBWith two steps; more steps add nothing
300kTraining steps of a small DiT (6 blocks) on MNIST

The Idea

Flow matching learns an instantaneous velocity field \(v(z_t, t)\) that carries one distribution into another; sampling integrates it with many small steps. MeanFlow [1] learns the average velocity over an interval instead,

\[ u(z_t, r, t) \triangleq \frac{1}{t-r}\int_r^t v(z_\tau, \tau)\,d\tau , \]

so one evaluation jumps across the whole interval. Training never integrates anything: differentiating the definition gives the MeanFlow identity, whose right-hand side is the regression target (the total derivative is one Jacobian-vector product, torch.func.jvp):

\[ u(z_t, r, t) = v(z_t, t) - (t-r)\Big(\frac{\partial u}{\partial z_t}\, v(z_t, t) + \frac{\partial u}{\partial t}\Big). \]

Our change: MeanFlow usually starts from Gaussian noise and generates images. We start the flow from noisy images \(z_1\) and end it at clean ones, so the same one-step jump becomes a denoiser:

\[ \hat{x} = z_1 - u_\theta(z_1, 0, 1). \]

The theory, from flow matching to MeanFlow, is written up step by step in my blog post From Flow Matching to MeanFlow; the full derivations are in the report.

Setup

  • Data: MNIST, noisy input = clean image + \(\sigma\epsilon\) with \(\sigma \sim \mathcal{U}(0.3, 0.8)\).
  • Model: a Diffusion Transformer (DiT): 32×32 input, 2×2 patches, width 144, 6 blocks, 3 heads; \(r\), \(t\) and the class label enter through adaLN.
  • Training: MeanFlow loss with classifier-free guidance and the adaptive L2 loss of [1], \((r, t)\) from a logit-normal distribution, AdamW (lr \(10^{-4}\), batch 128), cosine annealing with warm restarts, 300k steps in FP16.
  • Metric: PSNR on the test set.

Results

Test PSNR of one-step denoising over 300k training steps, rising from about 10 dB to about 21.7 dB
One-step test PSNR over training.
Output PSNR [dB]
Noisy input 6.04
1 NFE 22.65
2 NFE 24.07
3 NFE 24.08
4 NFE 24.07
5 NFE 24.06
Test PSNR after 300k training steps.
Grid of MNIST digits: ground truth, noisy inputs, and denoised outputs after 1 to 5 network evaluations
From top to bottom: ground truth, noisy input, and the outputs after 1 to 5 NFE.

What we learned

  • The noise has to be smooth. With Gaussian noise the noisy-image distribution stays smooth, as the continuity equation behind flow matching needs. Clipping the noisy pixels to [0, 1] piles probability mass up at the bounds, and training failed.
  • Cheap to sample, costly to train. Sampling takes one or two steps, but the JVP in every training step is expensive, and the fixed guidance scale limits flexibility.
  • Next steps. Harder datasets (CIFAR-10), non-Gaussian noise, and a comparison with other denoisers.

References

  1. Z. Geng, M. Deng, X. Bai, J. Z. Kolter, K. He. Mean Flows for One-step Generative Modeling. arXiv:2505.13447, 2025.
  2. Y. Lipman, R. T. Q. Chen, H. Ben-Hamu, M. Nickel, M. Le. Flow Matching for Generative Modeling. ICLR, 2023.
  3. W. Peebles, S. Xie. Scalable Diffusion Models with Transformers. ICCV, 2023.
  4. Our code starts from the PyTorch MeanFlow implementation haidog-yaqub/MeanFlow.