Remove.bg api automatically remove the background instance

Get the API address   just  register

Code

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)

Insert picture description here

Original image

Insert picture description here

Picture after removing the background

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_43657442/article/details/109037184