OT-RF / README.md
maryanlup's picture
Update README.md
c9afe03 verified
|
Raw History Blame Contribute Delete
2.81 kB
---
license: mit
library_name: diffusers
pipeline_tag: image-to-image
tags:
- image-editing
- rectified-flow
- optimal-transport
- flux
---
# Optimal Transport for Rectified Flow Image Editing (WACV 2026)
[Paper](https://huggingface.co/papers/2508.02363) · [arXiv](https://arxiv.org/abs/2508.02363) · [Code](https://github.com/marianlupascu/OT-RF) · [Demo](https://huggingface.co/spaces/maryanlup/OT-RF) · [Video](https://www.youtube.com/watch?v=ceJxfEnBIxQ)
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](https://huggingface.co/black-forest-labs/FLUX.1-dev) (gated — accept its license first).
![teaser](https://raw.githubusercontent.com/marianlupascu/OT-RF/main/assets/teaser.png)
## Usage
```python
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](https://github.com/marianlupascu/OT-RF) for the full inversion + editing example.
## Poster
[![WACV 2026 poster](https://huggingface.co/maryanlup/OT-RF/resolve/main/ot-rf_poster.jpg)](https://wacv.thecvf.com/virtual/2026/poster/955)
## Citation
```bibtex
@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}
}
```