Remove.bg api 自动去背景 实例
获取API地址 注册一下就可以了
代码
import requests
response = requests.post(
'https://api.remove.bg/v1.0/removebg',
files={'image_file': open('D:\\11.jpg', 'rb')},
data={'size': 'auto'},
headers={'X-Api-Key': 'INSERT_YOUR_API_KEY_HERE'},
)
if response.status_code == requests.codes.ok:
with open('no-bg.png', 'wb') as out:
out.write(response.content)
else:
print("Error:", response.status_code, response.text)