Contrastive Diffusion Guidance for Spatial Inverse Problems

Sattwik Basu, Chaitanya Amballa, Zhongweiyang Xu, Jorge Vančo Sampedro, Srihari Nelakuditi, Romit Roy Choudhury

Introduction

In classic inverse problems, the goal is to recover an unknown signal (such as a clean, high-resolution image) from a noisy or degraded measurement. Modern generative solvers, particularly diffusion models, have made massive strides in this area. They typically operate by using the gradient of a likelihood function to "steer" the generative denoising process toward a solution that matches the observed data.

However, this standard approach breaks down when applied to spatial inverse problems. A prime example is attempting to reconstruct a building's floorplan solely from the walking trajectories of people inside it. To address this, researchers have introduced CoGuide, a novel framework that uses contrastive learning to map floorplans and trajectories into a shared, smooth embedding space. This provides a stable "surrogate likelihood" that allows diffusion models to navigate complex, discrete optimization landscapes where traditional gradients fail.

The Challenge of Spatial Inverse Problems

To understand why standard diffusion solvers fail here, we must look at the "forward operator." In the floorplan-from-trajectory problem, the forward operator is the path-planning process itself—essentially, a human or an algorithm deciding how to navigate from point A to point B around obstacles.

Example of a target floorplan and the corresponding observed human trajectories.

This path-planning process is inherently non-smooth and non-differentiable. A microscopic change in the environment—like opening a tiny door in a previously solid wall—might completely alter the optimal path, leading to a massive, discontinuous jump in the measurement space.

Different path-planning algorithms produce highly variable trajectories, illustrating the non-smooth nature of the forward operator.

Because the gradients of these path-planners are either non-existent or wildly unstable, standard likelihood-based guidance becomes erratic. The diffusion solver either fails to converge or produces nonsensical layouts that physically conflict with the observed paths.

The CoGuide Framework

To sidestep the messy gradients of the forward operator, the authors developed CoGuide, which reformulates the guidance process in a smoother, learned space:

  1. Contrastive Embedding Space: Instead of calculating gradients through a discrete path-planner, CoGuide trains two separate encoders (one for floorplans, one for trajectories) using a contrastive objective (InfoNCE). This forces matching floorplan-trajectory pairs to cluster closely together in a shared embedding space, while pushing mismatched pairs far apart.
  2. Surrogate Likelihood Guidance: The core theoretical insight of the paper is demonstrating that the similarity score in this learned embedding space serves as a valid approximation of the true likelihood score. This provides a "smooth" gradient that the diffusion model can reliably use to steer the denoising process toward the true posterior.
  3. Intersection Penalty: To ensure the generated floorplans are physically plausible, an intersection penalty is applied during inference. This simple term strongly discourages the model from hallucinating walls on top of the observed walking trajectories.
  4. Adam-based Guidance: Rather than using standard Stochastic Gradient Descent (SGD) during the diffusion sampling steps, CoGuide employs the Adam optimizer. This helps the model navigate the non-convex posterior landscape more effectively, yielding better results when using accelerated sampling techniques like DDIM.

Experimental Setup and Key Results

The researchers evaluated CoGuide primarily on the HouseExpo dataset, a large-scale collection of ~35,000 2D floorplans, using synthetic A* trajectories at sparse, moderate, and dense levels. They also tested the model's real-world generalization using actual walking trajectories collected via Ultrawideband (UWB) sensors in student apartments.

Key Findings: * Quantitative Superiority: CoGuide significantly outperformed competitive baselines like Diffusion Posterior Sampling (DPS) and DiffPIR, particularly when data was sparse. In the sparse trajectory regime, CoGuide achieved an impressive F1 score of 0.91, compared to just 0.79 for the best-performing DPS variant. * Robustness to Sparsity: While standard Classifier-Free Guidance (CFG) models tend to overfit to specific training distributions, CoGuide’s embedding-based approach generalizes much better to the ill-posed nature of having very few trajectory points. * Qualitative Consistency: Visual results confirmed that CoGuide produces cleaner floorplans that strictly respect the boundaries of the input trajectories. Competing methods frequently "hallucinated" walls across known walking paths. * Real-world Generalization: On the noisy, real-world UWB data, CoGuide successfully inferred room structures that CFG-based models entirely missed or misplaced.

(Note: The authors also demonstrated CoGuide's versatility on a "blind" audio restoration task using the MAESTRO dataset, proving the method extends beyond spatial mapping.)

Limitations and Future Directions

While CoGuide represents a significant step forward for spatial inverse problems, the current implementation operates in simplified 2D environments without furniture. In reality, human paths are heavily influenced by clutter (tables, chairs, etc.), which adds further complexity to the forward operator.

Furthermore, the model is currently trained on optimal A* trajectories, whereas real human walking behavior is often sub-optimal, exploratory, or noisy. Future work could involve training on more diverse human motion models. Finally, the success of this contrastive surrogate approach suggests a highly promising route toward solving generalized "blind" inverse problems where the degradation process is entirely unknown.

Summary updated

BibTeX
@inproceedings{basu2026contrastive,
  author = {Sattwik Basu and Chaitanya Amballa and Zhongweiyang Xu and Jorge Vančo Sampedro and Srihari Nelakuditi and Romit Roy Choudhury},
  title = {{Contrastive Diffusion Guidance for Spatial Inverse Problems}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=B4BSxOdKYU},
}
Figure