目标:自动抠图,把人物抠出
原理:本质是使用深度学习的一个模型进行抠图,我们只使用这个模型,不必了解其算法
具体步骤:
一.获取属于自己的API
1.登录网站remove.bg
(英文的,看不懂可使用网页翻译)
2.用邮箱注册并登录(邮箱验证)
3.点击页面右上角,选择我的账户
4.显示API密钥,复制到记事本
二.安装第三方库
'''
如果报错提示未安装其他第三方库,使用指令pip install -i https://mirrors.aliyun.com/pypi/simple 模块名 ,进行安装'''
pip install -i https://mirrors.aliyun.com/pypi/simple removebg
pip install -i https://mirrors.aliyun.com/pypi/simple altgraph==0.17
pip install -i https://mirrors.aliyun.com/pypi/simple macholib==1.14
pip install -i https://mirrors.aliyun.com/pypi/simple Pillow==7.0.0
pip install -i https://mirrors.aliyun.com/pypi/simple PyInstaller==3.6
pip install -i https://mirrors.aliyun.com/pypi/simple os
三.代码
#功能:去除多张图片背景
from removebg import RemoveBg
import os
#根据上面步骤找到自己的API,并将API复制至下方
rmbg = RemoveBg("此处放上你的API密钥","error.log")
#设置图片存放路径