TL;DR
Follow-Your-Shape is a training-free, mask-free image editing framework designed specifically for large-scale object shape transformations while strictly preserving background content. By analyzing the velocity field differences between inversion and editing paths, it dynamically generates a Trajectory Divergence Map (TDM) to precisely localize and execute complex geometric edits.
What Problem Does This Paper Address?
While modern diffusion and flow-based generative models excel at general image editing tasks (like changing textures or colors), they struggle with large-scale structural and geometric shape transformations—such as turning a swan into a boat or a parrot into a hat.
When forced to perform these drastic structural edits, existing methods typically suffer from two failure modes: they either fail to alter the object's shape convincingly, or they inadvertently corrupt non-target background regions. Current region-control strategies fall short:
- Binary segmentation masks are too rigid and struggle with fluidly changing object boundaries.
- Cross-attention maps are notoriously noisy and unstable during significant shape shifts.
- Unconditional feature injection globally forces source structure onto the target image, which suppresses the intended shape modification.
Follow-Your-Shape introduces a way to dynamically and precisely localize where an edit should happen without relying on external masks or noisy attention mechanisms.
Methods
The core innovation of Follow-Your-Shape is treating image editing through the lens of dynamical systems and flow trajectories. The framework consists of two main components:
1. Trajectory Divergence Map (TDM)
Instead of relying on cross-attention layers, the authors look at the model's internal denoising velocity fields. They compute the token-wise $L_2$ norm difference between the velocity vectors predicted under the source prompt (the reconstruction path) and the target prompt (the editing path):
$$\delta^{(i)}_t = \|v_\theta(z^{(i)}_t, t, c_{tgt}) - v_\theta(x^{(i)}_t, t, c_{src})\|_2$$
Regions intended for modification exhibit significant trajectory divergence, while background areas follow nearly identical paths. This allows the model to dynamically map out the exact pixels that need to change.
2. Scheduled KV Injection
Directly applying TDM guidance from the start is unstable because early, high-noise latents provide weak spatial signals. To fix this, the authors introduce a three-stage denoising pipeline:
- Stage 1: Initial Trajectory Stabilization: For the first few timesteps ($k_{front}$), the model performs global, unconditional Key-Value (KV) injection from the source image to anchor the latent state to a stable reconstruction manifold, preventing background drift.
- Stage 2: Editing and TDM Aggregation: The model is allowed to explore the target-guided editing path. TDMs are collected across this window, aggregated using a softmax-weighted temporal fusion, and binarized via Otsu's thresholding method to create a clean edit mask ($M_S$).
- Stage 3: Structural and Semantic Conformance: The mask $M_S$ selectively blends target and source KV features—preserving the background while allowing the foreground to change shape. This is paired with ControlNet residual conditioning to stabilize the new structural patterns.
Datasets
The authors evaluate their method on two benchmarks:
- ReShapeBench (New): A benchmark curated specifically for evaluating large-scale shape modifications. It contains 120 newly collected images and 290 shape-aware editing cases split into single-object and multi-object scenes. The source-target prompts follow a strict template where only the foreground object description changes, isolating structural transformations from background resynthesis.
- PIE-Bench: A standard public image editing benchmark used to evaluate the model's generalizability across diverse, non-shape-specific editing tasks.
Key Insights and Ideas
- Flow Trajectories as Semantic Signals: The most elegant insight is that semantic differences between two prompts are directly encoded in the divergence of their flow trajectories in latent space. Velocity differences provide a much cleaner, more direct indication of structural change than cross-attention maps.
- The Necessity of Stabilization: You cannot edit effectively until you stabilize. Trying to change shapes in the ultra-high-noise regime (early timesteps) causes background drift. Forcing the model to first anchor to the source image's manifold ensures background integrity before the shape transformation begins.
- Data-Driven Thresholding: The values in the aggregated TDM naturally form a skewed unimodal distribution (a dominant background mode and a long-tailed foreground response), making it a perfect fit for Otsu’s method to automatically calculate an optimal, mask-free threshold.
Key Results
Follow-Your-Shape achieves state-of-the-art performance qualitatively and quantitatively across both benchmarks, using FLUX.1-[dev] as its base model.
Quantitative Performance
On ReShapeBench, Follow-Your-Shape significantly outperforms both diffusion- and flow-based baselines in background preservation and text alignment:
- Background Preservation: Achieves a PSNR of 35.79 and an LPIPS ($\times 10^3$) of 8.23, vastly outperforming standard flow-editing methods like RF-Edit (PSNR: 33.28, LPIPS: 17.53) and FlowEdit (PSNR: 32.46, LPIPS: 18.92).
- Text Alignment: Reaches a CLIP Similarity of 33.71, proving that background preservation does not come at the cost of editability.
Qualitative Performance
As shown in the paper's examples, the framework successfully handles complex single- and multi-object transformations (e.g., turning birds into dragonflies or a boy into a cat) while keeping background details like grass textures, house structures, and lighting completely unchanged. It avoids the detail jitter, ghosting, and incomplete transformations common in baseline models.
Limitations and Future Work
- Sensitivity to Prompt Ambiguity: Because the editing behavior is entirely driven by prompt-guided trajectories, vague or abstract instructions (e.g., relying on implicit assumptions about the target) can cause the model to struggle, leading to diffuse or weak edits.
- Temporal Instability in Video: When extending the framework to video generation models (like Wan 2.1), the spatial editing regions indicated by the TDM tend to fluctuate across frames. This causes visual inconsistency and incomplete transformations over time. The authors note that developing temporally-aware TDM construction or moving toward multi-agent video editing paradigms are promising future directions.
Summary updated