https://github.com/danielgatis/rembg
Linux环境下:
python3.8环境下
pip install rembg
在第一次运行时,若运行不出来,说明没有自动加载下载模型。需要下载模型。
https://docs.google.com/uc?export=download&id=1ao1ovG1Qtx4b7EoskHXmi2E9rp5CHLcZ
将下载的u2net.pth 保存到根目录自创的.u2net文件夹下
运行 rembg p path/to/input path/to/output
命令即可
如报错no module named ‘torch._c’ 则安装conda install pytorch即可