视觉智能平台AttributeError: ‘AttributeError’ object has no attribute ‘message’
按照示例代码写的,一直报这个错,可能是什么原因呀?
代码:
recogcolor_client = imagerecog20190930Client(open_api_models.Config(access_key_id=access_key_id,
access_key_secret=access_key_secret,
endpoint=’imagerecog.cn-shanghai.aliyuncs.com’))
def call_recogscene(img_url):
recogcolor_request = imagerecog_20190930_models.RecognizeImageColorRequest(url=img_url)
runtime = util_models.RuntimeOptions()
try:
ret = recogcolor_client.recognize_image_color_with_options(recogcolor_request, runtime)
return [(i.color, i.percentage, i.label) for i in ret.body.data.colortemplatelist]
except Exception as error:
print(img_url, UtilClient.assert_as_string(error.message))
return img_url
改过error这部分可以跑通,但是,会报’RecognizeImageColorResponseBodyData’ object has no attribute ‘colortemplatelist’ 的错误,我查了文档,返回值应该是有这项的呀
message对象没属性,你直接使用我们给的示例代码调用看下呢?
https://help.aliyun.com/zh/viapi/use-cases/color-identification?spm=a2c4g.11186623.0.i24
print(response.body.data.color_template_list)
此回答整理自钉群“阿里云视觉智能开放平台咨询1群”