Organizations: Institute of Information Engineering, CAS · School of Cyber Security, University of Chinese Academy of Sciences · State Key Laboratory of AI Safety, Institute of Computing Technology, CAS · Beijing Academy of Artificial Intelligence · School of Cyber Science and Tech., Shenzhen Campus of Sun Yat-sen University · Alibaba Group · School of Computer Science and Tech., University of Chinese Academy of Sciences · Key Laboratory of Big Data Mining and Knowledge Management, CAS
As powerful generative models, text-to-image diffusion models have recently been explored for discriminative tasks. A line of research focuses on adapting a pre-trained diffusion model to semantic segmentation without any further training, leading to training-free diffusion segmentors. These methods typically rely on cross-attention maps from the model's attention layers, which are assumed to capture semantic relationships between image pixels and text tokens. Ideally, such approaches should benefit from more powerful diffusion models, i.e., stronger generative capability should lead to better segmentation. However, we observe that existing methods often fail to scale accordingly. To understand this issue, we identify two underlying gaps: (i) cross-attention is computed across multiple heads and layers, but there exists a discrepancy between these individual attention maps and a unified global representation. (ii) Even when a global map is available, it does not directly translate to accurate semantic correlation for segmentation, due to score imbalances among different text tokens. To bridge these gaps, we propose two techniques: auto aggregation and per-pixel rescaling, which together enable training-free segmentation to better leverage generative capability. We evaluate our approach on standard semantic segmentation benchmarks and further integrate it into a generative technique, demonstrating both improved performance broad applicability. Codes are at https://github.com/Darkbblue/goca.
Figures & tables
Figure 1: (a) Previous training-free diffusion segmentors scale poorly with the generative power of diffusion models, which inspires our study to enable such scaling. (b) We have identified two gaps from individual cross-attention maps to semantic correlation, which have been preventing the aforementioned scaling.
Figure 2: Attention maps in different heads and layers show a certain collaboration pattern, each focusing on distinct aspects of the image.
Figure 3: Overview of our method. (a) and (b) consist the auto aggregation part, and (c) is the per-pixel rescaling part. (a) Head-wise aggregation reformulates multi-head attention as vector summation and then uses the dot-product similarity between each vector and the summed vector as head weights. (b) Layer-wise aggregation computes pseudo self-attention based on a chosen dense feature, regards it as the pseudo global attention, and finally uses the similarity between per-layer self-attention maps and this pseudo global attention as layer weights. (c) We exclude semantic special tokens and stop word tokens, only considering content word tokens, to rescale their attention scores to sum to 1, followed by a conventional per-token re-normalization.
Figure 4: Illustration of imbalance phenomena in raw global attention scores.
Type
Method
VOC
Context
COCO-Object
Cityscapes
ADE20K
Non-DM
MaskCLIP
38.8
23.6
20.6
10.0
9.8
ReCO
25.1
19.9
15.7
19.3
11.2
Pre-Trained DM
DiffSegmentor
60.1
27.5
37.9
-
-
MaskDiffusion
29.9
-
-
17.1
-
FTTM 1
48.9
30.0
34.6
12.3
20.3
Vanilla
SD v1.5
44.3
32.3
32.3
11.8
18.0
Table 1: Experimental results on standard semantic segmentation benchmarks, evaluated using mIoU ↑ . The best and runner-up are bold and underlined . 1 Reproduced by us because the original setting is different, details in Appendix A .
Figure 5: Visualization of per-class attention maps and the final segmentation using Vanilla and Ours . The input image is as shown in the top-left corner, and the prompt is “a cat on grass before wall”.
Head
Layer
Rescaling
SD v1.5
SD XL
Vanilla
Vanilla
Vanilla
44.3
51.1
Vanilla
Manual
Vanilla
51.1
-
Ours
Vanilla
Vanilla
44.8
56.1
Vanilla
Ours
Vanilla
52.1
51.3
Vanilla
Vanilla
Ours
52.6
51.4
Ours
Ours
Ours
60.7
65.6
Table 2: Ablation results evaluated using mIoU ↑ on Pascal VOC 2012 dataset, to evaluate the contribution of auto aggregation and per-pixel rescaling. The best result is marked as bold .
Method
CFG=2.0
CFG=3.0
CFG=5.0
CFG=7.5
CFG=10.0
FID
CLIP
FID
CLIP
FID
CLIP
FID
CLIP
FID
CLIP
SD v1.5
CFG
37.84
29.84
24.22
30.78
19.27
31.34
18.98
31.53
19.38
31.60
S-CFG
36.45
29.95
23.58
30.84
19.15
31.35
18.90
31.53
19.38
31.60
Ours+S-CFG
35.23
30.05
22.80
30.93
18.82
31.42
18.84
31.57
19.35
31.62
Table 3: Experimental results as the integration of an advanced generative technique, S-CFG [ 31 ] , evaluated using FID ↓ and CLIP ↑ . The top row shows the values of CFG strength, which is a hyperparameter. The best and runner-up are bold and underlined .
Figure 6: Generated images with SD v1.5. While Vanilla improves the background quality over CFG , Ours further enhances it.
Appendix figures & tables12 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 7: Head-wise auto-aggregation weights in a certain layer of SD v1.5.
Figure 8: Layer-wise auto-aggregation weights of SD v1.5, using the cat input as shown in Figure 7 .
Method
Running Time (s)
SD v1.5 Vanilla
753.53
SD v1.5 Baseline
750.09
SD v1.5
767.73
Appendix
Table 4: Running time comparison on VOC 2012 dataset with the SD v1.5 model.
Model
Head Metric
Layer Metric
mIoU (Context)
SD v1.5
dot-product
dot-product
40.4
l2-norm
dot-product
42.0
cosine
dot-product
42.0
dot-product
mse
33.9
dot-product
iou-like
39.2
SD XL
dot-product
dot-product
42.3
Appendix
Table 5: Ablation results to compare different similarity metrics for head- and layer-wise aggregation.
Model
Timestep
IoU (Context)
SD v1.5
50
40.1
100
40.4
150
40.3
200
39.7
Appendix
Table 6: Ablation results to compare different timesteps for feature extraction.
Model
Dense Layer
Dense Feature Quality (mIoU)
Resolution
IoU (Context)
SD v1.5
up-level3-repeat1-vit-block0-self-q
31.64
64
39.4
up-level2-repeat1-vit-block0-cross-q
53.58
32
40.4
up-level2-repeat2-vit-block0-cross-q
46.24
32
40.4
up-level1-repeat1-vit-block0-cross-q
49.04
16
40.3
Appendix
Table 7: Ablation results to compare different dense feature layers for layer-wise auto aggregation.
Method
Context
Original
60.4
GPT-4o w/o background
47.1
GPT-4o w/ background
41.3
SD XL
43.2
Appendix
Table 8: Ablation results where we modify the implementation of DiffSegmenter [ 36 ] , a SOTA method, and experiment on Context dataset.
Method
FID (1)
FID (2)
FID (3)
FID (AVG)
CLIP (1)
CLIP (2)
CLIP (3)
CLIP (AVG)
CFG
19.27
19.97
21.09
20.11±0.92
31.34
31.12
30.95
31.13±0.20
S-CFG
19.15
18.52
20.41
19.36±0.96
31.35
31.26
31.16
31.25±0.10
Ours+S-CFG
18.82
18.01
20.32
19.05±1.17
31.42
31.28
31.16
31.28±0.13
Appendix
Table 9: Experimental results with three different seeds under CFG=5.0 setting for FID and CLIP score evaluation.
Figure 9: Generated images with SD v1.5 using CFG=7.5 setting. Corresponding prompts and why Ours is considered better are annotated above each row of images.
Figure 10: In a simple scene, though there are quality gaps in per-class maps, the final segmentation maps are almost identical.
Figure 11: In a moderately complex scene, Ours gains significant quality improvement, especially in the background regions.
Figure 12: All models and both methods fail to capture the small person object in the complex scene, as latent diffusion models compress the original image with VAE. Nevertheless, we can still observe obvious quality enhancement in the segmentation of background regions, covering the sky, trees, and the road.