你是怎么扣一个图片的?还在用
PS
?是时候用一键抠图了。Rembg 就是你要找的一键抠图工具。
rembg是一款不错的背景移除工具,其采用UNet网络进行训练得到分割模型,精度相当高,本人安装过程遇到一些问题,先简单总结如下:
开源地址:https://github.com/danielgatis/rembg
运行环境
Python3.6+
以上版本。
pip install rembg
pip install rembg[gpu]
> curl -s http://input.png | rembg i > output.png
rembg i path/to/input.png path/to/output.png
rembg p path/to/input path/to/output
我们可以启动一个抠图的服务。作为一个通用的api服务
rembg s
也可以用docker运行
docker run -p 5000:5000 danielgatis/rembg s
浏览器访问链接直接抠图
http://localhost:5000/?url=https://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Gull_portrait_ca_usa.jpg/1280px-Gull_portrait_ca_usa.jpg
<form
action="http://localhost:5000"
method="post"
enctype="multipart/form-data"
>
<input type="file" name="file" />
<input type="submit" value="upload" />
</form>
更多功能广大网友可以继续挖掘。