Rectified flows for image inversion and editing. Our approach efficiently inverts reference style images in (a) and (b) without requiring text descriptions of the images and applies desired edits based on new prompts (e.g. “a girl” or “a dwarf”). For a reference content image (e.g. a cat in © or a face in (d)), it performs semantic image editing e.g. “ sleeping cat”) and stylization (e.g. “a photo of a cat in origmai style”) based on prompts, without leaking unwanted content from the reference image (input images have orange borders).

We support a Gradio demo for better user experience:
Web demonstration🔥
Try RF-Inversion using diffusers implementation! Load hyper Flux LoRA to enable 8 step inversion and editing🔥
import torch
from diffusers import FluxPipeline
import requests
import PIL
from io import BytesIO
import os
# torch.manual_seed(999)
pipe = FluxPipeline.from_pretrained(
"black-forest-labs/FLUX.1-dev",
torch_dtype=torch.bfloat16,
custom_pipeline="pipeline_flux_rf_inversion")
pipe.to("cuda")
def download_image(url):
response = requests.get(url)
return PIL.Image.open(BytesIO(response.content)).convert("RGB")
img_url = "https://www.aiml.informatik.tu-darmstadt.de/people/mbrack/tennis.jpg"
image = download_image(img_url)
inverted_latents, image_latents, latent_image_ids = pipe.invert(
image=image,
num_inversion_steps=28,
gamma=0.5
)
edited_image = pipe(
prompt="a tomato",
inverted_latents=inverted_latents,
image_latents=image_latents,
latent_image_ids=latent_image_ids,
start_timestep=0,
stop_timestep=7/28,
num_inference_steps=28,
eta=0.9,
).images[0]
save_dir = "./results/"
if not os.path.exists(save_dir):
os.makedirs(save_dir)
image_save_path = os.path.join(save_dir, f"rf_inversion.png")
edited_image.save(image_save_path)
print('Results saved here: ', image_save_path)
Try ComfyUI for better experience:
ComfyUI Node🔥. Follow the guidelines below to setup locally.
cd ComfyUI
python main.py
cd ComfyUI/custom_nodes
cd …
python main.py
cd ComfyUI
python main.py
@article{rout2024rfinversion,
title={Semantic Image Inversion and Editing using Rectified Stochastic Differential Equations},
author={Litu Rout and Yujia Chen and Nataniel Ruiz and Constantine Caramanis and Sanjay Shakkottai and Wen-Sheng Chu},
journal={arXiv preprint arXiv:2410.10792},
year={2024}
}
Copyright © 2024, Google LLC. All rights reserved.
We use cookies
We use cookies to analyze traffic and improve your experience. You can accept or reject analytics cookies.