rembg AI扣图
一、安装
pip install "rembg[cpu,cli] -i https://pypi.tuna.tsinghua.edu.cn/simple
二、准备图片
编写代码:main3.py
from rembg import remove
input_path = 'animal1.jpg'
output_path = 'animal2.jpg'
with open(input_path, 'rb') as i:
with open(output_path, 'wb') as o:
input = i.read()
output = remove(input)
o.write(output)
运行结果: