社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

如何使用remove.bg在Python中删除照片的背景

shy zhan • 6 年前 • 2316 次点击  

我想用 https://www.remove.bg 删除我照片的背景。 这是我的代码:

import requests            
response = requests.post(
    'https://api.remove.bg/v1.0/removebg',
    files={'image_file': open('U:/Training/python/remove-bg-master/child.jpg', 'rb')},   
    data={'size': 'auto'},
    headers={'X-Api-Key': 'API key'}   
)
if response.status_code == requests.codes.ok:
    with open('child-no-bg.png', 'U:\Training\python\remove-bg-master') as out:           
        out.write(response.content)
else:
    print("Error:", response.status_code, response.text)

但我犯了个错误:

SSLError: HTTPSConnectionPool(host='api.remove.bg', port=443): Max retries exceeded with url: /v1.0/removebg (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')])")))

你能告诉我这里发生了什么事吗?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/49793
文章 [ 2 ]  |  最新文章 6 年前