参考材料: https://pypi.org/project/rembg/
from rembg import remove
from PIL import Image
input_path = 'input.jpg'
output_path = 'output.png'
in_image = Image.open(input_path)
no_bg_image = remove(in_image) #删除背景
x, y = no_bg_image.size
new_image = Image.new('RGBA', no_bg_image.size, color='blue')
new_image.paste(no_bg_image, (0, 0, x, y), no_bg_image)
new_image.save(output_path)