arXiv:2609.05864cs.CVSep 2026

Manuscript Offprint

arXiv:2609.05864

Hierarchical Prompt Injector for Domain Generalization Segmentation

Xin Kun Lin, Ruoyu Guo, Jiaqi Guo, Maurice Pagnucco, Yang Song

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Xin Kun Lin®, Ruoyu Guo®, Jiaqi Guo®, Maurice Pagnucco®, and Yang Song®

School of Computer Science and Engineering, University of New South Wales, Sydney, Australia

{xin_kun.lin,morri,yang.song1}@unsw.edu.au

{ruoyu.guo,jiaqi.guo}@student.unsw.edu.au

Abstract. Domain Generalized Semantic Segmentation (DGSS) is a challenging task, as vision models often rely on low-level appearance cues that change across domains. In contrast, structural attributes exhibit cross-domain stability, motivating the use of structural priors for DGSS. Existing methods use prompt learning to transfer such priors into DGSS models, but typically encode each class as a single holistic prompt. Moreover, these methods apply prompts uniformly to all pixels, offering no mechanism to adapt when only a subset of object regions is visible due to viewpoint changes, occlusion, and environmental variation. We address this with Spatial Hierarchical Prompts (SHP) that enrich each class with region-level geometric anchors capturing structural appearance from distinct viewing angles, ensuring complementary coverage under arbitrary viewpoints. Additionally, we propose the Hierarchical Prompt Injector (HPI), which enables spatially adaptive prompt injection in foundation models. HPI spatially grounds prompts by modeling their semantic relevance and spatial influence with visual features. Considering the difficulty of learning spatially and semantically aware prompt injection, we further introduce auxiliary supervision to align hierarchical prompts with their corresponding object regions. We achieve 70.62% and 72.74% mIoU on synthetic-to-real and real-to-real benchmarks, respectively. Code and checkpoints are released at https://github.com/MosukFate/HPI.

Keywords: Domain Generalization · Semantic Segmentation · Vision-Language Models · Prompt Learning

1 Introduction

Domain generalized semantic segmentation (DGSS) aims to learn segmentation models from labeled source domains that can generalize to unseen target domains, where no target data are available during training [39]. Classical DGSS

  • Equal contribution.

X. Lin et al.

Figure

Fig. 1: Class-level prompts (left) versus our Spatial Hierarchical Prompts (right). Class-level prompts encode each category as a single holistic sentence, producing diffuse attention that spreads across background regions. SHP decomposes each class into region-level prompts built from four complementary components: Region Cue, Part, Geometry, and Boundary Relation.

strategies, such as style augmentation [61, 64] and frequency-domain perturbation [6, 31, 47], seek to reduce the model's reliance on appearance cues, but operate solely on low-level statistics without exploiting the underlying geometric structure of objects. Yet recent studies [12, 20, 37] have shown that structural attributes exhibit strong cross-domain stability, offering more reliable anchors for pixel-wise recognition. Accordingly, prompt learning in Vision-Language Models (VLMs) such as CLIP [38] has become a mainstream strategy for learning such structural attributes [24, 26, 65, 66].

Recent prompt-learning methods construct textual prompts, such as class names [35, 40], short domain descriptors [19, 23], or learnable context tokens [65, 66], to guide VLM features toward domain-robust representations. However, these methods encode each category as a single holistic sentence, compressing the geometric diversity of a class into one embedding and discarding region-specific structural cues that remain stable across domains. As illustrated in Fig. 1, such class-level prompts produce diffuse attention that fails to distinguish object parts from the background, and the problem is amplified under occlusion where a single description cannot match the limited visible content. Moreover, existing methods either feed prompts only into the decoder without modifying backbone features [19, 35], or inject them into the encoder uniformly across all positions [4, 40], with no mechanism to control where prompt information influences dense visual features. Most also lack explicit supervision over prompt-to-region correspondences [5, 12, 48], leaving the spatial grounding of prompts uncontrolled. This spatial imprecision is further amplified by VLMs pretrained with image-level contrastive objectives [38], which inherently lack the ability to ground language onto individual patches [5, 23, 35]. These limitations raise a core question: how can we encode stable geometric cues at the region level and inject them adaptively when only parts of an object are visible?

We propose a VLM-based framework for DGSS that integrates region-level geometric prompts into visual representations in a spatially adaptive and content-aware manner. We realize this framework with Spatial Hierarchical Prompts (SHP) and the Hierarchical Prompt Injector (HPI). Specifically, SHP decomposes each class into a small set of region-level prompts from distinct viewing angles (e.g., front, side, and rear of a vehicle), each encoding complementary geometric cues, including discriminative parts, shape attributes, and boundary relations. SHP provides stable geometric anchors that remain discriminative under distribution shift, because each regional description is tied to a semantically meaningful object part and emphasizes geometric structure and boundary relations, which are typically more stable across domains than low-level appearance. To make these textual anchors effective for dense prediction, HPI converts SHP embeddings into patch-wise feature residuals and injects them into visual features in a spatially adaptive manner. Since VLMs lack the spatial precision to ground prompts onto individual patches [5,35], we complement the VLM stream with a DINOv2 [34] spatial grounding branch, allowing HPI to inject semantic prompts with finer spatial support.

Within this two-branch injection framework, HPI controls not only whether a prompt is active at a given position, but also how strongly it modulates the features there. This is achieved through two complementary confidence maps. Semantic Alignment Confidence (SAC) measures the content-level relevance between each prompt and patch, determining whether a prompt should be active at a given position. Spatial Coherence Confidence (SCC) captures structural consistency across neighboring patches via a learned spatial confidence map, determining how much an active prompt modulates features while enforcing spatial coherence. We further introduce a Spatial Localization Loss to localize each region-level prompt to its corresponding object region, and a Semantic Consistency Loss to suppress responses from classes absent in the image. Our contributions are summarized as follows:

– We propose Spatial Hierarchical Prompts that decompose each class into region-level geometric anchors from distinct viewing angles. These prompts convert domain-invariant geometric structure into textual priors for pixel-level prediction under domain shifts.

– We develop the Hierarchical Prompt Injector, which adaptively controls whether and how much region-level prompts take effect via SAC and SCC. Our auxiliary losses, Spatial Localization and Semantic Consistency, directly supervise prompt-to-region alignment.

– HPI achieves state-of-the-art performance on synthetic-to-real (70.62 mIoU) and real-to-real (72.74 mIoU) DGSS benchmarks, outperforming strong single-foundation and multi-model baselines on average.

References (66)