Remove image background
Project description
iRembg
MODIFIED VERSION OF REMBG FOR PERSONAL USE
Installation
Install it from pypi
pip install irembg
Usage as a cli
Remove the background from a remote image
curl -s http://input.png | rembg > output.png
Remove the background from a local file
rembg -o path/to/output.png path/to/input.png
Remove the background from all images in a folder
rembg -p path/to/inputs
Usage as a server
Start the server
rembg-server
Open your browser to
http://localhost:5000?url=http://image.png
Also you can send the file as a FormData (multipart/form-data):
<form action="http://localhost:5000" method="post" enctype="multipart/form-data">
<input type="file" name="file"/>
<input type="submit" value="upload"/>
</form>
Usage as a library
In app.py
import sys
from rembg.bg import remove
sys.stdout.buffer.write(remove(sys.stdin.buffer.read()))
Then run
cat input.png | python app.py > out.png
Advance usage
Sometimes it is possible to achieve better results by turning on alpha matting. Example:
curl -s http://input.png | rembg -a -ae 15 > output.png
Original | Without alpha matting | With alpha matting (-a -ae 15) |
References
- https://arxiv.org/pdf/2005.09007.pdf
- https://github.com/NathanUA/U-2-Net
- https://github.com/pymatting/pymatting
License
Copyright (c) 2020-present Daniel Gatis
Licensed under MIT License
Buy me a coffee
Liked some of my work? Buy me a coffee (or more likely a beer)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file irembg-1.0.14.tar.gz
.
File metadata
- Download URL: irembg-1.0.14.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ae5c42d3b06f2e491f54910accb0eb813e2b0ef5e272c45baafedf1e3ce67b1 |
|
MD5 | ac3f5fc4991b36acb7d57eb5406ab8e8 |
|
BLAKE2b-256 | a27161a69f4055398ad627b699820494bf5afb0728e856fbd580044924854abd |
File details
Details for the file irembg-1.0.14-py3-none-any.whl
.
File metadata
- Download URL: irembg-1.0.14-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97beb5067955d114e548cd2ebb1fcbeaf295aa11e025fcf7da0daf1c1cfa613d |
|
MD5 | 3fe57d881c30a6abc5e97dc92ac407b7 |
|
BLAKE2b-256 | b384c4d1f3fef22a6f5d87ec8e8bb458781471989e7bc296cd56cb0c51a99f1a |