一个删除图像背景的工具Rembg

非常简洁干净的一个背景移除工具 , 可以命令行方式运行、也可以web方式运行 , 也可以Python代码方式运行 , 安装运行都非常简单 。原理是基于图像分割和Matting算法 , 支持u2net的一些列模型 。
开源:https://github.com/danielgatis/rembg

  • 安装
# CPU版本pip install rembg # 如果有GPU , 也可以安装GPU版pip install rembg[gpu]
  • 运行
# 命令行方式rembg i path/to/input.png path/to/output.png# web方式rembg s# python代码
  • Python代码例子
from rembg import removeinput_path = 'input.png'output_path = 'output.png'with open(input_path, 'rb') as i:with open(output_path, 'wb') as o:input = i.read()output = remove(input)o.write(output)
一个删除图像背景的工具Rembg

文章插图
 

【一个删除图像背景的工具Rembg】


    推荐阅读