Skip to content

Latest commit

ย 

History

History
122 lines (101 loc) ยท 5.36 KB

File metadata and controls

122 lines (101 loc) ยท 5.36 KB

๐Ÿ–ผ๏ธ Image Editing Using FLUX

๐Ÿ› ๏ธ Code Setup

The environment of our code is the same as FLUX, you can refer to the official repo of FLUX, or running the following command to construct the environment.

conda create --name RF-Solver-ImageEdit python=3.10
conda activate RF-Solver-ImageEdit
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.

Stylization

Ref Style
Editing Scripts Trump Marilyn Monroe Einstein
Edtied image
Editing Scripts Biden Batman Herry Potter
Edtied image

Adding & Replacing

Source image
Editing Scripts + hiking stick horse -> camel + dog
Edtied image

๐Ÿช„ Edit Your Own Image

Gradio Demo

We provide the gradio demo for image editing, which is also available on our ๐Ÿค— Huggingface Space! You can also run the gradio demo on your own device using the following command:

cd src
python gradio_demo.py

Here is an example of using the gradio demo to edit an image! Note that here "Number of inject steps" means the steps of feature sharing in RF-Edit, which is highly related to the quality of edited results. We suggest tuning this parameter, and selecting the results with the best visual quality.

Command Line

You can also run the following scripts to edit your own image.

cd src
python edit.py  --source_prompt [describe the content of your image or leave it as null] \
                --target_prompt [describe your editing requirements] \
                --guidance 2 \
                --source_img_dir [the path of your source image] \
                --num_steps 30  \
                --inject [typically set to a number between 2 to 8] \
                --name 'flux-dev' --offload \
                --output_dir [output path] 

Similarly, The --inject refers to the steps of feature sharing in RF-Edit, which is highly related to the performance of 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}
}