https://github.com/compvis/diff2flow

[CVPR 2025] Diff2Flow: Training Flow Matching Models via Diffusion Model Alignment

https://github.com/compvis/diff2flow

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.4%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

[CVPR 2025] Diff2Flow: Training Flow Matching Models via Diffusion Model Alignment

Basic Info
  • Host: GitHub
  • Owner: CompVis
  • License: mit
  • Language: Python
  • Default Branch: main
  • Size: 3.58 MB
Statistics
  • Stars: 40
  • Watchers: 0
  • Forks: 0
  • Open Issues: 2
  • Releases: 0
Created about 1 year ago · Last pushed about 1 year ago
Metadata Files
Readme License

README.md

🌊 Diff2Flow: Training Flow Matching Models via Diffusion Model Alignment

Johannes Schusterbauer*, Ming Gui*, Frank Fundel, Björn Ommer
CompVis Group @ LMU Munich
*Equal contribution

📄 CVPR 2025

Paper PDF

🔥 TL;DR

We propose Diff2Flow, a framework that bridges Diffusion and Flow Matching (FM) paradigms by rescaling timesteps, aligning interpolants, and deriving FM-compatible velocity fields. This alignment enables efficient FM finetuning of diffusion priors, retaining their knowledge while unlocking the inference efficiency and performance benefits of Flow Matching.

📝 Overview

Diffusion models have revolutionized generative tasks through high-fidelity outputs, yet flow matching (FM) offers faster inference and empirical performance gains. However, current foundation FM models are computationally prohibitive for finetuning, while diffusion models like Stable Diffusion benefit from efficient architectures and ecosystem support.

Resolution Adaptation

This work addresses the critical challenge of efficiently transferring knowledge from pre-trained diffusion models to flow matching. We propose Diff2Flow, a novel framework that systematically bridges diffusion and FM paradigms by rescaling timesteps, aligning interpolants, and deriving FM-compatible velocity fields from diffusion predictions. This alignment enables direct and efficient FM finetuning of diffusion priors with no extra computation overhead. Our experiments demonstrate that Diff2Flow outperforms naive FM and diffusion finetuning particularly under parameter-efficient constraints, while achieving superior or competitive performance across diverse downstream tasks compared to state-of-the-art methods.

📈 Results

We show our method on various fine-tuning tasks, e.g. adapting a model to a new resolution or dataset, transfering knowledge to a new domain (image-to-depth), and even speeding up inference by performing reflow.

Resolution Adaptation

When sampling from a diffusion model at a resolution different from its training resolution, performance often degrades due to the model being optimized for a fixed “sweet spot.” With Diff2Flow, adapting a pre-trained diffusion model to a new resolution becomes straightforward and efficient. Our method enables rapid finetuning, allowing the model to generate high-quality outputs at the target resolution without significant overhead. This adaptation remains effective even under LoRA constraints, outperforming both standard diffusion finetuning and naïve flow matching approaches.

Efficient T2I

An added benefit of our framework is that it also helps mitigate the non-zero terminal SNR issue common in diffusion models. Because the final timestep does not completely remove signal, these models typically struggle with prompts that require extreme uniformity (e.g., fully black or white images). With minimal finetuning using our approach, the model learns to align better with such prompts, producing cleaner, artifact-free outputs even in these edge cases.

Non-zero terminal SNR

Image-to-Depth

We can further leverage the diffusion prior to perform generative monocular depth estimation by finetuning the base model on synthetic data. Given a single image, our approach allows for the generation of accurate depth maps with just very few training iterations. This is highly efficient, enabling fast adaptation to depth estimation without requiring extensive training.

Image-to-Depth

Reflow

Flow Matching models support Reflow, a technique that straightens sampling trajectories and enables rapid image generation. Diffusion models cannot directly leverage this method. With our approach, we enable Reflow for diffusion models, allowing very efficient few-step inference and significantly speeding up the generation process.

For example, we could only use 4 (left) or even as few as 2 (right) inference steps to generate visually pleasing images from text.

Reflow

🛠️ Setup

Just create the environment using conda

bash conda env create -f environment.yml conda activate d2f

