Skip to content

A repository that implements multiple Rectified Flow (RF)-based image editing approaches built upon the 🤗 Diffusers library.

License

Notifications You must be signed in to change notification settings

Justin900429/RF-Image-Editing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rectified Flow Image Editing Approaches

Welcome to the Rectified Flow Image Editing repository!
This project provides a unified implementation of multiple Rectified Flow (RF)-based image editing approaches built upon the 🤗 Diffusers library.
It aims to make experimentation, comparison, and exploration of RF editing techniques both reproducible and accessible.


🚀 Features

This repository includes several state-of-the-art RF-based editing methods, all implemented under a consistent Diffusers interface:

In addition, we provide two auxiliary functions, reconstruction and multi-turn editing, to enhance usability and evaluation:

  • Reconstruction: Evaluates each method’s inversion and reconstruction capability.
  • Multi-turn Editing: Tests editing consistency across multiple sequential edits.

⚙️ Installation

Set up the environment with:

uv sync
source .venv/bin/activate

📘 Example Usage

For detailed examples, refer to the notebooks in the notebook/ directory. Below is a quick example using RF-Solver:

import diffusers
import torch

from pipeline import RFSolverEditFluxPipeline

diffusers.utils.logging.set_verbosity_error()

pipe = RFSolverEditFluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16)
pipe.to("cuda")
pipe.add_processor(after_layer=20, filter_name="single_transformer_blocks")

source_img = "assets/sources/cartoon.jpg"
source_prompt = "a cartoon style boy raising his left hand"
target_prompt = "a cartoon style Harry Potter raising his left hand"

image = pipe(
    source_img,
    source_prompt,
    target_prompt,
    inject_step=2,
    guidance_scale=2,
    num_inference_steps=25,
    with_second_order=True,
).images[0]
image.save("assets/results/cartoon_rf_solver.jpg")
image

🧩 Visual Comparisons

Below are several examples demonstrating different editing approaches:

Note

Although some papers do not include a prompt (i.e., use a null prompt) for inversion,
all examples below adopt a source prompt, as we find it leads to noticeably better results.

Approach Source Edit Result
RF-Inversion
Notebook Badge
source_img result_img
portrait of a cat portrait of a tiger
RF-Solver
Notebook Badge
source_img result_img
a cartoon style boy raising his left hand a cartoon style Harry Potter raising his left hand
FireFlow
Notebook Badge
source_img result_img
A young boy riding a brown horse in a countryside field. A young boy riding a camel in a countryside field.
FTEdit
Notebook Badge
source_img result_img
a cup of coffee with a tulip latte art on a wooden table a cup of coffee with a lion latte art on a wooden table
FlowEdit
Notebook Badge
source_img result_img
A gray cat and a brown dog sitting on the floor. A raccoon and a brown dog sitting on the floor.
DNAEdit
Notebook Badge
source_img result_img
A gray cat and a brown dog sitting on the floor. A raccoon and a brown dog sitting on the floor.

🔁 Reconstruction

Since many of these approaches also focus on improving inversion quality, we provide a dedicated example in the inversion test notebook.

The figure below shows the reconstruction loss between the forward and inverted processes over 25 steps.

inversion loss


🎨 Multi-turn Editing

As multi-turn image editing becomes increasingly important for refining and controlling generation results, we provide built-in support for multi-turn editing within our framework.

The example below demonstrates how each approach performs across multiple sequential edits.

Source Editing Prompts
source_img "a round cake with frosting on a wooden plate besides a cup"
"a round cake with frosting on a wooden plate"
"a square cake with frosting on a wooden plate"
"a square cake with frosting and chocolate sprinkles on a wooden plate"
"a square cake with frosting, chocolate sprinkles, and strawberry slices on a wooden plate"
Approach Result
RF-Inversion rf_inversion_result
RF-Solver rf_solver_result
FireFlow fireflow_result
FTEdit ftedit_result
FlowEdit flowedit_result
Multi-Turn multiturn_result
DNAEdit dnaedit_result

💡 Remarks

The effectiveness of image editing largely depends on two key aspects:

  • Designing better feature replacement or addition strategies
  • Developing more accurate solvers for the Rectified Flow (RF) process

For the first aspect, researchers are encouraged to explore the processors folder.
For the second, refer to the pipeline folder, particularly the denoise function.


📚 Citation

If you find this repository useful for your research or applications, please consider giving it a star 🌟 and also cite the corresponding original works:

RF-Inversion
@inproceedings{rout2024semantic,
  title={Semantic Image Inversion and Editing using Rectified Stochastic Differential Equations},
  author={Rout, Litu and Chen, Yujia and Ruiz, Nataniel and Caramanis, Constantine and Shakkottai, Sanjay and Chu, Wen-Sheng},
  booktitle={ICLR},
  year={2024}
}
RF-Solver
@inproceedings{wang2025taming,
  title={Taming Rectified Flow for Inversion and Editing},
  author={Wang, Jiangshan and Pu, Junfu and Qi, Zhongang and Guo, Jiayi and Ma, Yue and Huang, Nisha and Chen, Yuxin and Li, Xiu and Shan, Ying},
  booktitle={ICML},
  year={2025}
}
FireFlow
@inproceedings{deng2025fireflow,
  title={FireFlow: Fast Inversion of Rectified Flow for Image Semantic Editing},
  author={Deng, Yingying and He, Xiangyu and Mei, Changwang and Wang, Peisong and Tang, Fan},
  booktitle={ICML},
  year={2025}
}
FTEdit
@inproceedings{xu2025unveil,
  title={Unveil inversion and invariance in flow transformer for versatile image editing},
  author={Xu, Pengcheng and Jiang, Boyuan and Hu, Xiaobin and Luo, Donghao and He, Qingdong and Zhang, Jiangning and Wang, Chengjie and Wu, Yunsheng and Ling, Charles and Wang, Boyu},
  booktitle={CVPR},
  pages={28479--28489},
  year={2025}
}
FlowEdit
@inproceedings{kulikov2025flowedit,
  title={FlowEdit: Inversion-free text-based editing using pre-trained flow models},
  author={Kulikov, Vladimir and Kleiner, Matan and Huberman-Spiegelglas, Inbar and Michaeli, Tomer},
  booktitle={ICCV},
  year={2025}
}
Multi-Turn
@inproceedings{zhou2025multi,
  title={Multi-turn Consistent Image Editing},
  author={Zhou, Zijun and Deng, Yingying and He, Xiangyu and Dong, Weiming and Tang, Fan},
  booktitle={ICCV},
  year={2025}
}
DNAEdit
@inproceedings{xie2025dnaedit,
  title={DNAEdit: Direct Noise Alignment for Text-Guided Rectified Flow Editing},
  author={Xie, Chenxi and Li, Minghan and Li, Shuai and Wu, Yuhui and Yi, Qiaosi and Zhang, Lei},
  booktitle={NeurIPS},
  year={2025}
}

🙏 Acknowledgements

We sincerely thank the authors of all referenced papers for open-sourcing their work. This project builds upon their valuable contributions and integrates them into a unified, Diffusers-compatible framework.

About

A repository that implements multiple Rectified Flow (RF)-based image editing approaches built upon the 🤗 Diffusers library.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published