Inject Where It Matters: Objective-Dependent Feature Control in Rectified-Flow Image Editing

Nina Goncharova, Alexandra Ivanova, Aibek AlanovarXiv 2026

TL;DR

This paper introduces a more surgical approach to image editing with rectified-flow models like FLUX.1-dev. By using adaptive spatial masks to gate feature injection and REINFORCE-based policy optimization to select the best transformer blocks for specific editing goals, the authors achieve a superior balance between preserving the original image and following new text prompts.

What Problem Does This Paper Address?

State-of-the-art image editing often follows a "source-to-target" recipe: invert a real image to noise using a source prompt, then regenerate it using a target prompt. To keep the background and unrelated details intact, features from the original image are "injected" into the new generation process.

However, this creates a fundamental tension. If you inject too much source information, the model ignores your edit. If you inject too little, the entire image changes, losing the identity of the original. Current methods typically handle this suboptimally by injecting features uniformly across the whole image and using hand-picked or heuristically chosen transformer blocks. This paper asks: Where should we inject features spatially, and which blocks actually matter for a specific editing objective?

Methods

The authors propose two main innovations:

  1. Adaptive Spatial Feature Masks: Instead of overwriting every pixel (token) with source features, they create a mask based on the "discrepancy" between the model's output for the source prompt versus the target prompt. If the outputs are very different at a specific location, it means the prompt change matters there, so the model should keep the target features to allow the edit. Everywhere else, it injects source features to preserve the original content.
  2. Policy-Based Layer Selection: Choosing which of the 57 blocks in FLUX.1-dev to use for injection is a massive combinatorial problem (billions of possibilities). The authors use REINFORCE, a reinforcement learning algorithm, to learn a global policy that selects the "Top-K" blocks. The reward function is a weighted combination of CLIPScore (how well the image matches the prompt) and LPIPS (how well the image preserves the original).
Figure 1: Adaptive endpoint masks across three injection layers and steps. Blue tokens retain target features (Mℓ,t,n = 1); source features are injected elsewhere.

Datasets

The study primarily uses PIE-Bench, a standard benchmark for prompt-based image editing.

  • Optimization Split: 640 examples used to train the REINFORCE policy.
  • Validation Split: 60 examples used for final evaluation across ten different editing types.
  • Analysis Subset: A fixed 140-example "random-editing" category used for controlled ablations and trade-off studies.

Key Insights and Ideas

  • Objective-Dependent Preferences: One of the most striking findings is that the "best" layers change depending on your goal. If you prioritize perfect background preservation, the model prefers a specific set of early and late blocks. If you want strong alignment with a radical edit, it prefers entirely different, mostly middle-to-late single-stream blocks.
  • Disjoint Layer Sets: At extreme ends of the trade-off (pure preservation vs. pure alignment), the optimal sets of layers can be completely disjoint. This explains why hand-picking a single "one-size-fits-all" range of layers is inherently limited.
  • Internal Model Intelligence: The adaptive masks are built "online" using the model's own internal states. This means the system doesn't need an external segmentation model (like SAM) or user-provided masks to know which parts of the image to change.
Figure 4: Layer rankings across objectives for K ∈{3, 6, 9}. Red indicates higher preference. Blocks 0–18/19–56 are double-/single-stream; all policies use step 80.

Key Results

  • Efficiency: A learned set of just 9 blocks outperformed the 18-block set used by RF-Edit in terms of preservation (lower LPIPS) while maintaining comparable prompt alignment.
  • Pareto Improvement: The combination of adaptive masking and learned layers consistently provided a better trade-off curve than baseline methods like Stable Flow or FireFlow.
  • Transferability: Layer sets learned on one pipeline (like the authors' RF-Solver) could be successfully transferred to other pipelines (like RF-Edit or FireFlow), often improving their performance while significantly reducing the number of blocks required for injection.
Figure 3: Layer-set trade-offs on the 140-example analysis category across N; learned uses step 160.

Limitations and Future Work

  • Inference Compute: While the method reduces the number of injection operations, all transformer blocks still need to be executed. It doesn't yet provide a way to skip blocks entirely for faster inference.
  • Global vs. Local Policy: The current policy is "global"—it learns one set of blocks for all images. The authors suggest that a "per-image" policy that selects layers based on the specific image and prompt could be even more powerful.
  • Metric Constraints: The rewards rely on CLIPScore and LPIPS. While standard, these metrics don't always perfectly capture "local correctness" (e.g., if a person's hand is distorted but the background is perfect). Future work could explore more sophisticated reward functions.

Summary updated

Abstract

Many prompt-driven FLUX editing methods rely on injecting source features into target-conditioned generation, creating an inherent trade-off between source preservation and the desired edit. We address this problem by controlling where source features are injected and which transformer blocks are used. First, we introduce adaptive masks that spatially gate feature injection using differences between source- and target-conditioned block outputs at matched inversion states. Second, we use REINFORCE to select Top-K injection blocks under different preservation-editability objectives. The selected blocks are fixed at inference and require no online search. On PIE-Bench with FLUX.1-dev, spatial masking controls the alignment-preservation trade-off. On 60 validation examples, a learned nine-block set gives lower whole-image LPIPS than the 18-block RF-Edit set within the same masked pipeline, with slightly lower alignment. Among 50 random nine-block sets, it has the lowest LPIPS but not the highest reward. Separate objective sweeps reveal different block preferences for preservation and alignment.
BibTeX
@misc{goncharova2026inject,
  author = {Nina Goncharova and Alexandra Ivanova and Aibek Alanov},
  title = {{Inject Where It Matters: Objective-Dependent Feature Control in Rectified-Flow Image Editing}},
  year = {2026},
  eprint = {2611.25811},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.25811},
}
Figure