[PYTHON] How to make AWS rekognition recognize local image files

TL;DR

Put the binary data in the value of the key 'Bytes' and pass it to Image

import boto3

client = boto3.client('rekognition')

with open('image.jpg', 'rb') as f:
    response = client.search_faces_by_image(
        CollectionId='string',
        Image={
            'Bytes': f.read()
        }
    )

Other cases

In the sample of the world, there were overwhelmingly many cases of passing the image file stored in s3. When passing from s3, it can be analyzed by passing the bucket name and Object name.

response = client.search_faces_by_image(
    CollectionId='string',
    Image={
        'S3Object': {
            'Bucket': 'string',
            'Name': 'string',
            'Version': 'string'
        }
    },
)

Recommended Posts

How to make AWS rekognition recognize local image files
How to make a Japanese-English translation
How to make AWS Lambda Layers when running selenium × chrome on AWS Lambda
How to make a slack bot
How to make a crawler --Advanced
How to make a recursive function
How to make a deadman's switch
[Blender] How to make a Blender plugin
[Blender] How to make Blender scripts multilingual
How to write Docker base image
How to add AWS EBS volume
How to make a crawler --Basic
Tweet in Chama Slack Bot ~ How to make a Slack Bot using AWS Lambda ~
[AWS] How to deal with WordPress "An error occurred when cropping an image."
How to make Word Cloud characters monochromatic
How to make Selenium as light as possible
[Linux] How to subdivide files and folders
[Python] How to make a class iterable
How to create * .spec files for pyinstaller.
Automatically update CSV files to AWS DynamoDB
[Cocos2d-x] How to make Script Binding (Part 2)
How to adjust image contrast in Python
How to make multi-boot USB (Windows 10 compatible)
How to make a Backtrader custom indicator
How to make a Pelican site map
[Cocos2d-x] How to make Script Binding (Part 1)
How to find large files on Linux
How to read CSV files in Pandas
Summary of how to write AWS Lambda
How to automatically upload .gpx files to Strava
How to make a dialogue system dedicated to beginners
How to make an embedded Linux device driver (11)
How to create large files at high speed
How to make WTForms TextArea correspond to file drop
How to code a drone using image recognition
How to make an embedded Linux device driver (8)
How to make Spigot plugin (for Java beginners)
How to make an embedded Linux device driver (1)
[2020 version] How to install Python3 on AWS EC2
How to make an embedded Linux device driver (4)
Summary of how to import files in Python 3
How to make multiple kernels selectable on Jupyter
How to use Python Image Library in python3 series
How to make a dictionary with a hierarchical structure.
How to make an embedded Linux device driver (7)
How to make an embedded Linux device driver (2)
How to crop an image with Python + OpenCV
How to make scrapy JSON output into Japanese
How to make an embedded Linux device driver (3)
How to make a QGIS plugin (package generation)
How to check / extract files in RPM package
How to get the files in the [Python] folder
I read "How to make a hacking lab"
[Blender x Python] How to make an animation
How to make an embedded Linux device driver (6)
[AWS / Lambda] How to load Python external library
How to set up a local development server
How to make Substance Painter Python plugin (Introduction)
How to use PyTorch-based image processing library "Kornia"
[Blender x Python] How to make vertex animation
How to make an embedded Linux device driver (5)