基于PYTHON调用阿里云分割抠图-商品分割接口

Step By Step

1、 开通分割抠图服务,具体可参考链接

基于PYTHON调用阿里云分割抠图-商品分割接口

2、获取您的真实AK信息,具体可参考链接

基于PYTHON调用阿里云分割抠图-商品分割接口

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'))

5、运行结果

基于PYTHON调用阿里云分割抠图-商品分割接口

参考链接

商品分割

上一篇:基于Base64转码实现阿里云金融级人脸检测服务端接入教程Java code Sample


下一篇:服务网关GateWay的错误解决方法