【发布时间】:2018-08-23 22:05:00
【问题描述】:
我正在使用 boto3 调用识别的检测标签方法,该方法将图像(以 base64 编码字节的形式)作为输入。但是我不断收到 InvalidImageFormatException ,我不明白为什么。我已阅读文档并查看了一些示例,但我真的无法弄清楚为什么会收到此错误。
以下是我的代码以及到目前为止我尝试过的内容
self.rekog_client = boto3.client('rekognition', 'us-east-1')
with open('abc100.jpg', "rb") as cf:
base64_image=base64.b64encode(cf.read()).decode("ascii")
#also tried this) ==> base64_image=base64.b64encode(cf.read())
resp = self.rekog_client.detect_labels(Image={'Bytes': base64_image})
输出/异常:
botocore.errorfactory.InvalidImageFormatException: An error occurred(InvalidImageFormatException) when calling the DetectLabels operation: Invalid image encoding
【问题讨论】:
标签: python boto3 amazon-rekognition