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:
- 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.
- 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.
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).
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