How to use from the
Use from the
Diffusers library
pip install -U diffusers transformers accelerate
import torch
from diffusers import DiffusionPipeline
from diffusers.utils import load_image

# switch to "mps" for apple devices
pipe = DiffusionPipeline.from_pretrained("maryanlup/OT-RF", dtype=torch.bfloat16, device_map="cuda")

prompt = "Turn this cat into a dog"
input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png")

image = pipe(image=input_image, prompt=prompt).images[0]

Optimal Transport for Rectified Flow Image Editing (WACV 2026)

Paper · arXiv · Code · Demo · Video

Zero-shot, OT-guided inversion and editing for rectified flow models, built on 🤗 Diffusers. This repo hosts only the pipeline code; weights come from FLUX.1-dev (gated — accept its license first).

teaser

Usage

import os, sys, torch
from diffusers import FluxPipeline
from diffusers.utils import load_image
from huggingface_hub import hf_hub_download

torch.manual_seed(42)

base_pipe = FluxPipeline.from_pretrained(
    "black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16,
    custom_pipeline="pipeline_flux_rf_inversion").to("cuda")
sys.modules["pipeline_flux_rf_inversion"] = sys.modules[type(base_pipe).__module__]

sys.path.append(os.path.dirname(hf_hub_download("maryanlup/OT-RF", "improved_optimal_transport_rf_inversion.py")))
from improved_optimal_transport_rf_inversion import OptimalTransportRFInversionPipeline
ot_pipe = OptimalTransportRFInversionPipeline.from_pipe(base_pipe)

image = load_image("https://raw.githubusercontent.com/marianlupascu/OT-RF/main/assets/face_input.jpg").resize((1024, 1024))
inverted_latents, image_latents, latent_image_ids = ot_pipe.invert(image=image, num_inversion_steps=28)

edited_image = ot_pipe(
    prompt="a person wearing glasses",
    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,
    use_ot_guidance=True, transport_strength=0.3, ot_guidance_phase=0.3,
    respect_prompt_guidance=False,
).images[0]
edited_image.save("edited_ot.png")

See the GitHub README for the full inversion + editing example.

Poster

WACV 2026 poster

Citation

@InProceedings{Lupascu_2026_WACV,
    author    = {Lupa\c{s}cu, Marian and Stupariu, Mihai Sorin},
    title     = {Optimal Transport for Rectified Flow Image Editing: Unifying Inversion-Based and Direct Methods},
    booktitle = {Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (WACV)},
    year      = {2026},
    pages     = {6764--6774}
}
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Space using maryanlup/OT-RF 1

Paper for maryanlup/OT-RF