arXiv:2611.07061cs.CVNov 2026

Manuscript Offprint

arXiv:2611.07061

Segment What It Can Draw: Querying a Text-to-Image Generator with Its Own Images for Skin Lesion Segmentation

Hongyu Cao, Guangfu Guo, Jinghan Zhang, Dakshak Keerthi Chandra, Ying Zhang, Kunpeng Liu

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

Abstract

Skin lesion segmentation without annotated masks requires the target to be specified through other cues. Existing approaches rely on dermoscopy-specific rules, annotation-derived model priors, or user-selected regions. A general text-to-image diffusion transformer offers a text interface to the target, but its concept-word attention is unreliable on dermoscopy images: in the model's attention-output space, the word-derived skin-to-lesion direction is poorly aligned with the direction separating real skin from real lesions. We show that the direction derived from generated healthy-skin and lesion images is substantially better aligned. Based on this finding, we propose GENIQ, a training-free method that constructs initial skin and lesion prototypes from generated images and refines them using the most skin-like and lesion-like patches from unlabelled dermoscopy images. It scores test patches along the refined direction and applies a gated threshold to suppress contextual spill-over around small lesions. Without inference-time annotations or additional models, GENIQ achieves Dice scores of 0.85–0.88 on three dermoscopy test sets. It outperforms zero-shot and word-based attention methods on all three sets, and a hand-designed dermoscopy pipeline in Dice and IoU on two.

1. Introduction

Skin lesion segmentation delineates lesions in dermoscopy images, enabling the measurement of their size, border, and change over time [18, 26]. However, obtaining pixel-level masks is costly, motivating segmentation methods that require no mask annotations during training or inference. Without such annotations, a central challenge is how to specify the target region to be segmented. Existing approaches rely on dermoscopy-specific rules, annotation-derived priors embedded in pretrained models, or manual region selection. Text-to-image generators offer another potential source of guidance: when prompted with a lesion-related word, they can generate both lesions and surrounding healthy skin, suggesting that their internal features may encode the distinction between the two.

Turning this observation into segmentation requires a mechanism for reading the generator's internal features at the patch level. ConceptAttention [5] provides such a mechanism without additional training. In a diffusion transformer, image patches are represented as tokens whose attention outputs encode each patch in the context of the entire image [21]. To localize a target, ConceptAttention introduces its concept word as an additional token, processes it through the same attention layers, and scores each image patch by its proximity to the concept token relative to other words in the shared attention-output space. It thus converts a text-named target into a training-free, patch-level word query.

On dermoscopy images, however, this word-based query is unreliable. In FLUX [13, 14], the lesion word map ranks lesion patches no better than a spatial prior obtained by averaging the ground-truth masks of other images. The failure is not limited to lesion-related words: the hair map can even highlight a mole in an image containing no hair (Figure 1b, top right). These failures appear to arise from the query rather than from the image-token features themselves. In the shared attention-output space, the vector from the skin word to the lesion word has a cosine similarity of only 0.21 with the direction from real skin patches to real lesion patches. This alignment is approximately as weak as that of the skin-to-hair word vector. By contrast, the direction from generated healthy-skin patches to generated lesion patches achieves a cosine similarity of 0.61 with the real skin-to-lesion direction (Figure 1b, left). Thus, the feature space contains a useful skin-to-lesion direction, but concept words do not reliably recover it. This raises our

Figure

Figure 1. GENIQ: task, query construction, and thresholding. (a) Given a dermoscopy image, a text-named target, frozen FLUX [13, 14], and unlabelled images, GENIQ predicts a lesion mask without training, annotations, or external models. (b) Concept-word directions align poorly with the real skin-to-lesion direction, whereas the generated healthy-skin-to-lesion direction aligns better. GENIQ uses the word only inside generated images and refines the resulting query on unlabelled real images (green). (c) On a small lesion, the mean and two-class Otsu thresholds keep the score spill-over, whereas the upper threshold of a three-level split lies near the lesion edge. Cyan: clinician's outline; histogram colours: the three score levels.

central question: can we use a target specified only by text to construct a reliable query for these features, without training, inference-time annotations, or external models (Figure 1a)?

Prior work addresses complementary parts of this problem but leaves a gap. 1) Label-free lesion segmentation uses dermoscopy-specific pipelines or pretrained models, including superpixel clustering after hair removal, SAM prompted by vision-language saliency, and Stable Diffusion self-attention grouped into regions [4, 10, 11, 22]. However, the target is still specified through domain-specific rules, annotation-derived model priors, or human selection, making these methods difficult to extend to new text-named findings. 2) Word read-outs of diffusion models localise objects by scoring image patches against prompt or concept words [9, 27]. Because the concept word remains the query, even when prototypes from unlabelled images are introduced [19], these methods retain the word-to-image misalignment observed above. 3) Generated references construct visual prototypes from generated class images, using class-word cross-attention to separate foreground and background patches [2, 8]. However, they typically use background patches from the same class image rather than an explicitly generated negative class, such as healthy skin, and often extract features with an external encoder. They therefore do not provide the healthy-skin-to-lesion direction in the generator's own attention-output space. Together, these methods do not combine text-based target specification with an image-derived query constructed in the generator's own attention-output space.

Our Approach: Querying with Generated Images. To fill this gap, we propose GENIQ, which replaces Concept-Attention's direct word query with an image-derived query constructed by the same generator. Rather than using the concept word to match real lesion patches directly, we use it only within generated images, where distinguishing a gen-

erated lesion from its surrounding skin is easier. Generated lesion and healthy-skin images then define a visual direction for querying real dermoscopy images (Figure 1b, right). We further adapt this direction using unlabelled real images and introduce a gated threshold to reduce spill-over onto skin around small lesions (Figure 1c). In this way, generated images bridge the gap between a text-named target and its visual appearance in real images.

Our contributions are as follows: 1) We introduce a generated-image query that replaces the poorly aligned concept-word query with a healthy-skin-to-lesion direction constructed in the generator's own attention-output space. 2) We refine this query using unlabelled dermoscopy images, adapting it to real lesion appearance without training or annotations. 3) We introduce a gated threshold that reduces attention spill-over around small lesions. 4) On three dermoscopy test sets, GENIQ outperforms zero-shot baselines and word-based read-outs, and surpasses a hand-designed dermoscopy pipeline on two of the three sets.

References (24)