错误:根:预测失败:未知错误

时间:2020-04-13 13:05:39

标签: python tensorflow

我正在请求针对经过训练的模型(内置的图像分类算法)进行在线预测,并获取“ ERROR:root:Prediction failed:'str'对象没有属性'iteritems'”

这是我在Google AI平台上的第一个ML模型。模型训练成功,训练数据,验证数据和测试数据在输出文件夹中看起来都不错。但是,当我尝试通过传递输入JSON来测试模型时,出现此错误。

请找到正在创建JSON的代码

导入json 导入base64

IMAGE_URI='C://Yellow_Daisy.jpg'
with open(IMAGE_URI, "rb") as img_file:
    encoded_string = base64.b64encode(img_file.read()).decode('utf-8')
    image_bytes = {'b64': str(encoded_string)}
    instances = {'instances': image_bytes, 'key': '1'}
with open("C://prediction_instances.json","w") as f:
    f.write(json.dumps(instances))

0 个答案:

没有答案