https://github.com/justin900429/rf-image-editing
A repository that implements multiple Rectified Flow (RF)-based image editing approaches built upon the 🤗 Diffusers library.
https://github.com/justin900429/rf-image-editing
flux huggingface image-editing image-inversion multiturn reconstruction rectified-flow simple-implementations
Last synced: 6 months ago
JSON representation
A repository that implements multiple Rectified Flow (RF)-based image editing approaches built upon the 🤗 Diffusers library.
- Host: GitHub
- URL: https://github.com/justin900429/rf-image-editing
- Owner: Justin900429
- License: apache-2.0
- Created: 2025-07-11T15:09:09.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-10-16T14:45:13.000Z (8 months ago)
- Last Synced: 2025-10-17T16:09:16.578Z (8 months ago)
- Topics: flux, huggingface, image-editing, image-inversion, multiturn, reconstruction, rectified-flow, simple-implementations
- Language: Python
- Homepage:
- Size: 9.98 MB
- Stars: 4
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://github.com/huggingface/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:
- [RF-Inversion](https://arxiv.org/abs/2410.10792) · *ICLR 2024*
- [RF-Solver](https://arxiv.org/abs/2411.04746) · *ICML 2025*
- [FireFlow](https://arxiv.org/abs/2412.07517) · *ICML 2025*
- [FTEdit](https://arxiv.org/abs/2411.15843) · *CVPR 2025*
- [FlowEdit](https://arxiv.org/abs/2412.08629) · *ICCV 2025*
- [Multi-Turn](https://arxiv.org/abs/2505.04320) · *ICCV 2025*
- [DNAEdit](https://arxiv.org/abs/2506.01430) · *NeurIPS 2025*
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:
```bash
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**:
```python
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
portrait of a cat
portrait of a tiger
RF-Solver
a cartoon style boy raising his left hand
a cartoon style Harry Potter raising his left hand
FireFlow
A young boy riding a brown horse in a countryside field.
A young boy riding a camel in a countryside field.
FTEdit
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
A gray cat and a brown dog sitting on the floor.
A raccoon and a brown dog sitting on the floor.
DNAEdit
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](notebook/inversion_test.ipynb).
The figure below shows the **reconstruction loss** between the forward and inverted processes over 25 steps.

---
## 🎨 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
"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-Solver** |  |
| **FireFlow** |  |
| **FTEdit** |  |
| **FlowEdit** |  |
| **Multi-Turn** |  |
| **DNAEdit** |  |
---
## 💡 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`](processors/) folder.
For the second, refer to the [`pipeline`](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
```bibtex
@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
```bibtex
@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
```bibtex
@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
```bibtex
@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
```bibtex
@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
```bibtex
@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
```bibtex
@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.