python – Boto AWS Rekognition中的错误

我正在尝试使用AWS Rekognition through
Python boto3比较面孔,如AWS文档中所述.

我的API调用是:

client = boto3.client('rekognition', aws_access_key_id=key, aws_secret_access_key=secret, region_name=region )

source_bytes = open('source.jpg', 'rb')
target_bytes = open('target.jpg', 'rb')

response = client.compare_faces(
    SourceImage = {
        'Bytes':bytearray(source_bytes.read())
    },
    TargetImage = {
        'Bytes':bytearray(target_bytes.read())
    },
    SimilarityThreshold = SIMILARITY_THRESHOLD
)

source_image.close()
target_image.close()

但每次我运行这个程序,我都会收到以下错误:

botocore.errorfactory.InvalidParameterException: An error occurred (InvalidParameterException) when calling the CompareFaces operation: Request has Invalid Parameters

我已正确指定了密钥,密钥,区域和阈值.如何清除此错误并使请求调用工作?

最佳答案 你的代码非常好,

对于AWS Rekognition,图像维度非常重要.

亚马逊重新认知的限制

以下是Amazon Rekognition中的限制列表:

>存储为Amazon S3对象的最大图像大小限制为15 MB.
>高度和宽度的最小像素分辨率为80像素.作为参数传递给API的原始字节的最大图像大小为5 MB.
> Amazon Rekognition支持PNG和JPEG图像格式.也就是说,您作为输入提供给各种API操作的图像(例如DetectLabels和IndexFaces)必须采用其中一种受支持的格式.
>您可以在单个面部集合中存储的最大面数为100万.
搜索API返回的最大匹配面是4096.

来源:AWS Docs

点赞