# Rembg
[![Downloads](https://img.shields.io/pypi/dm/rembg.svg)](https://img.shields.io/pypi/dm/rembg.svg)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://img.shields.io/badge/License-MIT-blue.svg)
[![Hugging Face Spaces](https://img.shields.io/badge/ð¤%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/KenjieDec/RemBG)
[![Streamlit App](https://img.shields.io/badge/ð%20Streamlit%20Community-Cloud-blue)](https://bgremoval.streamlit.app/)
Rembg is a tool to remove images background.
<p style="display: flex;align-items: center;justify-content: center;">
<img alt="example car-1" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/car-1.jpg" width="100" />
<img alt="example car-1.out" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/car-1.out.png" width="100" />
<img alt="example car-2" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/car-2.jpg" width="100" />
<img alt="example car-2.out" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/car-2.out.png" width="100" />
<img alt="example car-3" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/car-3.jpg" width="100" />
<img alt="example car-3.out" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/car-3.out.png" width="100" />
</p>
<p style="display: flex;align-items: center;justify-content: center;">
<img alt="example animal-1" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/animal-1.jpg" width="100" />
<img alt="example animal-1.out" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/animal-1.out.png" width="100" />
<img alt="example animal-2" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/animal-2.jpg" width="100" />
<img alt="example animal-2.out" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/animal-2.out.png" width="100" />
<img alt="example animal-3" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/animal-3.jpg" width="100" />
<img alt="example animal-3.out" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/animal-3.out.png" width="100" />
</p>
<p style="display: flex;align-items: center;justify-content: center;">
<img alt="example girl-1" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/girl-1.jpg" width="100" />
<img alt="example girl-1.out" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/girl-1.out.png" width="100" />
<img alt="example girl-2" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/girl-2.jpg" width="100" />
<img alt="example girl-2.out" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/girl-2.out.png" width="100" />
<img alt="example girl-3" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/girl-3.jpg" width="100" />
<img alt="example girl-3.out" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/girl-3.out.png" width="100" />
</p>
<p style="display: flex;align-items: center;justify-content: center;">
<img alt="example anime-girl-1" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/anime-girl-1.jpg" width="100" />
<img alt="example anime-girl-1.out" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/anime-girl-1.out.png" width="100" />
<img alt="example anime-girl-2" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/anime-girl-2.jpg" width="100" />
<img alt="example anime-girl-2.out" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/anime-girl-2.out.png" width="100" />
<img alt="example anime-girl-3" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/anime-girl-3.jpg" width="100" />
<img alt="example anime-girl-3.out" src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/anime-girl-3.out.png" width="100" />
</p>
**If this project has helped you, please consider making a [donation](https://www.buymeacoffee.com/danielgatis).**
## Sponsor
<table>
<tr>
<td align="center" vertical-align="center">
<a href="https://photoroom.com/api/remove-background?utm_source=rembg&utm_medium=github_webpage&utm_campaign=sponsor" >
<img src="https://font-cdn.photoroom.com/media/api-logo.png" width="120px;" alt="Unsplash" />
</a>
</td>
<td align="center" vertical-align="center">
<b>PhotoRoom Remove Background API</b>
<br />
<a href="https://photoroom.com/api/remove-background?utm_source=rembg&utm_medium=github_webpage&utm_campaign=sponsor">https://photoroom.com/api</a>
<br />
<p width="200px">
Fast and accurate background remover API<br/>
</p>
</td>
</tr>
</table>
## Requirements
```text
python: >3.7, <3.13
```
## Installation
CPU support:
```bash
pip install rembg # for library
pip install rembg[cli] # for library + cli
```
GPU support:
First of all, you need to check if your system supports the `onnxruntime-gpu`.
Go to <https://onnxruntime.ai> and check the installation matrix.
<p style="display: flex;align-items: center;justify-content: center;">
<img alt="onnxruntime-installation-matrix" src="https://raw.githubusercontent.com/danielgatis/rembg/master/onnxruntime-installation-matrix.png" width="400" />
</p>
If yes, just run:
```bash
pip install rembg[gpu] # for library
pip install rembg[gpu,cli] # for library + cli
```
## Usage as a cli
After the installation step you can use rembg just typing `rembg` in your terminal window.
The `rembg` command has 4 subcommands, one for each input type:
- `i` for files
- `p` for folders
- `s` for http server
- `b` for RGB24 pixel binary stream
You can get help about the main command using:
```shell
rembg --help
```
As well, about all the subcommands using:
```shell
rembg <COMMAND> --help
```
### rembg `i`
Used when input and output are files.
Remove the background from a remote image
```shell
curl -s http://input.png | rembg i > output.png
```
Remove the background from a local file
```shell
rembg i path/to/input.png path/to/output.png
```
Remove the background specifying a model
```shell
rembg i -m u2netp path/to/input.png path/to/output.png
```
Remove the background returning only the mask
```shell
rembg i -om path/to/input.png path/to/output.png
```
Remove the background applying an alpha matting
```shell
rembg i -a path/to/input.png path/to/output.png
```
Passing extras parameters
```shell
SAM example
rembg i -m sam -x '{ "sam_prompt": [{"type": "point", "data": [724, 740], "label": 1}] }' examples/plants-1.jpg examples/plants-1.out.png
```
```shell
Custom model example
rembg i -m u2net_custom -x '{"model_path": "~/.u2net/u2net.onnx"}' path/to/input.png path/to/output.png
```
### rembg `p`
Used when input and output are folders.
Remove the background from all images in a folder
```shell
rembg p path/to/input path/to/output
```
Same as before, but watching for new/changed files to process
```shell
rembg p -w path/to/input path/to/output
```
### rembg `s`
Used to start http server.
```shell
rembg s --host 0.0.0.0 --port 7000 --log_level info
```
To see the complete endpoints documentation, go to: `http://localhost:7000/api`.
Remove the background from an image url
```shell
curl -s "http://localhost:7000/api/remove?url=http://input.png" -o output.png
```
Remove the background from an uploaded image
```shell
curl -s -F file=@/path/to/input.jpg "http://localhost:7000/api/remove" -o output.png
```
### rembg `b`
Process a sequence of RGB24 images from stdin. This is intended to be used with another program, such as FFMPEG, that outputs RGB24 pixel data to stdout, which is piped into the stdin of this program, although nothing prevents you from manually typing in images at stdin.
```shell
rembg b i
没有合适的资源?快使用搜索试试~ 我知道了~
图像背景移除工具:一个简单且实用的工具,专门用于移除图像背景或进行抠图
共120个文件
png:46个
py:26个
jpg:20个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 83 浏览量
2024-04-30
10:38:40
上传
评论
收藏 26.64MB ZIP 举报
温馨提示
一个简单且实用的工具,专门用于移除图像背景或进行抠图。它通过先进的算法,能够快速准确地分割前景和背景,适用于个人和商业用途。无论是制作透明背景的产品图片,还是进行创意设计,Rembg 都能提供有效的帮助。
资源推荐
资源详情
资源评论
收起资源包目录
图像背景移除工具:一个简单且实用的工具,专门用于移除图像背景或进行抠图 (120个子文件)
setup.cfg 524B
Dockerfile 176B
.dockerignore 123B
.editorconfig 176B
.gitattributes 31B
.gitignore 211B
MANIFEST.in 201B
pytest.ini 57B
_modpath.iss 7KB
_setup.iss 1KB
food-1.jpg 4.75MB
food-1.out.jpg 4.03MB
food-1.out.alpha.jpg 3.02MB
plants-1.jpg 1.44MB
plants-1.jpg 1.44MB
animal-3.jpg 247KB
cloth-1.jpg 211KB
car-2.jpg 166KB
animal-1.jpg 135KB
anime-girl-2.jpg 125KB
anime-girl-1.jpg 86KB
anime-girl-1.jpg 86KB
anime-girl-3.jpg 74KB
car-3.jpg 73KB
car-1.jpg 59KB
car-1.jpg 59KB
animal-2.jpg 44KB
girl-3.jpg 38KB
girl-2.jpg 34KB
girl-1.jpg 18KB
README.md 13KB
USAGE.md 2KB
feature_request.md 616B
bug_report.md 558B
animal-3.out.png 1.27MB
plants-1.isnet-general-use.png 698KB
plants-1.silueta.png 608KB
plants-1.u2net.png 572KB
plants-1.isnet-anime.png 510KB
plants-1.u2netp.png 479KB
cloth-1.u2netp.png 408KB
cloth-1.u2net_human_seg.png 405KB
cloth-1.silueta.png 399KB
cloth-1.u2net.png 399KB
animal-1.out.png 397KB
cloth-1.isnet-general-use.png 394KB
cloth-1.isnet-anime.png 392KB
plants-1.u2net_human_seg.png 341KB
cloth-1.u2net_cloth_seg.png 270KB
car-2.out.png 251KB
anime-girl-3.out.png 249KB
anime-girl-2.out.png 218KB
anime-girl-1.isnet-anime.png 215KB
anime-girl-1.out.png 215KB
anime-girl-1.u2netp.png 206KB
anime-girl-1.u2net_human_seg.png 196KB
anime-girl-1.isnet-general-use.png 194KB
anime-girl-1.u2net.png 181KB
anime-girl-1.silueta.png 180KB
animal-2.out.png 174KB
cloth-1.sam.png 165KB
girl-1.out.png 114KB
onnxruntime-installation-matrix.png 111KB
car-3.out.png 104KB
girl-3.out.png 102KB
car-1.isnet-general-use.png 101KB
girl-2.out.png 87KB
car-1.u2netp.png 83KB
car-1.silueta.png 80KB
car-1.u2net.png 79KB
car-1.out.png 78KB
car-1.sam.png 70KB
car-1.isnet-anime.png 52KB
anime-girl-1.u2net_cloth_seg.png 32KB
plants-1.sam.png 29KB
plants-1.out.png 29KB
car-1.u2net_human_seg.png 23KB
anime-girl-1.sam.png 21KB
plants-1.u2net_cloth_seg.png 17KB
car-1.u2net_cloth_seg.png 6KB
_build-exe.ps1 286B
versioneer.py 78KB
_version.py 23KB
sam.py 11KB
s_command.py 10KB
bg.py 10KB
p_command.py 6KB
b_command.py 5KB
u2net_cloth_seg.py 3KB
u2net_custom.py 3KB
silueta.py 3KB
i_command.py 3KB
dis_general_use.py 2KB
base.py 2KB
u2net.py 2KB
u2net_human_seg.py 2KB
dis_anime.py 2KB
setup.py 2KB
test_remove.py 2KB
u2netp.py 2KB
共 120 条
- 1
- 2
资源评论
UnknownToKnown
- 粉丝: 1w+
- 资源: 643
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功