July 6, 2025
O. Wolfson
rembg is a popular Python package for automatically removing the background from images using deep learning. It’s fast, easy to use, and runs entirely on your local machine.
Automatic Background Removal
rembg detects the subject of an image and removes the background, making it fully transparent (outputs a PNG with alpha channel).
No Cloud Uploads—Runs Locally All processing happens on your computer. No need to upload images to an external server.
Versatile Works with people, products, animals, objects—almost any image with a clear foreground.
Fast Uses pre-trained ONNX models for efficient, reliable performance (CPU or GPU).
Scriptable and Programmable Use from the command line or directly in your Python scripts.
rembgTo install the CLI and all extras:
shpip install 'rembg[cli]'
Note: It may be necessary to install more dependencies to get rembg to work. Read the snippet below for more details.
shpip install -r requirements.txt
rembg1. As a CLI Tool:
Remove the background from a photo in one line:
shrembg i input.jpg output.png
input.jpg: Your original image (JPG, PNG, or WEBP)output.png: Output with transparent background2. As a Python Library:
Use in your own Python scripts:
pythonfrom rembg import remove
with open("input.jpg", "rb") as i:
result = remove(i.read())
with open("output.png", "wb") as o:
o.write(result)
rembg?In summary:
rembg is the easiest and most powerful way to automatically make cutouts from images, with just one command or line of code.