TopoDiffusionNet: A Topology-aware Diffusion Model

Saumya Gupta, Dimitris Samaras, Chao Chen

TL;DR

TopoDiffusionNet (TDN) is the first framework to integrate topological constraints directly into the diffusion training process. By leveraging persistent homology—a tool from topological data analysis—TDN ensures that generated images strictly adhere to structural requirements, such as the exact number of objects or enclosed regions. This allows it to significantly outperform current state-of-the-art models like DALL-E 3 and Stable Diffusion in spatial reasoning tasks.

What Problem Does This Paper Address?

Current text-to-image (T2I) diffusion models are masters of texture and style but surprisingly poor at basic logic and "counting." If you ask a model for "exactly five giraffes," you might get four, six, or a surreal giraffe-hydra. This is because these models lack an inherent understanding of topology—the branch of mathematics concerned with the properties of geometric objects that are preserved under continuous deformation.

Specifically, models struggle with Betti numbers, which measure fundamental topological features:

  • 0-dimensional topology ($\beta_0$): The number of connected components (e.g., "How many distinct animals are in this field?").
  • 1-dimensional topology ($\beta_1$): The number of holes or enclosed regions (e.g., "How many blocks does this road network create?").

For applications like robotics, urban planning, or medical imaging, "close enough" isn't good enough. We need models that can respect these fundamental structural constraints.

Comparison of diffusion models on topological constraints. TopoDiffusionNet successfully generates exactly 5 giraffes (0-dim) and 4 road regions (1-dim), while baselines like DALL-E 3 and Stable Diffusion fail.

Methods

The authors propose TopoDiffusionNet (TDN), which introduces a topology-aware objective function into the diffusion denoising process.

  1. Persistent Homology (PH): The core innovation is using PH to "see" through the noise. During the diffusion process, intermediate images are incredibly noisy. PH treats an image like a topographical map, identifying "peaks" (objects) and "valleys" (holes). It tracks which structures are "salient" (persistent) and which are just random noise.
  2. The Topology Loss ($\mathcal{L}_{top}$): The researchers designed a differentiable loss function composed of two parts:
  3. $\mathcal{L}_{preserve}$: This identifies the top $c$ topological structures (where $c$ is the user's constraint) and "amplifies" them, ensuring they survive the denoising process.
  4. $\mathcal{L}_{denoise}$: This identifies all other "spurious" structures and suppresses them, preventing the model from generating extra, unwanted objects.
  5. Conditioning: The model is conditioned on the desired Betti number $c$. This embedding is injected into the U-Net's residual blocks alongside the standard timestep embedding.

Importantly, TDN generates spatial masks first. These masks, which now have the perfect topology, can then be fed into a secondary model like ControlNet to produce high-quality, realistic images.

Datasets

The model was evaluated on four diverse datasets to prove its versatility:

  • Shapes: A synthetic dataset of circles, triangles, and rectangles (0-dim constraints).
  • COCO (Animals): Real-world animal masks used to test object counting (0-dim constraints).
  • CREMI: An electron microscopy dataset of biological cells (1-dim constraints/holes).
  • Google Maps: Aerial photos of New York City used to test road network layouts (1-dim constraints/regions).

Key Insights and Ideas

  • Noise is the Friend of Topology: One might think noise would break topological analysis. However, the authors show that Persistent Homology is uniquely robust to noise, making it the perfect "guiding hand" for the early, chaotic stages of diffusion.
  • Differentiability is Key: By mapping topological structures back to specific pixel coordinates (maxima and saddle points), the authors made a traditionally "discrete" mathematical concept (counting) differentiable. This allows the model to learn via standard backpropagation.
  • Beyond Counting: While 0-dim topology is essentially counting, 1-dim topology is much harder. TDN is the first to show that diffusion models can be forced to create specific "loop" structures, which is vital for generating things like circuit diagrams or road maps.

Key Results

TDN showed massive improvements over baselines like Stable Diffusion, DALL-E 3, and Attention Refocusing (AR):

  • Accuracy: On the Shapes dataset, TDN achieved 94.7% accuracy in generating the correct number of objects, compared to just 75% for a standard conditioned diffusion model (ADM-T) and ~68% for DALL-E 3.
  • Complex Structures: In the Google Maps (1-dim) task, TDN reached 83.1% accuracy in creating the correct number of regions, while the baseline struggled at 54.9%.
  • Efficiency: TDN reaches a "clean" topological state much earlier in the denoising process than other models, effectively accelerating the generation of structurally sound images.

Limitations and Future Work

  • Two-Step Process: Currently, TDN focuses on generating the mask (the layout), which then requires a tool like ControlNet to become a final image. The authors suggest that future work could integrate this topological loss directly into RGB image generation.
  • Computational Overhead: Calculating persistent homology at every training step is computationally more expensive than standard diffusion training, though the authors note it is manageable.
  • Higher Dimensions: The paper focuses on 2D images ($\beta_0$ and $eta_1$). Extending this to 3D volumes (like medical CT scans) would be a logical but challenging next step.

Summary updated

BibTeX
@inproceedings{gupta2025topodiffusionnet,
  author = {Saumya Gupta and Dimitris Samaras and Chao Chen},
  title = {{TopoDiffusionNet: A Topology-aware Diffusion Model}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=ZK1LoTo10R},
}
Figure