ReFlex: Text-Guided Editing of Real Images in Rectified Flow via Mid-Step Feature Extraction and Attention Adaptation

Jimyeong Kim, Jungwon Park, Yeji Song, Nojun Kwak, Wonjong Rhee

TL;DR

This paper introduces ReFlex, a novel method for editing real images using text prompts with Rectified Flow (ReFlow) models. ReFlex addresses the challenge of preserving source image structure while adapting to text instructions by extracting key features from intermediate latent representations and adapting attention mechanisms.

What Problem Does This Paper Address?

Text-to-image generation models have seen remarkable progress, leading to the development of image editing techniques guided by text prompts. While diffusion models (DMs) have been a popular backbone for these editing tasks, they often struggle with image quality and text alignment. Rectified Flow (ReFlow) models, like FLUX, offer superior image quality and text alignment. However, adapting these advanced ReFlow models for real-image editing remains a significant challenge. Existing ReFlow editing methods often fail to preserve the source image's structure, especially during substantial edits like color changes, and can suffer from appearance leakage. This paper aims to bridge this gap by proposing a ReFlow-specific editing method that balances structural preservation with accurate text-guided modifications.

Methods

ReFlex tackles the editing challenge by focusing on three key insights derived from analyzing the internal workings of ReFlow's Multi-Modal Diffusion Transformer (MM-DiT) architecture:

  • Mid-Step Feature Extraction: Instead of relying on fully inverted latents (which can lose structural information), ReFlex extracts features from a "mid-step" latent. This intermediate representation, captured at approximately half the inversion timesteps (T/2), offers a better balance between preserving source structure and retaining editability.
  • Key Feature Identification: Through analysis, the authors identified three crucial features within MM-DiT for effective editing:
  • I2I-SA (Image-to-Image Self-Attention): Captures structural information.
  • I2T-CA (Image-to-Text Cross-Attention): Captures image-text relationships.
  • Residual Feature: Contributes to structural integrity.
  • Attention Adaptation: To further enhance editability and text alignment, ReFlex employs two adaptation techniques for the identified attention features:
  • I2T-CA Adaptation: A mapping function aligns text tokens between source and target prompts, allowing for targeted replacement of attention features.
  • I2I-SA Adaptation: This technique replaces the most concentrated "top-k" attention values in the source's I2I-SA with corresponding values from the target's I2I-SA. This helps maintain global structure while allowing for local modifications.
  • Local Editing with Latent Blending: For localized edits, ReFlex generates an editing mask using the I2T-CA of a specified "blended word" from the prompt. This mask is then used with latent blending to confine changes to specific regions.

Datasets

The paper evaluates ReFlex on two widely used benchmarks:

  • PIE-Bench: Contains 700 images across 9 tasks, providing source and target prompts, along with "blended words" for latent blending.
  • Wild-TI2I-Real: Consists of 78 image-target prompt pairs, but does not provide source prompts.

Key Insights and Ideas

  • Mid-step inversion is crucial: The paper demonstrates that features extracted from latents closer to the original image (mid-step) are significantly better at preserving source structure than those from fully inverted latents. This is a key departure from prior DM-based editing methods.
  • MM-DiT's internal structure matters: ReFlow models have a different architecture (MM-DiT) than U-Net based DMs. Simply applying DM editing techniques doesn't work; understanding and leveraging MM-DiT's specific attention mechanisms (I2I-SA, I2T-CA) and residual connections is vital.
  • Balancing source and target is key: Simply injecting source features leads to poor edits, while over-adapting to the target prompt can lose structural information. ReFlex's attention adaptation techniques are designed to strike this critical balance.
  • Text alignment can be improved by manipulating attention: The I2T-CA and I2I-SA adaptation strategies show that fine-tuning how attention maps are used during injection can significantly improve how well the edited image adheres to the target text.

Key Results

  • Quantitative Performance: ReFlex achieves significant improvements in text alignment, with gains of 1.69% to 7.11% on PIE-Bench and 3.21% to 16.46% on Wild-TI2I-Real compared to nine baselines.
  • User Preference: In user studies, ReFlex was preferred in 68.2% of cases against FLUX-based methods and 61.0% against SD-based methods, indicating a strong user preference for its output quality and adherence to edits.
  • Qualitative Results: Visual comparisons show ReFlex successfully preserves source structure and accurately follows target prompts, outperforming baselines that often struggle with structural integrity or text alignment.

Limitations and Future Work

The authors acknowledge a few limitations:

  • Unintentional Edits: When edits overlap with the subject, ReFlex may unintentionally alter other features of that subject (e.g., changing hair when only editing glasses).
  • Mask Generation Artifacts: For local editing, the generated masks might not perfectly localize the editing region, potentially leading to artifacts.
  • Variability in Editing Results: The paper notes variability in editing outcomes, which could be further investigated.

Future work could explore more advanced mask generation techniques and automatic detection of "blended words" for local editing. The authors hope their findings will serve as a foundation for future advancements in ReFlow-based image editing.

Summary updated

BibTeX
@inproceedings{kim2025reflex,
  author = {Jimyeong Kim and Jungwon Park and Yeji Song and Nojun Kwak and Wonjong Rhee},
  title = {{ReFlex: Text-Guided Editing of Real Images in Rectified Flow via Mid-Step Feature Extraction and Attention Adaptation}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2025},
}
Figure