SpotEdit: Selective Region Editing in Diffusion Transformers
Zhibin Qin1, Zhenxiong Tan1, Zeqing Wang1, Songhua Liu2, Xinchao Wang1
1 National University of Singapore
2 Shanghai Jiao Tong University
SpotEdit is a training-free, region-aware framework for instruction-based image editing with Diffusion Transformers (DiTs).
While most image editing tasks only modify small local regions, existing diffusion-based editors regenerate the entire image at every denoising step, leading to redundant computation and potential degradation in preserved areas. SpotEdit follows a simple principle: edit only what needs to be edited.
SpotEdit dynamically identifies non-edited regions during the diffusion process and skips unnecessary computation for these regions, while maintaining contextual coherence for edited regions through adaptive feature fusion.
conda create -n spotedit python=3.10
conda activate spotedit
pip install -r requirements.txtReady-to-run notebooks live in examples/, one per backbone. Each one loads the pipeline, runs SpotEdit alongside a full-compute baseline for comparison, and visualizes the reused (non-edited) region.
- FLUX.1-Kontext-dev —
examples/flux.ipynb - Qwen-Image-Edit (base) —
examples/qwen.ipynb - Qwen-Image-Edit-Plus (2509 / 2511) —
examples/qwen_plus.ipynb - FLUX.2 [klein] —
examples/flux2.ipynb(needsdiffusers>=0.37)
- Experiments and test examples are typically conducted at a resolution of 1024×1024. We recommend setting both input and output image sizes to 1024×1024 when running SpotEdit.
- To help preserve the subject's proportions, it can be useful to feed a square canvas: scale the source to fit 1024×1024 while keeping its aspect ratio and pad the remainder (aspect-preserving letterbox), instead of stretching a non-square image to 1024×1024. The example notebooks do this by default.
SpotEdit's behaviour is controlled through SpotEditConfig. Two options are worth highlighting:
reuse_mode — how cached tokens are written back each denoising step
"velocity"(default): at every step the reused (non-edited) tokens are guided toward the source image by setting their predicted velocity tov = (x_t − x0_src) / σ, so theirx0prediction stays close to the source latent. The reused region then follows a similar trajectory to the recomputed region, which helps keep the boundary smooth and avoids relying on a hard paste at the end."overwrite": reused tokens keep the cached prediction during the loop and the source latents are hard-pasted onto them once, after the final step. This is simpler, though it can leave a more visible boundary between the reused and regenerated regions.
judge_method — how the reuse / recompute split is decided
Each step, SpotEdit assigns every token a per-token LPIPS-like edit score d (lower tends to mean unchanged, higher tends to mean edited).
"LPIPS": a token is reused whend < threshold, i.e. a fixed cutoff you set."LPIPS_kmeans": the cutoff is instead chosen adaptively per step by running 1-D k-means (k = 2, sum-of-squares split) over the token scores and reusing the lower-score cluster. This can help reduce the need to hand-tunethresholdwhen the score scale differs across images or backbones;thresholdis then kept mainly as a full-reuse safety fallback.
"LPIPS_kmeans" is available on every backbone. It is used as the default for the Qwen family (Qwen-Image-Edit and Qwen-Image-Edit-Plus), while the FLUX backbones (FLUX.1-Kontext, FLUX.2 [klein]) keep the fixed-threshold "LPIPS" as their default.
- SpotEdit is not intended for global edits that affect most or all regions of the image, such as full-scene style transfer or global color changes. In these cases, SpotEdit cannot reliably identify non-edited regions, and thus falls back to computation that is effectively equivalent to the original full-image diffusion process.
- ComfyUI integration — wrap SpotEdit as a ComfyUI custom node / workflow so it can be used inside ComfyUI pipelines.
@artical{qin2025spotedit,
title= {SpotEdit: Selective Region Editing in Diffusion Transformers},
author= {Qin, Zhibin and Tan, Zhenxiong and Wang, Zeqing and Liu, Songhua and Wang, Xinchao},
journal={arXiv preprint arXiv:2512.22323},
year={2025}
}

