How to add an item in a collection in amazon s3?
Question:
I have this code for create a data collection:
import boto3
def createCollection():
cliente = boto3.client('rekognition')
respuesta = cliente.create_collection (CollectionId = 'Fotos')
print (respuesta)
createCollection()
But my question is how to add an item in this collection.
Could you please help me.
thanks.
Answers:
Assuming you’re trying to add an image to the collection from your local filesystem, you can do so with the index_faces()
method:
with open('image.png', 'rb') as image:
respuesta = cliente.index_faces(Image={'Bytes': image.read()}, CollectionId='Fotos')
print respuesta
I have this code for create a data collection:
import boto3
def createCollection():
cliente = boto3.client('rekognition')
respuesta = cliente.create_collection (CollectionId = 'Fotos')
print (respuesta)
createCollection()
But my question is how to add an item in this collection.
Could you please help me.
thanks.
Assuming you’re trying to add an image to the collection from your local filesystem, you can do so with the index_faces()
method:
with open('image.png', 'rb') as image:
respuesta = cliente.index_faces(Image={'Bytes': image.read()}, CollectionId='Fotos')
print respuesta