SuperAPI AI Directory

Flow-Factory

Flow-Factory is a unified fine-tuning framework for diffusion models and Flow-Matching models, supporting online reinforcement learning (RL) and offline fine-tuning. It can train tasks such as text-to-image, text-to-video, image-to-image, image-to-video, and text/first-last-frame/reference-image-to-audio-video, supports algorithms such as GRPO, SFT, offline DPO, and TDM, and is compatible with models such as SD3.5, FLUX.1, FLUX.2, Qwen-Image, Wan2, LTX-2, and MiniMax H3. The framework provides built-in and custom reward models, experiment tracking (W&B, SwanLab), attention backend acceleration, and CUDA training images, making it suitable for generative model fine-tuning in research and engineering scenarios.

Open website

About this tool

Flow-Factory is a unified framework for convenient fine-tuning of Flow-Matching models, maintained by X-GenGroup. Its core positioning is to support both online reinforcement learning (Online RL) and offline fine-tuning (Offline Fine-Tuning), covering diffusion models and Flow-Matching models.

Main capabilities

  • Supports multiple generative tasks: text-to-image, text-to-video, image-to-image, image-to-video, as well as text-to-audio-video, first-last-frame-to-audio-video, ordered-reference-image-to-audio-video, etc.
  • Supports multiple algorithms: GRPO, SFT, offline DPO, TDM, etc., with models and algorithms decoupled at the framework interface level.
  • Supports multiple models: sd3-5, flux1, flux1-kontext, flux2, flux2-klein, qwen-image, qwen-image-edit-plus, qwen-image-2.1, z-image, bagel, sensenova, wan2_t2v, wan2_i2v, ltx2_t2av, ltx2_i2av, and the MiniMax H3 workflow.
  • Reward model system: supports three types of reward models, Pointwise, Pairwise, and Groupwise, with multiple pre-registered reward models built in and support for custom reward models; it also supports VLM-as-Judge (remote vLLM / OpenAI-style HTTP).
  • Experiment tracking: training samples and metric curves can be recorded online via Weights & Biases or SwanLab.
  • Acceleration and backends: supports selection of multiple attention backends and can be combined with torch.compile and feature caching; it is recommended to install the kernels package and use backends such as flash_hub.
  • Dataset format: a unified dataset structure, with SFT and offline DPO using strict JSONL with schema_version: 2; text-to-image/video tasks require only plain-text prompts, support train.txt/test.txt or train.jsonl/test.jsonl, and also support negative_prompt; conditional image tasks use an ordered list under the images key.
  • Hardware and dependencies: requires Python 3.10 or higher, PyTorch 2.10 or higher; optional dependencies include deepspeed, etc.; the Bagel adapter requires flash-attn (>=2.5.8) and opencv-python; MiniMax H3 and LTX2 require diffusers>=0.40.0; Qwen-Image 2.1 currently requires the bundled diffusers submodule; PyAV >=17.0.0 is used to decode ordered video/audio reference and target media; TorchAudio 2.10 delegates audio loading and saving to TorchCodec, which also requires FFmpeg shared libraries.
  • Provides a CUDA training image (Python 3.12, uv installation, PyTorch 2.10 + cu129, deepspeed, wandb, released diffusers), located under docker/docker-cuda/.

Usage

  • Installation: install Flow-Factory and optional dependencies according to the documentation, e.g. pip install -e .[wandb] or pip install -e .[swanlab]; for Bagel use pip install -e .[bagel]; for Qwen-Image 2.1, first run git submodule update --init && pip install -e ./diffusers.
  • Configuration: set tracker parameters, reward model names, image_dir/video_dir, etc. in the configuration file; the attention backend selection is located in the unified acceleration block.
  • Training: start training with a simple command; offline examples use a strict V2 manifest and do not require training a reward model.
  • Dataset: prepare data according to a unified structure; SFT and offline DPO use strict JSONL; prompt and input condition encodings are cached, while target/chosen/rejected media are decoded and encoded on the fly, and their VAE latents are not written to the preprocessing cache.
  • Reward model: specify the reward model name in the configuration file to use the built-in reward models; GenEval requires additional dependencies, which can be installed with bash scripts/install_geneval_deps.sh.

Applicable scenarios

  • Research and engineering on diffusion models and Flow-Matching models foronline RL or offline fine-tuning.
  • Training pipelines that require a unified framework to simultaneously handle image, video, and audio-video generation tasks.
  • Scenarios that require custom reward models or the use of VLM-as-Judge for reinforcement learning training.

Limitations and notes

  • Some of the support mentioned in the documentation (such as Qwen-Image 2.1, MiniMax H3, LTX-2) has specific dependency or configuration requirements, and must be installed and set up according to the corresponding instructions.
  • MiniMax H3 requires B=1, no CFG, use of neutral guidance 1.0, and keeping video/audio trajectories separate; video uses shift 12, and audio uses shift 3.
  • Completion of the smoke matrix in the documentation does not represent reward improvement, convergence, or numerical consistency.
  • Information on features, fees, pricing, platforms, or effects not provided in the materials is not yet available.