S2Edit: Text-Guided Image Editing with Precise Semantic and Spatial Control

Xudong Liu, Zikun Chen, Ruowei Jiang, Ziyi Wu, Kejia Yin, Han Zhao, Parham Aarabi, Igor GilitschenskiarXiv 2025 · DOI

Abstract

S2Edit is a novel framework for text-guided image editing designed to solve the "identity loss" problem common in diffusion models. By combining semantic disentanglement through orthogonality constraints and spatial grounding via attention masking, S2Edit allows for precise local edits—such as changing hair color or facial expressions—while maintaining the subject's unique facial features.

Introduction

Text-to-image diffusion models excel at generation but struggle with precise editing. A common issue is concept entanglement, where the model's representation of a subject's "identity" is mixed with its "attributes" (e.g., hair color, skin tone). Consequently, requesting a local change often results in global alterations to the subject's face or background. S2Edit addresses these challenges by disentangling identity from attributes both semantically and spatially.

Methods

S2Edit (Semantic and Spatial Edit) operates in two primary stages: identity fine-tuning and inference.

Identity Fine-tuning with Dual Controls

The model learns a unique text token (e.g., [I]) to represent the subject. To ensure this token only captures identity, two controls are implemented:

  1. Semantic Control: An orthogonality constraint is applied, forcing the identity token's embedding to be mathematically perpendicular to the rest of the prompt. This prevents the token from absorbing attributes intended for modification.
  2. Spatial Control: To prevent identity information from bleeding into the background, S2Edit employs cross-attention masking. It automatically extracts a binary mask from the model's internal attention maps for a "class word" (e.g., "lady"). The identity token [I] is then restricted to attend only to this masked region.
Extracted figure from page 4 of S2Edit: Text-Guided Image Editing with Precise Semantic and Spatial Control

Inference

The system uses Null-text Inversion to find the initial noise map of the source image and denoises it using the target prompt (e.g., "A [I] lady with red hair").

Results

S2Edit was evaluated on datasets including FFHQ, CelebA, AFHQ (cats), and LSUN (churches).

Figure 5: Comparison of S2Edit against baseline methods. S2Edit preserves the original identity while accurately reflecting the text prompt, whereas other methods often change the subject's facial structure.

On the FFHQ benchmark, S2Edit achieved superior performance with the lowest LPIPS (0.13) and FID (52.31) scores compared to competitors like InstructPix2Pix and DeltaEdit. In user studies, S2Edit was preferred over 70% of the time for both identity preservation and prompt alignment. Visual results demonstrate that S2Edit performs clean, localized edits that maintain the integrity of the original subject.

Conclusion

S2Edit provides a robust mathematical and spatial framework for disentangling identity from attributes in diffusion models. While it requires a brief fine-tuning phase and accurate source prompts, it sets a new standard for high-fidelity, text-guided image editing. Future work may involve automating source prompt generation to further streamline the workflow.

Summary updated

BibTeX
@misc{liu2025s,
  author = {Xudong Liu and Zikun Chen and Ruowei Jiang and Ziyi Wu and Kejia Yin and Han Zhao and Parham Aarabi and Igor Gilitschenski},
  title = {{S2Edit: Text-Guided Image Editing with Precise Semantic and Spatial Control}},
  year = {2025},
  eprint = {2507.04584},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.04584},
}
Figure