无需训练即可精准编辑图像局部,背景不被干扰。
SAM-Flow: Source-Anchored Masked Flow for Training-Free Image Editing

- 用探测图和注意力图定位可编辑区域,只在局部更新潜空间。
- 通过源图像轨迹锚定非目标区域,有效避免背景泄露。
- 兼容主流模型,无需微调,适合快速实现精准图像编辑。
训练无关的图像编辑因能利用预训练扩散模型和流匹配模型直接修改真实图像而受到关注,但现有基于反演和微分流的方法通常进行全局潜在空间传输,不可避免地将编辑效果扩散至非目标区域,导致背景泄漏。为此,本文提出 SAM-Flow,一种源锚定掩码流框架,实现局部化训练无关图像编辑。该方法首先使用探测图像和标记锚定注意力图定位可编辑语义区域,仅在这些区域内应用微分速度更新,其余区域则锚定于源图像潜空间轨迹。为进一步提升空间稳定性和边界自然性,引入时变源锚定投影机制,包含动态软掩码、过渡区域和时间掩码累积。所提方法为即插即用设计,可无缝集成主流流匹配骨干模型(如 Stable Diffusion 3 与 FLUX),无需任何微调。大量定性和定量实验表明,SAM-Flow 在实现精准语义编辑的同时显著提升了背景保持能力,提供了一种简单通用的局部化训练无关图像编辑范式。代码已开源:https://github.com/chwbob/Sam-Flow。
原文摘要 · Abstract (English)
Training-free image editing has recently attracted increasing attention due to its ability to modify real images using powerful pre-trained diffusion and flow-matching models without additional training. However, existing inversion-based and differential-flow-based methods usually perform global latent transport, which inevitably propagates editing effects to non-target regions and leads to background leakage. To address this problem, we propose SAM-Flow, a source-anchored masked flow framework for localized training-free image editing. Instead of updating the whole latent representation, SAM-Flow first uses a scout image and token-grounded attention maps to localize the editable semantic regions. It then applies differential velocity updates only within these regions, while anchoring the remaining areas to the source-image latent trajectory. To further improve spatial stability and boundary naturalness, we introduce a time-varying source-anchored projection mechanism with dynamic soft masks, transition regions, and temporal mask accumulation. The proposed method is plug-and-play and can be integrated with mainstream flow-matching backbones such as Stable Diffusion 3 and FLUX without any fine-tuning. Extensive qualitative and quantitative experiments demonstrate that SAM-Flow achieves accurate semantic editing while significantly improving background preservation, providing a simple and general localized editing paradigm for training-free image editing. Code is available at: https://github.com/chwbob/Sam-Flow.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。