We propose RF-Solver to solve the rectified flow ODE with less error, thus enhancing both sampling quality and inversion-reconstruction accuracy for rectified-flow-based generative models. Furthermore, we propose RF-Edit to leverage the RF-Solver for image and video editing tasks. Our methods achieve impressive performance on various tasks, including text-to-image generation, image/video inversion, and image/video editing.
# 🔥 News - [2024.11.18] More examples for style transfer are available! - [2024.11.18] Gradio Demo for image editing is available! - [2024.11.11] The homepage of the project is available! - [2024.11.08] Code for image editing is released! - [2024.11.08] Paper released! # 👨💻 ToDo - ☑️ Release the gradio demo - ☑️ Release scripts to for more image editing cases - ☐ Release the code for video editing # 📖 Method ## RF-Solver
We derive the exact formulation of the solution for Rectified Flow ODE. The non-linear part in this solution is processed by Taylor Expansion. Through higher order expansion, the approximation error in the solution is significantly reduced, thus achieving impressive performance on both text-to-image sampling and image/video inversion.
## RF-EditBased on RF-Solver, we further propose the RF-Edit for image and video editing. RF-Edit framework leverages the features from inversion in the denoising process, which enables high-quality editing while preserving the structual information of source image/video. RF-Edit contains two sub-modules, espectively for image editing and video editing.
# 🛠️ Code Setup The environment of our code is the same as FLUX, you can refer to the [official repo](https://github.com/black-forest-labs/flux/tree/main) of FLUX, or running the following command to construct the environment. ``` conda create --name RF-Solver-Edit python=3.10 conda activate RF-Solver-Edit pip install -e ".[all]" ``` # 🚀 Examples for Image Editing We have provided several scripts to reproduce the results in the paper, mainly including 3 types of editing: Stylization, Adding, Replacing. We suggest to run the experiment on a single A100 GPU. ## StylizationRef Style | |||
Editing Scripts | Trump | Marilyn Monroe | Einstein |
Edtied image | |||
Editing Scripts | Biden | Batman | Herry Potter |
Edtied image |
Source image | |||
Editing Scripts | + hiking stick | horse -> camel | + dog |
Edtied image |
## Image Stylization
## Image Editing
## Video Editing
# 🖋️ Citation If you find our work helpful, please **star 🌟** this repo and **cite 📑** our paper. Thanks for your support! ``` @article{wang2024taming, 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}, journal={arXiv preprint arXiv:2411.04746}, year={2024} } ``` # Acknowledgements We thank [FLUX](https://github.com/black-forest-labs/flux/tree/main) for their clean codebase. # Contact The code in this repository is still being reorganized. Errors that may arise during the organizing process could lead to code malfunctions or discrepancies from the original research results. If you have any questions or concerns, please send email to wjs23@mails.tsinghua.edu.cn.