阿里云安全内容安全图片检查的python例子,这行报异常,'tuple' object has no attribute 'encode'什么原因啊?
看下传参呢from alibabacloud_green20220302.client import Client
from alibabacloud_green20220302 import models
from alibabacloud_tea_openapi.models import Config
import json
import uuid
config = Config(
access_key_id=you_accessKeyId,
access_key_secret=you_accessSecret,
# 连接时超时时间,单位毫秒(ms)。
connect_timeout=3000,
# 读取时超时时间,单位毫秒(ms)。
read_timeout=6000,
region_id='cn-shenzhen',
endpoint='green-cip.cn-shenzhen.aliyuncs.com'
)
clt = Client(config)
serviceParameters = {
'imageUrl': 'https://img.alicdn.com/tfs/TB1Mq6ZmCslXu8jSZFuXXXg7FXa-1440-568.jpg',
'dataId': str(uuid.uuid4())
}
ImageModerationRequest = models.ImageModerationRequest(
# 检测类型: baselineCheck 通⽤基线检测
service='baselineCheck',
service_parameters=json.dumps(serviceParameters)
)
try:
response = clt.image_moderation(ImageModerationRequest)
if response.status_code == 200:
body = response.body
# print(body)
print('requestId:{}'.format(body.request_id))
print('code:{}'.format(body.code))
print('msg:{}'.format(body.msg))
if body.code == 200:
data = body.data
print('dataId:{}'.format(data.data_id))
result = data.result
for ret in result:
print('label:{}'.format(ret.label))
print('confidence:{}'.format(ret.confidence))
else:
print('response not success. code:{},msg:{}'.format(body.code, body.msg))
else:
print('response not success. status:{},result:{}'.format(response.status_code, response))
except Exception as err:
print(err) ,此回答整理自钉群“阿里云内容安全技术答疑群”
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。