- 🧹 Object Removal - Remove foreground objects and their effects using only object masks
- 🖼️ Object Insertion - Seamless generative insertion of objects into existing scenes
- 📊 Novel CFD Metric - Reference-free evaluation of object removal quality
Install dependencies and download OmniPaint weights:
bash scripts/setup.shRun this from the repository root.
- Single image:
python scripts/omnipaint_remove.py \
--input ./demo_assets/removal_samples/images/5.jpg \
--mask ./demo_assets/removal_samples/masks/5.png \
--output_dir ./outputs \
--seed 42 \
--steps 28 \
--device cuda:0- Directory:
python scripts/omnipaint_remove.py \
--input ./demo_assets/removal_samples/images \
--mask ./demo_assets/removal_samples/masks \
--output_dir ./outputs \
--seed 42 \
--steps 28 \
--device cuda:0- Single image:
python scripts/omnipaint_insert.py \
--background ./demo_assets/insertion_samples/backgrounds/background-2.png \
--mask ./demo_assets/insertion_samples/masks/mask-2.png \
--subject ./demo_assets/insertion_samples/subjects/subject-2.png \
--output_dir ./outputs \
--seed 42 \
--steps 28 \
--device cuda:0 \
--carvekit_device cuda:0- Directory:
python scripts/omnipaint_insert.py \
--background ./demo_assets/insertion_samples/backgrounds \
--mask ./demo_assets/insertion_samples/masks \
--subject ./demo_assets/insertion_samples/subjects \
--output_dir ./outputs \
--seed 42 \
--steps 28 \
--device cuda:0 \
--carvekit_device cuda:0The demo app supports both manual mask drawing and automatic mask generation using segmentation model.
-
Gradio environment setup:
bash scripts/app_setup.sh
Run this if you plan to launch
app.py. The installation may take around 15 minutes due to SAM2 setup and weight downloads. -
Run the app:
python app.py
- Directory mode expects the following structure by default:
- Removal:
demo_assets/removal_samples/images/*.{jpg,png,...}with matching masks indemo_assets/removal_samples/masks/*.{jpg,png,...}(same basenames). - Insertion:
demo_assets/insertion_samples/backgrounds/background-XX.png, masks indemo_assets/insertion_samples/masks/mask-XX.png, subjects indemo_assets/insertion_samples/subjects/subject-XX.png. Direct basename alignment also works.
- Removal:
- Mask quality strongly affects insertion performance. Prefer a single connected-component mask; avoid multiple disconnected masks.
See cfd_score for setup and usage.

