📈 GH Trending Explorer 🎲 Surprise me

← all repos

danielgatis / rembg

git clone https://github.com/danielgatis/rembg.git v2.0.85 · 1mo ago

Rembg is a tool to remove images background

+5
stars, 24h · #2,990
+~35
stars, 7 days · #3,618
+~150
stars, 30 days · #3,614
25k
★ total · +0% this week
2.4k
forks · 0 open issues

Star history (as recorded here)

2026-10-20 · 25,136 ★ 2026-10-22 · 25,154 ★
LanguagePython
LicenseMIT
Created2020-08-10 (6y ago)
Last push1d ago
Watchers171
OwnerUser

GitHub topics

Links

README excerpt
Rembg is a tool to remove image backgrounds. It can be used as a CLI, Python library, HTTP server, or Docker container. 
## Sponsors
 PhotoRoom Remove Background API 
 https://photoroom.com/api 
 Fast and accurate background remover API 
**If this project has helped you, please consider making a donation.**
## Requirements
 [code] bash
pip install "rembg[gpu]" # for library
pip install "rembg[gpu,cli]" # for library + cli
 [code] bash
pip install "rembg[rocm]" # for library
pip install "rembg[rocm,cli]" # for library + cli
 [code] shell
rembg --help
 [code] shell
rembg --help
 [code] shell
curl -s http://input.png | rembg i > output.png
 [code] shell
rembg i path/to/input.png path/to/output.png
 [code] shell
rembg i path/to/input.png
# → path/to/input.out.png
 [code] shell
rembg i -m u2netp path/to/input.png path/to/output.png
 [code] shell
rembg i -om path/to/input.png path/to/output.png
 [code] shell
rembg i -a path/to/input.png path/to/output.png
 [code] shell
rembg i -dc path/to/input.png path/to/output.png
 [code] shell
rembg i -m sam -x '{ "sam_prompt": [{"type": "point", "data": [724, 740], "label": 1}] }' examples/plants-1.jpg examples/plants-1.out.png
 [code] shell
rembg i -m u2net_custom -x '{"model_path": "~/.u2net/u2net.onnx"}' path/to/input.png path/to/output.png
 [code] shell
export WITHOUTBG_API_KEY=sk_...
rembg i -m withoutbg path/to/input.png path/to/output.png
 [code] shell
export ATLASCLOUD_API_KEY=apikey-...
rembg i -m atlascloud path/to/input.png path/to/output.png
 [code] shell
rembg i -m withoutbg -x '{"api_key":"sk_..."}' path/to/input.png path/to/output.png
 [code] shell
rembg p path/to/input path/to/output
 [code] shell
rembg p -w path/to/input path/to/output
 [code] shell
rembg s --host 0.0.0.0 --port 7000 --log_level info
 [code] shell
rembg s --no-ui
 [code] shell
curl -s "http://localhost:7000/api/remove?url=http://input.png" -o output.png
 [code] shell
curl -s -F file=@/path/to/input.jpg "http://localhost:7000/api/remove" -o output.png
 [code] shell
rembg b -o 
 [code] shell
ffmpeg -i input.mp4 -ss 10 -an -f rawvideo -pix_fmt rgb24 pipe:1 | rembg b 1280 720 -o folder/output-%03u.png
 [code] python
from rembg import remove
with open('input.png', 'rb') as i:
 with open('output.png', 'wb') as o:
 input = i.read()
 output = remove(input)
 o.write(output)
 [code] python
from rembg import remove
from PIL import Image
input = Image.open('input.png')
output = remove(input)
output.save('output.png')
 [code] python
from rembg import remove
import cv2
input = cv2.imread('input.png')
output = remove(input)
cv2.imwrite('output.png', output)
 [code] python
from rembg import remove
with open('input.png', 'rb') as i:
 with open('output.png', 'wb') as o:
 input = i.read()
 output = remove(input, force_return_bytes=True)
 o.write(output)
 [code] python
from pathlib import Path
from rembg import remove, new_session
session = new_session()
for file in Path('path/to/folder').glob('*.png'):
 input_path = str(file)
 output_path = str(file