Prompting diffusion representations for cross-domain semantic segmentation

Rui Gong, Martin Danelljan, Han Sun, Julio Delgado Mangas, Luc Van Gool · DOI · OpenReview

Abstract

Semantic segmentation models often struggle with domain shift, such as transitioning from synthetic training data to real-world adverse weather conditions. This paper demonstrates that text-to-image diffusion models, like Stable Diffusion, serve as robust backbones for cross-domain segmentation. By leveraging the inherent disentanglement of object identity and style in diffusion representations, the authors introduce a framework using category and scene prompts. Through prompt randomization and a parameter-efficient test-time tuning strategy, the proposed method achieves state-of-the-art performance on several benchmarks, including GTA-to-Cityscapes and Cityscapes-to-ACDC, without requiring complex image-to-image translation.

Introduction: The Challenge of Domain Shift

Deep learning models for semantic segmentation are notoriously fragile when faced with domain shift—the discrepancy between training (source) and deployment (target) environments. A model trained on clear, synthetic data often fails in real-world scenarios involving rain, fog, or nighttime. Existing solutions typically rely on heavy data augmentation or complex domain adaptation techniques that can lead to overfitting or catastrophic forgetting.

Diffusion models provide disentangled representations that separate object identity from style, unlike standard backbones.

The core insight of this work is that diffusion models, trained to generate diverse images from text prompts, naturally learn to separate "what" an object is from "how" it appears. This disentanglement makes them exceptionally well-suited for robust semantic segmentation.

Methodology

The authors utilize a frozen Stable Diffusion backbone and introduce two key prompting strategies to harness its representational power.

Category and Scene Prompting

Instead of processing images in isolation, the model is conditioned on text prompts. Category prompts (e.g., "a photo of a car") provide a semantic prior that helps the model identify objects even in low-visibility conditions. Scene prompts (e.g., "a night photo") allow the model to explicitly account for domain-specific styles, effectively "setting aside" the style to focus on invariant object features.

The proposed framework includes training with consistency loss across various scene prompts and efficient test-time adaptation via learnable tokens.

Robust Training and Adaptation

  1. Prompt Randomization & Consistency Loss: During training, the same image is paired with different random scene prompts. A consistency loss is applied to ensure the segmentation output remains invariant to the prompt, forcing the backbone to extract domain-agnostic features.
  2. Test-Time Domain Adaptation (TTDA): To adapt to a specific new environment at inference time, the model optimizes a single learnable prompt token (768 dimensions) using pseudo-labels. This approach is highly parameter-efficient, avoiding updates to the backbone weights and maintaining stability.

Experimental Results

The method was evaluated on several rigorous benchmarks, including synthetic-to-real (GTA/SYNTHIA → Cityscapes) and clear-to-adverse (Cityscapes → ACDC/Dark Zurich) transitions.

  • State-of-the-Art Performance: On GTA → Cityscapes, the model achieved 52.2 mIoU, outperforming previous methods like AugFormer.
  • Robustness to Adverse Weather: On the Cityscapes → ACDC task, the method reached 62.0 mIoU, a significant improvement over the previous SOTA (DAFormer), which surprisingly had access to target domain data during its training phase.
  • Efficiency: The test-time adaptation requires tuning only 768 parameters, making it significantly faster and more stable than traditional methods that fine-tune entire network layers.

Key Insights

  • Generative Priors: Diffusion backbones, even without specific tuning, generalize better than standard supervised or self-supervised backbones (e.g., Swin, MAE).
  • Prompting as Style Anchoring: Explicitly conditioning on the scene (e.g., "night") acts as an anchor, allowing the segmentation head to focus on structural features that remain constant across domains.
  • Simplicity over Complexity: Superior results are achieved by manipulating text conditioning rather than employing complex image-to-image translation pipelines like CycleGAN.

Conclusion and Future Work

This research highlights the untapped potential of generative diffusion models for discriminative tasks like semantic segmentation. While the current approach uses manual prompt templates, future work could integrate Large Language Models (LLMs) to automate prompt generation. Additionally, while parameter-efficient, the computational cost of diffusion backbones remains a consideration for real-time edge deployment. Expanding this "promptable representation" framework to other dense prediction tasks, such as instance segmentation, remains a promising direction.

Summary updated

BibTeX
@misc{gong2023prompting,
  author = {Rui Gong and Martin Danelljan and Han Sun and Julio Delgado Mangas and Luc Van Gool},
  title = {{Prompting diffusion representations for cross-domain semantic segmentation}},
  year = {2023},
  eprint = {2307.02138},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2307.02138},
}
Figure