Papers
Topics
Authors
Recent
Search
2000 character limit reached

Cross-SGA: Semantic Guided Adapter

Updated 10 April 2026
  • Cross-SGA is a dedicated adapter that injects dual-branch cross-attention into a pre-trained UNet, enabling controlled anomaly synthesis.
  • It fuses standard language-driven guidance with anomaly-specific semantic embeddings via a gated mechanism to enhance synthetic realism.
  • Empirical results demonstrate that incorporating Cross-SGA with CSM and ASEA significantly boosts performance metrics such as IS and AUROC.

Cross-SGA (Semantic Guided Adapter) is a dedicated adapter architecture designed for anomaly synthesis within the AnomalyControl framework. It enables fine-grained controllable generation of realistic abnormalities by integrating cross-modal semantic features that arise from both textual and visual prompts. SGA extends each cross-attention block in a pre-trained UNet (notably Stable Diffusion) by introducing a dual-branch attention mechanism, allowing simultaneous and gated fusion of standard language-driven guidance and anomaly-specific cross-modal information coordinated upstream by a Cross-modal Semantic Modeling (CSM) module and the Anomaly-Semantic Enhanced Attention (ASEA) mechanism (He et al., 2024).

1. Architectural Overview of SGA

SGA is implemented as a lightweight adapter module injected into all 16 cross-attention blocks of a Stable Diffusion UNet. At each block, the input to SGA consists of the standard text prompt embedding CC and a cross-modal semantic embedding CC' computed by CSM. Queries ZRB×N×dZ \in \mathbb{R}^{B \times N \times d} are projected as usual, with N1024N\approx 1024 (flattened spatial locations), and d=768d=768 (token dim). SGA introduces a second set of key/value projections (Ksem,VsemK_{\mathrm{sem}}, V_{\mathrm{sem}}) from CC', distinct from the text branch's Ktext,VtextK_{\mathrm{text}}, V_{\mathrm{text}}. This enables dual cross-attention in each block: one over CC and another over CC'. The outputs are fused by a learnable gate parameter CC'0, fixed to CC'1 during inference.

2. Attention Mechanisms and Core Equations

The dual-branch cross-attention operates as follows. For both textual and cross-modal (semantic) branches, attention maps are computed:

CC'2

Corresponding outputs:

CC'3

These are fused in a gated manner:

CC'4

where CC'5 is a scalar, set to CC'6. In matrix form, with SGA introducing trainable parameters only in the new branch:

CC'7

3. Interaction with Cross-Modal Feature Extraction and ASEA

Upstream, the CSM module extracts CC'8 by leveraging ASEA (Anomaly-Semantic Enhanced Attention). ASEA steers the attention of a large pre-trained vision-LLM (VLM) toward ground-truth anomaly regions, optimizing a guidance vector CC'9 so that the attention map ZRB×N×dZ \in \mathbb{R}^{B \times N \times d}0 aligns with the binary anomaly mask ZRB×N×dZ \in \mathbb{R}^{B \times N \times d}1. The alignment penalty is

ZRB×N×dZ \in \mathbb{R}^{B \times N \times d}2

and ZRB×N×dZ \in \mathbb{R}^{B \times N \times d}3 is refined for ZRB×N×dZ \in \mathbb{R}^{B \times N \times d}4 steps using learning rate ZRB×N×dZ \in \mathbb{R}^{B \times N \times d}5. After optimization, the cross-modal embedding is computed:

ZRB×N×dZ \in \mathbb{R}^{B \times N \times d}6

serving as key/value source for SGA's semantic branch.

4. Optimization Objectives and Training Workflow

SGA's and ASEA's training is compartmentalized as follows.

  • ASEA loss for ZRB×N×dZ \in \mathbb{R}^{B \times N \times d}7:

ZRB×N×dZ \in \mathbb{R}^{B \times N \times d}8

  • Diffusion reconstruction loss for SGA parameters ZRB×N×dZ \in \mathbb{R}^{B \times N \times d}9:

N1024N\approx 10240

At each iteration: (1) ASEA updates N1024N\approx 10241 for N1024N\approx 10242 steps with respect to N1024N\approx 10243, (2) N1024N\approx 10244 is frozen, a noisy latent N1024N\approx 10245 is sampled, N1024N\approx 10246 is computed, then SGA weights are updated via N1024N\approx 10247.

5. Hyperparameters and Data-Flow Specifications

  • Stable Diffusion latent space: N1024N\approx 10248, N1024N\approx 10249, d=768d=7680.
  • VLM outputs d=768d=7681 cross-modal tokens: d=768d=7682, token dimension d=768d=7683.
  • Key/Value projections in SGA branch: d=768d=7684.
  • Training: SGA learning rate d=768d=7685, AdamW optimizer, weight decay d=768d=7686.
  • ASEA: d=768d=7687 guidance steps, guidance learning rate d=768d=7688.
  • Classifier-free guidance: each branch (text/cross-modal) independently dropped with d=768d=7689.
  • Gating parameter Ksem,VsemK_{\mathrm{sem}}, V_{\mathrm{sem}}0 fixed at Ksem,VsemK_{\mathrm{sem}}, V_{\mathrm{sem}}1 during both training and inference.

6. Empirical Impact of SGA and Ablation Findings

Performance metrics as measured on MVTec-AD, with relevant IS (Inception Score), IC-LPIPS, and AUROC (AUC-P, AUC-I):

Configuration IS IC-LPIPS AUC-P AUC-I
SD Backbone (no SGA) 1.50 0.18 90.3% 93.0%
+SGA (visual adapter only) 1.66 0.23 92.7% 95.4%
+CSM (cross-modal) + SGA 1.69 0.25 93.1% 95.8%
Full (CSM+ASEA+SGA), Ksem,VsemK_{\mathrm{sem}}, V_{\mathrm{sem}}2 1.84 0.35 99.5% 99.3%

These results indicate SGA alone contributes a 0.16 increase in IS and a 2.4 percentage point increase in AUC-I. When combined with cross-modal feature extraction and attention guidance, the complete AnomalyControl stack achieves substantial gains in the realism and controllability of synthesized anomalies, with near-perfect anomaly/pixel-level detection AUROC scores (He et al., 2024). This suggests SGA is instrumental in closing the realism gap for synthetic abnormalities, especially when paired with attention-optimized cross-modal priors.

7. Significance and Outlook

Cross-SGA constitutes a dedicated and modular solution for infusing semantic and anomaly-specific guidance into conditional diffusion models. Its gated dual-attention and reliance on externally steered cross-modal embeddings distinguish it from conventional text-driven adapters, conferring enhanced ability to encode fine-grained abnormal traits for downstream inspection and detection tasks. Subsequent research may extend the Cross-SGA mechanism to other generative pipelines or further refine the interaction between semantic adapters and upstream attention guidance processes.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Cross-SGA.