Make sure to have a folder in this directory which includes all the neccessary checkpoints, e.g. the autoencoder checkpoint for the first stage model, SD1.5, etc. You can download the checkpoints as follows:

```bash mkdir checkpoints cd checkpoints

SD 1.5 checkpoint

wget -O v1-5-pruned.ckpt https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/main/v1-5-pruned.ckpt?download=true

SD 2.1 checkpoint

wget -O v2-1768-ema-pruned.ckpt https://huggingface.co/stabilityai/stable-diffusion-2-1/resolve/main/v2-1768-ema-pruned.ckpt?download=true

SD-VAE checkpoint

wget -O sdae.ckpt https://www.dropbox.com/scl/fi/lvfvy7qou05kxfbqz5d42/sdae.ckpt?rlkey=fvtu2o48namouu9x3w08olv3o&st=vahu44z5&dl=0

TinyAutoencoderKL checkpoints

wget https://github.com/madebyollin/taesd/raw/refs/heads/main/taesdencoder.pth wget https://github.com/madebyollin/taesd/raw/refs/heads/main/taesddecoder.pth

nulltext openclip embedding

wget -O nulltextopenclipembedding.npy https://www.dropbox.com/scl/fi/6yq31ho8vntz7bbvu3ad2/nulltextopenclipembedding.npy?rlkey=gcy6vtdg61u6fdhavvxsixebx&st=xf9gxhdz&dl=0 ```

🚀 Usage

In general, the config.yaml file specifies the default. The configs are split into 5 submodules:

  • autoencoder: specifies which first stage to use (either standard one or Tiny Autoencoder)
  • data: specifies the data
  • lora: contains different LoRA configs
  • model: the specific model architecture (SD 2.1 with either 4 or 8 input channels), as well as the objective function (diffusion, FM, or Diff2Flow)
  • task: specifies the conditioning information as well as the visualizer and metric tracker configs

You can overwrite one of the 5 modules via <module>=.... For example, data=hypersim changes the data to the hypersim config. The dot notation allows you to dynamically set different values from the config. For example, if you want to change the batch size, you can type data.params.batch_size=2. Since modifying multiple parameters via CLI can be cumbersome, there is also the experiment folder, where you can add config files. Then simply run a specific experiment via

bash python train.py experiment=<your-experiment>

Info: Appending --info config to your command shows you the final resulting config.

You can find some example configs in the configs/experiment folder (incl. image-to-depth, reflow, and text-to-image configs). In general, you need to setup a task (configs/task) to define the conditioning (cross-attention) and context (concatenation). For example, for image-to-depth, we set the context key to the original image latent, and set the conditioning stage to be a dummy clip embedder, which returns the nulltext embedding. The task config allows you to additionally setup a metric tracker and a visualizer.

For the experiments of the paper, you need to download (e.g. Hypersim) or create the datasets (reflow SD1.5 image-noise pairs). You can then run one of the configs just by replacing the respective dataset, e.g., python train.py experiment=img2depth/obj_base data=hypersim for monocular depth estimation. Currently, there are dummy datasets provided that specify what the inputs and outputs are.

🎓 Citation

If you use our work in your research, please use the following BibTeX entry

bibtex @InProceedings{schusterbauer2024diff2flow, title={Diff2Flow: Training Flow Matching Models via Diffusion Model Alignment}, author={Johannes Schusterbauer and Ming Gui and Frank Fundel and Björn Ommer}, booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition}, year={2025} }

Owner

  • Name: CompVis - Computer Vision and Learning LMU Munich
  • Login: CompVis
  • Kind: organization
  • Email: assist.mvl@lrz.uni-muenchen.de
  • Location: Germany

Computer Vision and Learning research group at Ludwig Maximilian University of Munich (formerly Computer Vision Group at Heidelberg University)

GitHub Events

Total
  • Issues event: 1
  • Watch event: 33
  • Issue comment event: 2
  • Push event: 1
  • Fork event: 1
Last Year
  • Issues event: 1
  • Watch event: 33
  • Issue comment event: 2
  • Push event: 1
  • Fork event: 1

Committers

Last synced: 12 months ago

All Time
  • Total Commits: 3
  • Total Committers: 1
  • Avg Commits per committer: 3.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 3
  • Committers: 1
  • Avg Commits per committer: 3.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Johannes Fischer j****r@o****m 3

