Skip to content

caetas/SymmetricFlow

Repository files navigation

Python PyTorch uv Docker

[AAAI 2026] - Symmetrical Flow Matching: Unified Image Generation, Segmentation, and Classification with Score-Based Generative Models

Generated samples.

The official implementation of Symmetrical Flow Matching: Unified Image Generation, Segmentation, and Classification with Score-Based Generative Models.

Francisco Caetano1, Christiaan Viviers1, Peter H.N. de With1, Fons van der Sommen1

¹ Eindhoven University of Technology

What is SymmFlow?

SymmFlow is a unified Flow Matching framework that performs semantic image generation, segmentation, and classification within a single model. Instead of treating these tasks separately, it learns bi-directional flows between images and their semantic representations, allowing the model to move from masks or labels to images, and back again, using the same architecture. This symmetry enables efficient conditional generation, one-step segmentation and classification, and high-fidelity image synthesis with only a few inference steps. SymmFlow also supports flexible conditioning, from pixel-level masks to global labels, making it a general framework for vision tasks that require both semantic understanding and generative capability.

Prerequisites

You will need:

  • Git
  • uv (see pyproject.toml for full version)
  • a .secrets file with the required secrets and credentials
  • load environment variables from .env
  • NVIDIA Drivers(mandatory) and CUDA >= 12.8 (mandatory if Docker/Apptainer is not used)
  • Weights & Biases account

Installation

Clone this repository (requires git ssh keys)

git clone --recursive git@github.com:caetas/SymmetricFlow.git
cd SymmetricFlow

Using uv

Create the environment and install the dependencies:

uv sync --python 3.12

Activate the environment on Linux

You can activate the environment with:

source .venv/bin/activate

You might be required to run the following command once to setup the automatic activation of the conda environment and the virtualenv:

direnv allow

Feel free to edit the .envrc file if you prefer to activate the environments manually.

Using Docker or Apptainer

Create a .secrets file and add your Weights & Biases API Key:

WANDB_API_KEY = <your-wandb-api-key>

Docker

Create the image using the provided Dockerfile

docker build --tag symmflow .

Or download it from the Hub:

docker pull docker://ocaetas/symmflow

Then run the script job_docker.sh that will execute main.sh:

cd scripts
bash job_docker.sh

To access the shell, please run:

docker run --rm -it --gpus all --ipc=host --env-file .env -v $(pwd)/:/app/ symmflow bash

Apptainer

Convert the Docker Image to a .sif file:

apptainer pull symmflow.sif docker://ocaetas/symmflow

Then run the script job_apptainer.sh that will execute main.sh:

cd scripts
bash job_apptainer.sh

To access the shell, please run:

apptainer shell --nv --env-file .env --bind $(pwd)/:/app/ symmflow.sif

Add the flag --nvccli if you are using WSL.

Note: Edit the main.sh script if you want to train a different model.

Datasets

Semantic Image Synthesis and Segmentation

  • CelebAMask-HQ: Automatically Downloaded.
  • COCO-Stuff: Download here and move the dataset to data/raw

Classification and Conditional Image Generation

  • MNIST: Automatically Downloaded.
  • CIFAR-10: Automatically Downloaded.

Training the Models

In addition to the instructions for using Docker or Apptainer, the documentation for training is available here: TRAINING.md.

Download Pretrained Models

The folder containing the pretrained weights of the models used in the paper can be downloaded here.

Running and Evaluating the Models

The instructions to run and evaluate the models are available in INFERENCE.md.

License

This project is licensed under the terms of the MIT license. See LICENSE for more details.

Citation

If you publish work that uses SymmFlow, please cite SymmFlow as follows:

@article{caetano2025symmetrical,
  title={Symmetrical Flow Matching: Unified Image Generation, Segmentation, and Classification with Score-Based Generative Models},
  author={Caetano, Francisco and Viviers, Christiaan and De With, Peter HN and van der Sommen, Fons},
  journal={arXiv preprint arXiv:2506.10634},
  year={2025}
}

About

[AAAI 2026] - The official implementation of SymmFlow.

Resources

Stars

Watchers

Forks

Packages

No packages published