Instructions to use maryanlup/OT-RF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use maryanlup/OT-RF with Diffusers:
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] - Notebooks
- Google Colab
- Kaggle
|
Download README.md from maryanlup/OT-RF: direct link, hf CLI and curl.
- Browser
- Download file 2.81 kB
-
https://huggingface.co/maryanlup/OT-RF/resolve/main/README.md
- Command line
-
hf download hf://maryanlup/OT-RF/README.md
-
curl -L -o README.md https://huggingface.co/maryanlup/OT-RF/resolve/main/README.md
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). | |
|  | |
| ## 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 | |
| [](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} | |
| } | |
| ``` |