GIMP 3 plugin for background removal using nobg / FeyNobg, 'cause GIMP still doesn't have a good built-in background remover. Works on my machine. Might work on yours. Pull Requests are welcome :)
- Background removal (Masking)
- Background removal (Recolor)
- Simple subject removal (Recolor)
NASA test photo background removal (credit):
![]() Original |
![]() Mask |
![]() Recolor |
![]() Recolor + touch-up |
Portrait background blur — naively blurred vs Remove Subject (Recolor) blurred:
![]() Original blurred + foreground |
![]() Foreground (Recolor) |
![]() Background (Remove Subject) |
![]() Background blurred + foreground |
Table of contents
Runs nobg on the active layer and gives you a layer mask. Recolor mode also fixes foreground colors at soft edges (hair, glass, etc.) and adds a new layer instead. Everything runs locally on your machine.
I use this on Fedora with RPM GIMP and an NVIDIA GPU. Flatpak GIMP, Windows, macOS, and CPU-only setups are largely untested. The installer is cross-platform Python, but may not work depending on your specific system. PRs welcome if you get it working somewhere I haven't.
- GIMP 3.0+
- Python 3.11 or 3.12
- uv
- Native GIMP install recommended (I use Fedora RPM, not Flatpak)
Fedora packages if import gi fails:
sudo dnf install gimp python3-gobject gtk3 gobject-introspection-devel python3-devel cairo-devel- Clone and set up the venv:
git clone https://github.com/CreativeMindstorms/GIMP-bg-remover
cd GIMP-bg-remover
uv venv .venv
uv sync- NVIDIA GPU (optional):
uv sync --no-group cpu --extra cudaUses cu128 wheels from pyproject.toml. Change the index URL there if your driver needs a different CUDA build. Default uv sync installs CPU-only PyTorch (+cpu wheels, slower inference).
- Install the GIMP plugin (Linux, macOS, Windows):
uv run --no-sync python scripts/install-gimp-plugin.py- Restart GIMP.
First run downloads the FeyNobg model from Hugging Face (~1 GB). Prefetch if you want:
uv run --no-sync hf download feyninc/FeyNobgSelect a layer, then pick one of:
- Layer > Remove Background (Mask) - matte as layer mask, pixels unchanged
- Layer > Remove Background (Recolor) - foreground color recovery, new layer above
- Layer > Remove Subject (Recolor) - subject-free background as opaque RGB layer (Useful for portrait background blurring)
| Mode | What it does |
|---|---|
| Mask | nobg matte goes on as a layer mask. RGB stays put. |
| Recolor | New layer with recovered colors and a refined matte in the pixels, plus a coarse nobg matte as the layer mask (see below). |
| Subject (Recolor) | Opaque RGB layer with the subject removed and background colors recovered at soft edges. Coarse nobg matte as layer mask over the subject (see below). |
Recolor builds two masks from the same photo:
- Refined matte (in the layer pixels) - pymatting cleanup. Usually nicer on hair and soft edges.
- Coarse matte (layer mask) - straight from nobg. Usually nicer on hard edges (tables, shoulders, crisp outlines).
The layer mask removes noise around strong edges, but may also remove detail around soft edges. Sometimes it may look better to (partly) remove the layer mask and use the pure output layer.
Paint on the layer mask to mix them: whiten where you want the refined detail to show through (hair, wispy edges). Leave it dark where you want the coarse mask to keep a clean hard edge.
Recolor dialog: Processing size (low = fast, high = sharp). Run on CPU if you hit VRAM errors. Soft edge zone (low = better for hard edges, high = better for hair). Enable Also create background layer to add a subject-free background plate below the cutout in the same run.
Mask mode skips layers that already have a mask. Large images infer at up to 2560 px on the long edge; the mask is written at full resolution.
GIMP spawns a new plugin process every run, so the model reloads and unloads each time.
Test inference without GIMP:
uv run --no-sync python -m nobg_gimp.inference examples/base.jpg /tmp/mask.pngForce CPU:
uv run --no-sync python -m nobg_gimp.inference examples/base.jpg /tmp/mask.png --device cpuGPL-3.0-or-later. Full text in LICENSE.
GIMP plugins that call GIMP's API should be GPL-compatible. Dependencies have their own licenses; see THIRD_PARTY_NOTICES.md.
- nobg and FeyNobg by Feyn
- BiRefNet (architecture behind FeyNobg)
- pymatting for the Recolor pipeline
- Example photo: NASA, Commander Eileen Collins (see examples/README.md)








