Semantic-Aligned Image Prompt Extractor (SAIPE)
- The paper introduces SAIPE as a novel mechanism that converts degraded JPEG images into semantic prompt embeddings aligned with the Stable Diffusion text encoder.
- SAIPE employs a dual-branch training strategy combining reconstruction loss and semantic alignment loss to preserve image fidelity while guiding restoration.
- Architecturally, SAIPE integrates a SwinIR-based encoder, a reconstruction decoder, and an image guidance embedder to ensure detailed texture and color recovery.
Semantic-Aligned Image Prompt Extractor (SAIPE) is the mechanism in SODiff that converts a low-quality JPEG image into a semantic image prompt embedding for one-step diffusion-based JPEG artifacts removal. In the formulation introduced with SODiff, SAIPE extracts rich features from low-quality images, projects them into an embedding space semantically aligned with that of the Stable Diffusion 2.1 text encoder, and simultaneously preserves crucial information for faithful reconstruction. Its purpose is to replace textual prompts with image-derived prompt embeddings that can guide a finetuned Stable Diffusion UNet without requiring a vision-LLM at inference time (Yang et al., 10 Aug 2025).
1. Definition and conceptual role
Within SODiff, SAIPE is defined as a semantic-aligned image prompt extractor that turns a compressed image into an embedding that shares the same embedding space as the Stable Diffusion text encoder. “Semantic alignment” means that the image-derived embedding lives in, and is numerically close to, the embedding space of the text encoder, such that it is interchangeable with text embeddings inside the diffusion model. The design goal is twofold: to provide semantically distilled guidance to the generative prior of Stable Diffusion 2.1, and to retain fine-grained structure and color cues needed for faithful reconstruction under heavy JPEG compression (Yang et al., 10 Aug 2025).
This formulation addresses a specific limitation of JPEG artifacts removal. The SODiff paper states that classical CNN- and Transformer-based restoration methods often struggle to hallucinate missing complex textures and tend to over-smooth, yielding “blocked details and distorted structures.” It further argues that converting a degraded image into short text descriptions dilutes information, because texture, color, and layout can be lost when rich visual content is compressed into natural language. SAIPE is therefore positioned not as a captioning module, but as an adapter from image features to the text-conditioning space of a pretrained text-to-image diffusion model (Yang et al., 10 Aug 2025).
A common misconception is that SAIPE merely substitutes one prompt generator for another. In the SODiff framework, it instead reuses the conditioning interface already expected by Stable Diffusion, but replaces textual prompts with image prompts derived directly from the low-quality input. The text encoder is only used during SAIPE training to provide reference text embeddings; there are no textual prompts at inference (Yang et al., 10 Aug 2025).
2. Position inside the SODiff pipeline
SODiff is a one-step diffusion model for JPEG artifacts removal. Given an over-compressed JPEG image , a frozen VAE encoder from Stable Diffusion maps it to a latent code,
A quality factor-aware time predictor analyzes and outputs a continuous timestep , while SAIPE processes and outputs the semantic image prompt embedding . A finetuned Stable Diffusion UNet then takes , , and 0 as conditions and performs a single denoising step; the VAE decoder finally produces the restored image 1 (Yang et al., 10 Aug 2025).
SAIPE is trained as a separate first-stage network before SODiff itself. Its input is the low-quality JPEG image 2, and its outputs are a reconstructed image 3, used only during SAIPE training, and the semantic image embedding 4, which becomes the image prompt during SODiff training and inference. The Stable Diffusion VAE encoder and decoder remain frozen, and only the UNet is finetuned with LoRA, conditioned on 5 and 6 (Yang et al., 10 Aug 2025).
The separation between SAIPE and the quality factor-aware time predictor is explicit. SAIPE uses only 7 and corresponding text descriptions for its own training, whereas the time predictor infers 8 and JPEG QF from 9 using its own residual block network. There is no direct cross-loss between them; they operate in parallel once both are trained (Yang et al., 10 Aug 2025).
3. Architectural composition
SAIPE has three main components: a shared feature extractor encoder 0, a reconstruction decoder 1, and an image guidance embedder 2. All three share the same intermediate feature tensor 3 (Yang et al., 10 Aug 2025).
The shared encoder 4 is based on SwinIR. It receives the JPEG image 5, applies 6 downsampling and channel expansion to 180 channels, and then passes the result through two Residual Swin Transformer Blocks. The output is
7
a feature map intended to retain rich hierarchical information. The paper notes that, although the exact spatial size is not spelled out, the feature map is downsampled 8, so it is roughly 9 with 180 channels (Yang et al., 10 Aug 2025).
The reconstruction decoder 0 is symmetric to the encoder but uses fewer Swin layers. It applies LayerNorm on 1, upsamples back to 2, and produces
3
Its stated purpose is to ensure that 4 encodes enough information to reconstruct the clean image 5, so that the prompt branch does not collapse into purely semantic labels detached from the input image’s reconstruction requirements (Yang et al., 10 Aug 2025).
The image guidance embedder 6 converts 7 into the final image prompt embedding,
8
Its pipeline comprises an input MLP, a Performer encoder, multi-scale convolutions that produce key and value tensors, and multi-head attention pooling with learnable queries. The learnable queries act similarly to latent slots that capture different semantic aspects. The output dimensionality is designed to match the Stable Diffusion text encoder, so that 9 can be fed directly into the prompt-conditioning pipeline without dimensional mismatch (Yang et al., 10 Aug 2025).
4. Training objectives and semantic alignment mechanism
SAIPE training is explicitly two-branch. The reconstruction branch enforces faithful restoration from 0 to 1 with
2
The semantic alignment branch uses LLaVA-v1.5-7B to generate a detailed caption of the compressed image 3; the caption is embedded by the frozen Stable Diffusion text encoder to obtain 4, and the alignment loss is
5
The total SAIPE loss is
6
with 7 (Yang et al., 10 Aug 2025).
This objective encodes the central balance of SAIPE. The reconstruction loss forces 8 to preserve low-level and mid-level information, while the MSE alignment term pushes 9 toward the semantic structure of the text-encoder space already used by Stable Diffusion. The paper describes this as extracting “distilled semantic guidance” while preserving the feature priors of the images themselves (Yang et al., 10 Aug 2025).
Training is staged. SAIPE is trained separately from scratch, without involving the Stable Diffusion UNet. Gradients from 0 and 1 update 2, 3, and 4. The Stable Diffusion text encoder is used only as a frozen feature extractor, and LLaVA is used only to generate text. During the second stage, when SODiff is trained, SAIPE is frozen. Training data are drawn from DF2K and LSDIR, with images randomly cropped to 5 and degraded by JPEG compression with quality factors 6. The reported optimization settings are Adam, learning rate 7, batch size 16, and 50k iterations on 4 NVIDIA RTX A6000 GPUs (Yang et al., 10 Aug 2025).
5. Diffusion conditioning, reconstruction fidelity, and empirical evidence
In the diffusion stage of SODiff, 8 replaces textual prompts. The same conditioning channels in the Stable Diffusion UNet, including cross-attention, are reused, but now driven by image-derived embeddings rather than text. The paper does not detail the exact mapping from 9 to a token sequence, but states that it “matches the text encoder,” and therefore can be fed directly into the conditioning pipeline. There is no concatenation with text prompts; SODiff is purely image-prompt driven at inference (Yang et al., 10 Aug 2025).
The empirical case for SAIPE is presented most clearly in the prompt-method ablation on Urban100 and DIV2K-val at 0. On Urban100, removing 1 yields DISTS 0.1261, MUSIQ 64.41, and MANIQA 0.4609; DAPE yields DISTS 0.0877, MUSIQ 71.53, and MANIQA 0.4953; full SAIPE yields DISTS 0.0862, MUSIQ 72.51, and MANIQA 0.5531. On DIV2K-val, the corresponding results are 0.1071, 62.83, and 0.3250 without 2; 0.0697, 64.39, and 0.3652 for DAPE; and 0.0731, 66.72, and 0.4013 for SAIPE. The paper interprets these results as showing that semantically aligned image prompts are more informative than naive image prompts or text prompts, especially on perceptual image-quality metrics (Yang et al., 10 Aug 2025).
A second empirical argument is geometric. UMAP plots show that, without the alignment loss, image embeddings are scattered and distant from the text embeddings, whereas with alignment they cluster close to the text embeddings, indicating successful alignment of both distribution and magnitude. The paper treats this as evidence that semantic alignment is necessary for the Stable Diffusion conditioning mechanism to behave stably and coherently (Yang et al., 10 Aug 2025).
Another misconception is that semantic alignment necessarily sacrifices fidelity. The design of SAIPE argues the opposite: the reconstruction branch ensures that 3 remains reconstruction-capable, and because 4 is built on top of 5, the prompt embedding inherits access to structural and textural information. The qualitative examples cited in the paper describe fine textures such as bricks and clouds being reconstructed more plausibly than with competing methods, while avoiding the over-smoothed appearance of conventional restoration networks (Yang et al., 10 Aug 2025).
6. Related formulations, limitations, and broader significance
Although the term SAIPE is specific to SODiff, multiple adjacent works describe closely related mechanisms. In few-shot learning, “Semantic Prompt” conditions a Visformer backbone using class-name embeddings projected into spatial and channel prompt pathways; the paper explicitly describes this method as essentially a “Semantic-Aligned Image Prompt Extractor” implemented on top of a ViT-style backbone (Chen et al., 2023). In weakly supervised semantic segmentation, SemPLeS learns category-specific prompts in CLIP space to suppress co-occurring backgrounds and improve semantic alignment between segmented regions and class labels (Lin et al., 2024). In unpaired image captioning, prompt-based learning uses CLIP image features mapped through a trainable layer into prompt tokens aligned with the text encoder, plus a CLIP-based metric prompt for pseudo-pair filtering (Zhu et al., 2022).
A different but related line of work shifts from image restoration and recognition to generation and editing. Visual Prompt Engineering introduces discrete SigLIP 2-based “visual prompts” as intermediate semantic plans for class-conditional generation, text-to-image generation, and image editing, and reports substantially better editing preservation for internal versus external integration, including PSNR 26.76 versus 19.92 (Jia et al., 3 Jun 2026). By contrast, VisualPrompter, PromptEnhancer, and self-rewarding LVLM prompt optimization operate primarily at the text level: they use visual feedback, Chain-of-Thought rewriting, or LVLM-as-a-judge loops to produce prompts that are more semantically aligned with generated images, rather than directly learning an image-to-text-encoder adapter (Wu et al., 29 Jun 2025, Wang et al., 4 Sep 2025, Yang et al., 22 May 2025). This suggests a useful distinction between prompt extraction in embedding space and prompt optimization in natural language.
The principal limitation identified for SAIPE in SODiff is training complexity. The paper states that SAIPE is trained from scratch in a separate stage, while the diffusion components are finetuned from pretrained weights; joint training caused convergence instability, so a two-stage scheme was adopted. A further reported limitation is generalization under severe chroma subsampling, where SODiff can still exhibit color shifts even when textures are well restored. The paper suggests that future work could explore more stable joint training, better initialization, additional color or frequency-domain priors, and extension of SAIPE to other degradation types such as other compression standards, deblurring, super-resolution, or multimodal guidance combining text and image prompts (Yang et al., 10 Aug 2025).
Taken together, these results position SAIPE as a specific architecture for mapping degraded images into a pretrained text-conditioning space while preserving reconstruction-relevant priors. In SODiff, that mapping is realized through a SwinIR-based shared encoder, a reconstruction branch, and a semantic alignment branch grounded in the Stable Diffusion text encoder. In the broader literature, analogous mechanisms recur wherever a model must translate visual evidence into semantically usable prompt representations without collapsing either the semantics or the image-specific detail (Yang et al., 10 Aug 2025).