提交成功
提交失败
U2Net python人像去除背景

就是使用 backgroundremover,其实就是一个Python库

github地址:https://github.com/nadermx/backgroundremover

使用很简单:就两步(github介绍安装中有一些没必要安装,可忽略)

第一步:安装库

pip install backgroundremover

第二步:执行命令

# backgroundremover -i "带背景照片" -o "去除背景照片"
backgroundremover -i "cg.jpg" -o "cg_outopt.jpg"

Python方式调用:

# 导入库
import os
os.system('backgroundremover -i "cg.jpg" -o "cg_output.jpg"')

原理:实际上就是python通过os去执行终端命令。

注意:

在第二步时,初次使用需要下载模型(大概170m),下载地址是google,因此需要能够访问google,才能下载。

备用下载地址:

链接:https://pan.baidu.com/s/1drYRXVQt2spfXnOb1hHBqw
提取码:6666

下载好的模型需要放到当前系统用户的目录下:

## Window:
C:/Users/Administrator/.u2net/u2net.pth
 
## Mac:
/Users/lyc/.u2net/u2net.pth
 
## Linux:
/root/.u2net/u2net.pth

如果找不到直接搜素【.u2net】文件夹。


免责声明:本站的所有博客、言论等仅代表作者个人观点,与本网站立场无关。本站公开发布此信息的目的在于传播更多信息,如有侵权请立即与我们联系,我们将及时处理。

点赞 0
评论 0
分享
收藏
打赏
举报