--- title: Follow the Mean (FLUX.2) emoji: 🪷 colorFrom: pink colorTo: indigo sdk: gradio sdk_version: 6.14.0 app_file: app.py pinned: false license: apache-2.0 short_description: Training-free reference-guided generation with FLUX.2-klein models: - black-forest-labs/FLUX.2-klein-4B tags: - flux - flux.2 - flow-matching - reference-guided - rmg - training-free --- # Follow the Mean — FLUX.2 reference-guided generation Training-free **Reference-Mean Guidance (RMG)** applied to a frozen [`FLUX.2-klein-4B`](https://huggingface.co/black-forest-labs/FLUX.2-klein-4B). The prompt says *what* the image is; the reference set biases *which way* the flow goes. Change the reference set, and the flow changes. * Paper: [Follow the Mean: Reference-Guided Flow Matching](https://arxiv.org/abs/2605.10302) * Code: [github.com/pedrocurvo/follow-the-mean](https://github.com/pedrocurvo/follow-the-mean) ## How it works For deterministic flow-matching interpolants, the velocity field points toward an endpoint mean. RMG approximates a *target* endpoint mean from a small reference set and adds the residual correction during sampling: ``` u_guided(x_t, t) = u_theta(x_t, t) + beta_t * (mu_ref(x_t, t) - mu_theta(x_t, t)) / (1 - t) ``` No FLUX.2 weights are updated; the control signal lives entirely in the reference set. This Space implements that callback on top of the `Flux2KleinPipeline` from `diffusers`.