Step By Step
1、 开通分割抠图服务,具体可参考链接
2、获取您的真实AK信息,具体可参考链接
3、添加依赖
pip install aliyun-python-sdk-imageseg==1.1.8
4、Python Code Sample
#coding=utf-8
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.request import CommonRequest
from aliyunsdkcore.auth.credentials import AccessKeyCredential
from aliyunsdkcore.auth.credentials import StsTokenCredential
credentials = AccessKeyCredential('<your-access-key-id>', '<your-access-key-secret>')
# use STS Token
# credentials = StsTokenCredential('<your-access-key-id>', '<your-access-key-secret>', '<your-sts-token>')
client = AcsClient(region_id='cn-shanghai', credential=credentials)
request = CommonRequest()
request.set_accept_format('json')
request.set_domain('imageseg.cn-shanghai.aliyuncs.com')
request.set_method('POST')
request.set_protocol_type('https') # https | http
request.set_version('2019-12-30')
request.set_action_name('SegmentCommodity')
request.add_query_param('ImageURL', "图片地址url")
response = client.do_action(request)
# python2: print(response)
print(str(response, encoding = 'utf-8'))