Instructions to use yeates/OmniPaint with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use yeates/OmniPaint 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("black-forest-labs/FLUX.1-dev", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("yeates/OmniPaint") 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
- Local Apps Settings
- Draw Things
Add model card with usage instructions and technical details
Browse files
README.md
CHANGED
|
@@ -1,3 +1,108 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
library_name: diffusers
|
| 4 |
+
pipeline_tag: image-to-image
|
| 5 |
+
tags:
|
| 6 |
+
- image-inpainting
|
| 7 |
+
- object-removal
|
| 8 |
+
- object-insertion
|
| 9 |
+
- flux
|
| 10 |
+
- lora
|
| 11 |
+
- iccv2025
|
| 12 |
+
base_model:
|
| 13 |
+
- black-forest-labs/FLUX.1-dev
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# OmniPaint: Mastering Object-Oriented Editing via Disentangled Insertion-Removal Inpainting
|
| 17 |
+
|
| 18 |
+
<p align="center">
|
| 19 |
+
<b>ICCV 2025</b>
|
| 20 |
+
</p>
|
| 21 |
+
|
| 22 |
+
<p align="center">
|
| 23 |
+
<a href="https://arxiv.org/pdf/2503.08677"><img src="https://img.shields.io/badge/Paper-arXiv-b31b1b.svg"></a>
|
| 24 |
+
<a href="https://www.yongshengyu.com/OmniPaint-Page/"><img src="https://img.shields.io/badge/Website-Project-6535a0"></a>
|
| 25 |
+
<a href="https://github.com/yeates/OmniPaint"><img src="https://img.shields.io/badge/GitHub-Code-181717?logo=github"></a>
|
| 26 |
+
<a href="https://huggingface.co/datasets/yeates/omnipaint-bench"><img src="https://img.shields.io/badge/HuggingFace-Dataset-FFD21E?logo=huggingface"></a>
|
| 27 |
+
</p>
|
| 28 |
+
|
| 29 |
+
## Model Description
|
| 30 |
+
|
| 31 |
+
OmniPaint is a unified framework for **object-oriented image editing** that disentangles object insertion and removal into two specialized inpainting tasks. Built on top of [FLUX.1-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev), OmniPaint uses **LoRA adapters** to enable:
|
| 32 |
+
|
| 33 |
+
- **Object Removal** — Remove foreground objects and their visual effects (shadows, reflections) using only object masks
|
| 34 |
+
- **Object Insertion** — Seamlessly insert objects into existing scenes with harmonious lighting and perspective
|
| 35 |
+
|
| 36 |
+
The model also introduces a novel **CFD (Content-aware Frechet Distance)** metric for reference-free evaluation of object removal quality.
|
| 37 |
+
|
| 38 |
+
## Model Files
|
| 39 |
+
|
| 40 |
+
| File | Description |
|
| 41 |
+
|------|-------------|
|
| 42 |
+
| `weights/omnipaint_remove.safetensors` | LoRA weights for object removal |
|
| 43 |
+
| `weights/omnipaint_insert.safetensors` | LoRA weights for object insertion |
|
| 44 |
+
| `embeddings/remove.npz` | Pre-computed text embeddings for removal |
|
| 45 |
+
| `embeddings/insert.npz` | Pre-computed text embeddings for insertion |
|
| 46 |
+
|
| 47 |
+
## Usage
|
| 48 |
+
|
| 49 |
+
### Installation
|
| 50 |
+
|
| 51 |
+
```bash
|
| 52 |
+
git clone https://github.com/yeates/OmniPaint.git
|
| 53 |
+
cd OmniPaint
|
| 54 |
+
bash scripts/setup.sh
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
This will install dependencies and automatically download model weights from this repository.
|
| 58 |
+
|
| 59 |
+
### Object Removal
|
| 60 |
+
|
| 61 |
+
```bash
|
| 62 |
+
python scripts/omnipaint_remove.py \
|
| 63 |
+
--input ./demo_assets/removal_samples/images/5.jpg \
|
| 64 |
+
--mask ./demo_assets/removal_samples/masks/5.png \
|
| 65 |
+
--output_dir ./outputs \
|
| 66 |
+
--seed 42 --steps 28 --device cuda:0
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
### Object Insertion
|
| 70 |
+
|
| 71 |
+
```bash
|
| 72 |
+
python scripts/omnipaint_insert.py \
|
| 73 |
+
--background ./demo_assets/insertion_samples/backgrounds/background-2.png \
|
| 74 |
+
--mask ./demo_assets/insertion_samples/masks/mask-2.png \
|
| 75 |
+
--subject ./demo_assets/insertion_samples/subjects/subject-2.png \
|
| 76 |
+
--output_dir ./outputs \
|
| 77 |
+
--seed 42 --steps 28 --device cuda:0
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
### Gradio Demo
|
| 81 |
+
|
| 82 |
+
```bash
|
| 83 |
+
bash scripts/app_setup.sh # one-time setup (~15 min)
|
| 84 |
+
python app.py
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
## Technical Details
|
| 88 |
+
|
| 89 |
+
- **Base model**: [FLUX.1-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev) (FluxTransformer2DModel)
|
| 90 |
+
- **Training method**: LoRA fine-tuning with disentangled adapters for insertion and removal
|
| 91 |
+
- **Framework**: Diffusers + PEFT
|
| 92 |
+
- **Inference steps**: 28 (default)
|
| 93 |
+
- **Guidance scale**: 3.5 (default)
|
| 94 |
+
|
| 95 |
+
## Citation
|
| 96 |
+
|
| 97 |
+
```bibtex
|
| 98 |
+
@article{yu2025omnipaint,
|
| 99 |
+
title={OmniPaint: Mastering Object-Oriented Editing via Disentangled Insertion-Removal Inpainting},
|
| 100 |
+
author={Yu, Yongsheng},
|
| 101 |
+
journal={arXiv preprint arXiv:2503.08677},
|
| 102 |
+
year={2025}
|
| 103 |
+
}
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
## License
|
| 107 |
+
|
| 108 |
+
This model is released under the [MIT License](https://opensource.org/licenses/MIT).
|