去背景rembg工具,安装方法

时间:2024-01-13浏览次数:996
GIT:https://github.com/danielgatis/rembg PYTHON版本:python: >3.7, 这是我的一个技术博客网站,主要目地是为了方便自己整理基础知识应用与收集常见技术问题,以便后面出现同样问题可以直接解决;

GIT:https://github.com/danielgatis/rembg


PYTHON版本:python: >3.7,<3.12,成功安装版本为:3.10.10


安装:


CPU support:

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.


.u2net模型位置:

C:UsersAdministrator.u2net

rembg位置:
C:UsersAdministratorAppDataLocalProgramsPythonPython310Libsite-packages


修改端口位置:
C:UsersAdministratorAppDataLocalProgramsPythonPython310Libsite-packagesrembgcommandss_command.py



启动方法:


rembg i

Used when input and output are files.


Remove the background from a remote image


curl -s http://input.png | rembg i > output.png

Remove the background from a local file


rembg i path/to/input.png path/to/output.png

Remove the background specifying a model


rembg i -m u2netp path/to/input.png path/to/output.png

Remove the background returning only the mask


rembg i -om path/to/input.png path/to/output.png

Remove the background applying an alpha matting


rembg i -a path/to/input.png path/to/output.png

Passing extras parameters


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

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


rembg p path/to/input path/to/output

Same as before, but watching for new/changed files to process


rembg p -w path/to/input path/to/output


rembg s 服务端启动


Used to start http server.


To see the complete endpoints documentation, go to: http://localhost:5000/api.


Remove the background from an image url


curl -s "http://localhost:5000/api/remove?url=http://input.png" -o output.png

Remove the background from an uploaded image


curl -s -F file=@/path/to/input.jpg "http://localhost:5000/api/remove"  -o output.png


GET方法示例:http://localhost:8900/api/remove?model=isnet-general-use&url=https://ai.vmofa.com/member/10000/5/thumbnails/2401/img_07153812844829.jpg

下一条:

没有下一条信息

Copyright © 2018 网站仅供学习交流使用,无任何商业用途  闽ICP备15015615号  技术支持: 微魔法建站