Discovering Latent Graphs with GFlowNets for Diverse Conditional Image Generation

Bailey Trang, Parham Saremi, Alan Q. Wang, Fangrui Huang, Zahra TehraniNasab, Amar Kumar, Tal Arbel, Li Fei-Fei, Ehsan Adeli

TL;DR

Rainbow is a novel conditional image generation framework that addresses prompt ambiguity by decomposing input conditions into diverse latent graph representations using Generative Flow Networks (GFlowNets). By integrating these diverse condition representations into frozen, pretrained generative models, Rainbow synthesizes highly varied, high-fidelity images across both natural and medical domains without relying on superficial random seed variations.

What Problem Does This Paper Address?

When you give an image generator an ambiguous prompt like "a sunset scene with a mountain," there isn't just one correct answer. The scene could take place in spring or winter, under clear skies or heavy clouds. Similarly, in medical imaging, generating a brain MRI for a "65-year-old male" involves massive inherent uncertainty because real human anatomy varies wildly (e.g., different ventricle sizes), even given identical demographic factors.

Traditional conditional generative models struggle to capture this multi-modal diversity. They typically rely on two flawed workarounds:

  1. Tweaking random seeds: This often results in superficial changes or repetitive layouts rather than meaningful semantic diversity.
  2. Prompt expansion via LLMs: Using an LLM to add verbal details works only for text prompts and introduces the LLM's own systemic biases.

Rainbow solves this by directly discovering and exploring the uncertainty space within the latent representation of any condition type (textual or non-textual).

Methods

Rainbow introduces a three-step inference pipeline that can be wrapped around any pretrained, frozen Latent Diffusion Model (LDM):

  1. Condition Encoding: An input condition $C$ is mapped to an initial latent representation $c$ via a standard condition encoder.
  2. Latent Graph Generation via GFlowNets: Instead of directly feeding $c$ into the diffusion model, Rainbow passes it to a graph generator ($Q_{GFN}$). This module uses a Generative Flow Network (GFlowNet) to sample $M$ diverse trajectories (sequences of edges) over an unconstrained latent graph. GFlowNets are uniquely suited here because they sample trajectories proportionally to a reward function, preventing the model from collapsing to a single "optimal" mode and ensuring wide exploration of the prompt's uncertainty space.
  3. Graph Decoding & Image Synthesis: A graph decoder ($Q_D$) uses a Recurrent Neural Network (RNN) and a pooling layer to convert these trajectories into $M$ distinct condition representations ($\hat{c}^{1:M}$). These are then combined with the original condition and fed into the LDM to generate a diverse set of output images.
Figure 1: Rainbow operates by transforming an input condition into diverse images. Initially, it employs the pretrained condition encoder to derive an initial representation of the input condition (which contains uncertainty about locations or objects with the given prompt in this example). Then, a graphs generator produces multiple trajectories over a graph that reflect the input condition. These graphs are encoded into new latent condition representations. New condition representations and a latent noisy image are processed through the Latent Diffusion Model to acquire denoised image latents, which are subsequently decoded into diverse output images.

During training, the graph generator and decoder are optimized from scratch using a Detailed Balance Objective (DBO), where the reward is tied to the negative mean squared error of the diffusion denoising process.

Datasets

The authors evaluated Rainbow across three distinct domains:

  • Natural Images: The Flickr30k dataset (~30k image-caption pairs) representing daily-life scenes with high stylistic and object uncertainty.
  • 3D Brain MRIs: A curated dataset of ~27k healthy brain scans aggregated from major clinical studies (ADNI, ABCD, HCP, PPMI, and AIBL), where anatomical details like ventricle sizes vary naturally.
  • Chest X-rays: The CheXpert dataset (~170k training images) containing diverse medical devices, anatomical structures, and pathologies.

Key Insights and Ideas

  • GFlowNets as Latent Decomposers: While GFlowNets are traditionally used to construct discrete objects like molecules or gene networks, Rainbow uniquely applies them to sample diverse paths in a latent space, effectively "decomposing" a single ambiguous prompt into its constituent semantic possibilities.
  • Unconstrained, Interpretable Latent Graphs: The edges of the latent graph are randomly initialized and not explicitly predefined. Remarkably, the model implicitly learns to group edges into highly interpretable semantic features. For example, by clustering the generated images, the authors isolated specific edge sets that correspond directly to "spring," "winter," or the presence of "medical support devices." Manually appending these discovered edges allows for fine-grained, concept-specific image editing.

Key Results

Rainbow consistently outperformed state-of-the-art baselines (including Stable Diffusion 2-1/3.5, CADS, and PAG) in both diversity and image quality.

  • Natural Images: Rainbow achieved the highest Inception Score (IS = 10.45) and Inception Vendi Score (VS = 28.90), proving it generates higher quality and more diverse images than standard baselines.
  • Medical Imaging Fidelity: In the 3D Brain MRI synthesis task, Rainbow achieved a significantly lower FID score (0.3149) compared to a standard LDM (0.3288). It successfully captured realistic biological variations (like varying ventricle sizes for older adults) where baselines suffered from mode collapse.
Quantitative comparison showing Rainbow achieving the best trade-off between image quality (IS) and diversity (VS).
Qualitative comparison of sunset scenes generated by baselines and Rainbow, demonstrating Rainbow's superior seasonal and lighting diversity.

Limitations and Future Work

Despite its strong performance, Rainbow has a few limitations:

  • Computational Overhead: Sampling $M$ trajectories in parallel during training increases computational resource demands.
  • Manual Graph Interpretation: While the latent graphs capture distinct concepts, mapping specific edges to human-understandable features currently requires post-hoc clustering. Automating this semantic mapping is an open area for future work.
  • Clinical Safety: For medical applications, the authors note that generated counterfactual images must undergo rigorous anatomical plausibility checks by domain experts before being deployed in clinical workflows.

Summary updated

Abstract

Capturing diversity is crucial in conditional and prompt-based image generation, particularly when conditions contain uncertainty that can lead to multiple plausible outputs. To generate diverse images reflecting this diversity, traditional methods often modify random seeds, making it difficult to discern meaningful differences between samples, or diversify the input prompt, which is limited in verbally interpretable diversity. We propose Rainbow, a novel conditional image generation framework, applicable to any pretrained conditional generative model, that addresses inherent condition/prompt uncertainty and generates diverse plausible images. Rainbow is based on a simple yet effective idea: decomposing the input condition into diverse latent representations, each capturing an aspect of the uncertainty and generating a distinct image. First, we integrate a latent graph, parameterized by Generative Flow Networks (GFlowNets), into the prompt representation computation. Second, leveraging GFlowNets' advanced graph sampling capabilities to capture uncertainty and output diverse trajectories over the graph, we produce multiple trajectories that collectively represent the input condition, leading to diverse condition representations and corresponding output images. Evaluations on natural image and medical image datasets demonstrate Rainbow's improvement in both diversity and fidelity across image synthesis, image generation, and counterfactual generation tasks.
BibTeX
@inproceedings{trang2025discovering,
  author = {Bailey Trang and Parham Saremi and Alan Q. Wang and Fangrui Huang and Zahra TehraniNasab and Amar Kumar and Tal Arbel and Li Fei-Fei and Ehsan Adeli},
  title = {{Discovering Latent Graphs with GFlowNets for Diverse Conditional Image Generation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=PhHrlDKcx1},
}
Figure