--- license: apache-2.0 library_name: diffusers datasets: - ILSVRC/imagenet-1k --- # Gaussian Mixture Flow Matching Models (GMFlow) Model used in the paper: **Gaussian Mixture Flow Matching Models**
[Hansheng Chen](https://lakonik.github.io/)1, [Kai Zhang](https://kai-46.github.io/website/)2, [Hao Tan](https://research.adobe.com/person/hao-tan/)2, [Zexiang Xu](https://zexiangxu.github.io/)3, [Fujun Luan](https://research.adobe.com/person/fujun/)2, [Leonidas Guibas](https://geometry.stanford.edu/?member=guibas)1, [Gordon Wetzstein](http://web.stanford.edu/~gordonwz/)1, [Sai Bi](https://sai-bi.github.io/)2
1Stanford University, 2Adobe Research, 3Hillbot
[[arXiv](https://arxiv.org/abs/2504.05304)] [[GitHub](https://github.com/Lakonik/GMFlow)] ## Usage Please first install the [official code repository](https://github.com/Lakonik/GMFlow). We provide a Diffusers pipeline for easy inference. The following code demonstrates how to sample images from the pretrained GM-DiT model using the GM-ODE 2 solver and the GM-SDE 2 solver. ```python import torch from huggingface_hub import snapshot_download from lib.models.diffusions.schedulers import FlowEulerODEScheduler, GMFlowSDEScheduler from lib.pipelines.gmdit_pipeline import GMDiTPipeline # Currently the pipeline can only load local checkpoints, so we need to download the checkpoint first ckpt = snapshot_download(repo_id='Lakonik/gmflow_imagenet_k8_ema') pipe = GMDiTPipeline.from_pretrained(ckpt, variant='bf16', torch_dtype=torch.bfloat16) pipe = pipe.to('cuda') # Pick words that exist in ImageNet words = ['jay', 'magpie'] class_ids = pipe.get_label_ids(words) # Sample using GM-ODE 2 solver pipe.scheduler = FlowEulerODEScheduler.from_config(pipe.scheduler.config) generator = torch.manual_seed(42) output = pipe( class_labels=class_ids, guidance_scale=0.45, num_inference_steps=32, num_inference_substeps=4, output_mode='mean', order=2, generator=generator) for i, (word, image) in enumerate(zip(words, output.images)): image.save(f'{i:03d}_{word}_gmode2_step32.png') # Sample using GM-SDE 2 solver (the first run may be slow due to CUDA compilation) pipe.scheduler = GMFlowSDEScheduler.from_config(pipe.scheduler.config) generator = torch.manual_seed(42) output = pipe( class_labels=class_ids, guidance_scale=0.45, num_inference_steps=32, num_inference_substeps=1, output_mode='sample', order=2, generator=generator) for i, (word, image) in enumerate(zip(words, output.images)): image.save(f'{i:03d}_{word}_gmsde2_step32.png') ``` ## Citation ``` @misc{gmflow, title={Gaussian Mixture Flow Matching Models}, author={Hansheng Chen and Kai Zhang and Hao Tan and Zexiang Xu and Fujun Luan and Leonidas Guibas and Gordon Wetzstein and Sai Bi}, year={2025}, eprint={2504.05304}, archivePrefix={arXiv}, primaryClass={cs.LG}, url={https://arxiv.org/abs/2504.05304}, } ```