Skip to content
프로젝트

keishihara/flow-matching has 131 GitHub stars and 13 forks. GitHot measured 0 stars in 24 hours, 0 in 7 days, and 0 in 15 days. Last checked 2026-11-19 12:30 UTC. Last push 2026-01-18.

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
업데이트 지연

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

소개

Flow Matching implemented in PyTorch

머신러닝

README.md

Original

Flow Matching in PyTorch

This repository contains a simple PyTorch implementation of the paper Flow Matching for Generative Modeling.

2D Flow Matching Example

The gif below demonstrates mapping a single Gaussian distribution to a checkerboard distribution, with the vector field visualized.

And, here is another example of moons dataset.

Getting Started

Clone the repository and set up the python environment.

git clone https://github.com/keishihara/flow-matching.git
cd flow-matching

Make sure you have Python 3.12+ installed. Install uv:

curl -LsSf https://astral.sh/uv/install.sh | sh

Then, set up the environment:

uv sync

Conditional Flow Matching [Lipman+ 2023]

This is the original CFM paper implementation [1]. Some components of the code are adapted from [2] and [3].

2D Toy Datasets

You can train the CFM models on 2D synthetic datasets such as checkerboard and moons. Specify the dataset name using --dataset option. Training parameters are predefined in the script, and visualizations of the training results are stored in the outputs/ directory. Model checkpoints are not included as they are easily reproducible with the default settings.

uv run scripts/train_flow_matching_2d.py --dataset checkerboard

The vector fields and generated samples, like the ones displayed as GIFs at the top of this README, can now be found in the outputs/cfm/ directory.

Image Datasets

You can also train class-conditional CFM models on popular image classification datasets. Both the generated samples and model checkpoints will be stored in the outputs/cfm directory. For a detailed list of training parameters, run uv run scripts/train_flow_matching_on_image.py --help.

To train a class-conditional CFM on MNIST dataset, run:

uv run scripts/train_flow_matching_on_image.py --do_train --dataset mnist

After training, you can now generate samples with:

uv run scripts/train_flow_matching_on_image.py --do_sample --dataset mnist

Now, you should be able to see the generated samples in the outputs/cfm/mnist/ directory.

Rectified Flow [Liu+ 2023]

This is an implementation of the Reflow model (2-Rectified Flow to be specific) from the Rectified Flow paper [2].

2D Synthetic Data

We have implemented the Reflow on 2d synthetic datasets, same as the CFM. To train the reflow, you have to specify pretrained CFM checkpoints as reflow is a distillation model.

For example, to train on the checkerboard dataset with a pretrained CFM checkpoint:

uv run scripts/train_reflow_2d.py --dataset checkerboard

The training results, including vector field visualizations and generated samples, are saved under outputs/reflow/ folder.

Comparison of sampling process between CFM and Reflow

To compare CFM and Reflow on 2d datasets, run:

uv run scripts/plot_comparison_2d.py --dataset checkerboard

The resulting GIFs can be found under outputs/comparisons/ folder. Below is an example comparison of the two methods in the checkerboard dataset:

References