Issues and Pull Requests

Last synced: 12 months ago


Dependencies

environment.yml conda
  • _libgcc_mutex 0.1
  • _openmp_mutex 5.1
  • _sysroot_linux-64_curr_repodata_hack 3
  • abseil-cpp 20211102.0
  • aiohappyeyeballs 2.4.4
  • anyio 3.7.1
  • argon2-cffi 23.1.0
  • argon2-cffi-bindings 21.2.0
  • arrow-cpp 14.0.2
  • asttokens 2.4.1
  • aws-c-auth 0.6.19
  • aws-c-cal 0.5.20
  • aws-c-common 0.8.5
  • aws-c-compression 0.2.16
  • aws-c-event-stream 0.2.15
  • aws-c-http 0.6.25
  • aws-c-io 0.13.10
  • aws-c-mqtt 0.7.13
  • aws-c-s3 0.1.51
  • aws-c-sdkutils 0.1.6
  • aws-checksums 0.1.13
  • aws-crt-cpp 0.18.16
  • aws-sdk-cpp 1.10.55
  • backports 1.0
  • backports.functools_lru_cache 1.6.5
  • beautifulsoup4 4.12.3
  • binutils_impl_linux-64 2.38
  • binutils_linux-64 2.38.0
  • blas 1.0
  • bleach 6.1.0
  • boost-cpp 1.82.0
  • bottleneck 1.3.7
  • brotli-python 1.0.9
  • bzip2 1.0.8
  • c-ares 1.19.1
  • ca-certificates 2024.11.26
  • certifi 2024.12.14
  • cffi 1.15.1
  • charset-normalizer 2.0.4
  • colorama 0.4.6
  • comm 0.1.4
  • cryptography 41.0.3
  • cuda 12.1.0
  • cuda-cccl 12.6.77
  • cuda-cccl_linux-64 12.6.77
  • cuda-command-line-tools 12.1.1
  • cuda-compiler 12.6.2
  • cuda-crt-dev_linux-64 12.6.20
  • cuda-crt-tools 12.6.20
  • cuda-cudart 12.1.105
  • cuda-cudart-dev 12.1.105
  • cuda-cudart-dev_linux-64 12.6.77
  • cuda-cudart-static 12.6.77
  • cuda-cudart-static_linux-64 12.6.77
  • cuda-cudart_linux-64 12.6.77
  • cuda-cuobjdump 12.6.77
  • cuda-cupti 12.1.105
  • cuda-cuxxfilt 12.6.77
  • cuda-demo-suite 12.4.127
  • cuda-documentation 12.4.127
  • cuda-driver-dev 12.6.77
  • cuda-driver-dev_linux-64 12.6.77
  • cuda-gdb 12.6.77
  • cuda-libraries 12.1.0
  • cuda-libraries-dev 12.6.2
  • cuda-libraries-static 12.6.2
  • cuda-nsight 12.6.77
  • cuda-nvcc 12.6.20
  • cuda-nvcc-dev_linux-64 12.6.20
  • cuda-nvcc-impl 12.6.20
  • cuda-nvcc-tools 12.6.20
  • cuda-nvcc_linux-64 12.6.20
  • cuda-nvdisasm 12.6.77
  • cuda-nvml-dev 12.6.77
  • cuda-nvprof 12.6.80
  • cuda-nvprune 12.6.77
  • cuda-nvrtc 12.1.105
  • cuda-nvrtc-dev 12.1.105
  • cuda-nvrtc-static 12.6.85
  • cuda-nvtx 12.1.105
  • cuda-nvvm-dev_linux-64 12.6.20
  • cuda-nvvm-impl 12.6.20
  • cuda-nvvm-tools 12.6.20
  • cuda-nvvp 12.6.80
  • cuda-opencl 12.3.52
  • cuda-opencl-dev 12.3.52
  • cuda-profiler-api 12.6.77
  • cuda-runtime 12.1.0
  • cuda-sanitizer-api 12.6.77
  • cuda-toolkit 12.1.0
  • cuda-tools 12.1.1
  • cuda-version 12.6
  • cuda-visual-tools 12.6.2
  • datasets 2.12.0
  • dbus 1.13.18
  • debugpy 1.6.7
  • decorator 5.1.1
  • defusedxml 0.7.1
  • dill 0.3.6
  • entrypoints 0.4
  • exceptiongroup 1.1.3
  • executing 2.0.1
  • expat 2.6.4
  • ffmpeg 4.3
  • filelock 3.9.0
  • fontconfig 2.14.1
  • freetype 2.12.1
  • frozenlist 1.4.0
  • fsspec 2023.10.0
  • gcc_impl_linux-64 11.2.0
  • gcc_linux-64 11.2.0
  • gds-tools 1.8.0.34
  • gflags 2.2.2
  • giflib 5.2.1
  • glib 2.78.4
  • glib-tools 2.78.4
  • glog 0.5.0
  • gmp 6.2.1
  • gmpy2 2.1.2
  • gnutls 3.6.15
  • grpc-cpp 1.48.2
  • gxx_impl_linux-64 11.2.0
  • gxx_linux-64 11.2.0
  • h5py 3.9.0
  • hdf5 1.12.1
  • huggingface_hub 0.24.6
  • icu 73.1
  • idna 3.4
  • importlib-metadata 6.8.0
  • importlib_metadata 6.8.0
  • importlib_resources 6.1.1
  • intel-openmp 2023.1.0
  • ipykernel 6.26.0
  • ipython 8.17.2
  • ipython_genutils 0.2.0
  • jedi 0.19.1
  • jinja2 3.1.2
  • jpeg 9e
  • jsonschema 4.21.1
  • jsonschema-specifications 2023.12.1
  • jupyter_client 7.4.9
  • jupyter_core 5.5.0
  • jupyter_server 1.24.0
  • jupyterlab_pygments 0.3.0
  • kernel-headers_linux-64 3.10.0
  • krb5 1.20.1
  • lame 3.100
  • lcms2 2.12
  • ld_impl_linux-64 2.38
  • lerc 3.0
  • libboost 1.82.0
  • libbrotlicommon 1.0.9
  • libbrotlidec 1.0.9
  • libbrotlienc 1.0.9
  • libcublas 12.1.0.26
  • libcublas-dev 12.1.0.26
  • libcublas-static 12.6.4.1
  • libcufft 11.0.2.4
  • libcufft-dev 11.0.2.4
  • libcufft-static 11.3.0.4
  • libcufile 1.8.0.34
  • libcufile-dev 1.8.0.34
  • libcufile-static 1.11.1.6
  • libcurand 10.3.4.52
  • libcurand-dev 10.3.4.52
  • libcurand-static 10.3.7.77
  • libcurl 8.5.0
  • libcusolver 11.4.4.55
  • libcusolver-dev 11.4.4.55
  • libcusolver-static 11.7.1.2
  • libcusparse 12.0.2.55
  • libcusparse-dev 12.0.2.55
  • libcusparse-static 12.5.4.2
  • libdeflate 1.17
  • libedit 3.1.20230828
  • libev 4.33
  • libevent 2.1.12
  • libffi 3.4.4
  • libgcc-devel_linux-64 11.2.0
  • libgcc-ng 11.2.0
  • libgfortran-ng 11.2.0
  • libgfortran5 11.2.0
  • libglib 2.78.4
  • libgomp 11.2.0
  • libiconv 1.16
  • libidn2 2.3.4
  • libjpeg-turbo 2.0.0
  • libnghttp2 1.57.0
  • libnpp 12.0.2.50
  • libnpp-dev 12.0.2.50
  • libnpp-static 12.3.1.54
  • libnvfatbin 12.6.77
  • libnvfatbin-dev 12.6.77
  • libnvfatbin-static 12.6.77
  • libnvjitlink 12.1.105
  • libnvjitlink-dev 12.1.105
  • libnvjitlink-static 12.6.85
  • libnvjpeg 12.1.1.14
  • libnvjpeg-dev 12.1.1.14
  • libnvjpeg-static 12.3.3.54
  • libnvvm-samples 12.1.105
  • libpng 1.6.39
  • libprotobuf 3.20.3
  • libsodium 1.0.18
  • libssh2 1.10.0
  • libstdcxx-devel_linux-64 11.2.0
  • libstdcxx-ng 11.2.0
  • libtasn1 4.19.0
  • libthrift 0.15.0
  • libtiff 4.5.1
  • libunistring 0.9.10
  • libuuid 1.41.5
  • libwebp 1.3.2
  • libwebp-base 1.3.2
  • libxcb 1.15
  • libxkbcommon 1.0.1
  • libxml2 2.10.4
  • llvm-openmp 14.0.6
  • lz4-c 1.9.4
  • markupsafe 2.1.1
  • matplotlib-inline 0.1.6
  • mistune 3.0.2
  • mkl 2023.1.0
  • mkl-service 2.4.0
  • mkl_fft 1.3.8
  • mkl_random 1.2.4
  • mpc 1.1.0
  • mpfr 4.0.2
  • mpmath 1.3.0
  • multidict 6.0.4
  • multiprocess 0.70.14
  • nbclassic 1.0.0
  • nbclient 0.8.0
  • nbconvert 7.16.1
  • nbconvert-core 7.16.1
  • nbconvert-pandoc 7.16.1
  • nbformat 5.9.2
  • ncurses 6.4
  • nest-asyncio 1.5.8
  • nettle 3.7.3
  • networkx 3.1
  • notebook 6.5.6
  • notebook-shim 0.2.4
  • nsight-compute 2024.3.2.3
  • nspr 4.35
  • nss 3.89.1
  • numexpr 2.8.7
  • numpy 1.26.0
  • numpy-base 1.26.0
  • openh264 2.1.1
  • openjpeg 2.4.0
  • openssl 3.0.15
  • orc 1.7.4
  • packaging 23.2
  • pandas 2.1.4
  • pandoc 3.1.12.1
  • pandocfilters 1.5.0
  • parso 0.8.3
  • pcre2 10.42
  • pexpect 4.8.0
  • pickleshare 0.7.5
  • pillow 10.0.1
  • pip 23.3
  • pkgutil-resolve-name 1.3.10
  • platformdirs 4.0.0
  • prometheus_client 0.20.0
  • prompt-toolkit 3.0.41
  • prompt_toolkit 3.0.41
  • propcache 0.2.0
  • ptyprocess 0.7.0
  • pure_eval 0.2.2
  • pyarrow 14.0.2
  • pycparser 2.21
  • pygments 2.16.1
  • pyopenssl 23.2.0
  • pysocks 1.7.1
  • python 3.11.5
  • python-dateutil 2.8.2
  • python-fastjsonschema 2.19.1
  • python-tzdata 2024.1
  • python-xxhash 2.0.2
  • python_abi 3.11
  • pytorch 2.1.0
  • pytorch-cuda 12.1
  • pytorch-mutex 1.0
  • pytz 2024.1
  • pyyaml 6.0.1
  • pyzmq 23.2.0
  • re2 2022.04.01
  • readline 8.2
  • referencing 0.33.0
  • regex 2023.10.3
  • requests 2.31.0
  • responses 0.13.3
  • rpds-py 0.10.6
  • s2n 1.3.27
  • send2trash 1.8.2
  • setuptools 68.0.0
  • six 1.16.0
  • snappy 1.1.10
  • sniffio 1.3.0
  • soupsieve 2.5
  • sqlite 3.41.2
  • stack_data 0.6.2
  • sympy 1.11.1
  • sysroot_linux-64 2.17
  • tbb 2021.8.0
  • terminado 0.18.0
  • tinycss2 1.2.1
  • tk 8.6.12
  • torchtriton 2.1.0
  • torchvision 0.16.0
  • tornado 6.3.3
  • tqdm 4.66.1
  • traitlets 5.13.0
  • typing-extensions 4.7.1
  • typing_extensions 4.7.1
  • tzdata 2023c
  • urllib3 1.26.18
  • utf8proc 2.6.1
  • webencodings 0.5.1
  • websocket-client 1.7.0
  • wheel 0.41.2
  • xxhash 0.8.0
  • xz 5.4.2
  • yaml 0.2.5
  • zeromq 4.3.4
  • zipp 3.17.0
  • zlib 1.2.13
  • zstd 1.5.5