# Remove an Image Background With AI (Free)

> rembg cuts a subject to a transparent PNG from the command line — one file or a whole folder, offline, full resolution, no watermark and no upload.

- Canonical: https://guides-ai.pages.dev/guides/remove-background-with-ai/
- Plate 12.01 · Topic: AI images (https://guides-ai.pages.dev/topics/image/)
- Published: 10 Jun 2026 · Updated: 06 Sept 2026 · 3 min read
- Source site: guides-ai — https://guides-ai.pages.dev/

Web tools like remove.bg are fine for one image, but they cap free downloads at low resolution and every file leaves your machine. **`rembg` does the same job locally, at full resolution, on as many files as you like.** It runs a segmentation model that predicts a per-pixel alpha mask, then writes a transparent PNG — plain local [inference](/glossary/#inference), no account.

## 1. Install

```bash
pip install "rembg[cpu,cli]"
```

Installs the library plus the `rembg` command. This has changed: a bare `pip install rembg` no longer pulls a runtime — you must pick an extra. Use `"rembg[gpu,cli]"` for NVIDIA/CUDA or `"rembg[rocm,cli]"` for AMD. Python 3.11, 3.12 or 3.13 is required.

## 2. Cut one image

```bash
rembg i input.jpg output.png
```

Reads one file, writes a transparent PNG beside it. The first run downloads the model, so it is slow once and fast after.

## 3. Batch a folder

```bash
rembg p ./photos ./cutouts
```

Processes every image in `./photos` into `./cutouts`, reusing the loaded model instead of paying startup cost per file. There is also `rembg s --host 0.0.0.0 --port 7000` if you would rather call it as a local HTTP service.

## 4. Change the model when edges are rough

```bash
rembg i -m isnet-general-use input.jpg output.png
```

Swaps the segmentation model. The default is `bria-rmbg`; `isnet-general-use` and the `birefnet-*` family often hold hair and thin objects better, `u2net_human_seg` is tuned for people, and `isnet-anime` for illustration.

## Verify it worked

```bash
python -c "from PIL import Image; print(Image.open('output.png').mode)"
```

Prints the colour mode — you want `RGBA`. `RGB` means the alpha channel was dropped, almost always because the output filename ended in `.jpg`, which cannot store transparency.

**If it fails:** `command not found` means you installed without the `cli` extra. Fuzzy or missing edges usually mean low contrast between subject and background rather than a bad model — reshoot or try `-m birefnet-general`. For a mask you want to paint by hand instead, see [inpainting](/guides/ai-image-inpainting/); to enlarge the cutout afterwards, [upscale it locally](/guides/upscale-images-locally/). Model list and options: [the rembg README](https://github.com/danielgatis/rembg).
