- Newest
- Most votes
- Most comments
Yes, it is possible to move a user and their associated face IDs from one collection to another in Amazon Rekognition. Here are the steps to do it:
-
Retrieve the user and face IDs from the current collection:
- Use the
ListFacesoperation to retrieve the list of faces associated with the user you want to move. - Note down the
UserIdandFaceIdfor each face belonging to that user.
- Use the
-
Delete the user and faces from the current collection:
- Use the
DeleteUseroperation to delete the user from the current collection. - Use the
DeleteFacesoperation to delete the faces associated with the user from the current collection.
- Use the
-
Add the user and faces to the new collection:
- Use the
CreateUseroperation to create the user in the new collection. - Use the
AddFacesoperation to add the faces associated with the user to the new collection.
- Use the
Here's some sample code in Python to demonstrate the process:
import boto3 # Create Rekognition client rekognition = boto3.client('rekognition') # Current collection current_collection_id = 'current-collection' # New collection new_collection_id = 'new-collection' # User to move user_id = 'user-to-move' # Step 1: Retrieve the user and face IDs from the current collection response = rekognition.list_faces(CollectionId=current_collection_id, UserIDs=[user_id]) faces = response['Faces'] face_ids = [face['FaceId'] for face in faces] # Step 2: Delete the user and faces from the current collection rekognition.delete_user(CollectionId=current_collection_id, UserId=user_id) rekognition.delete_faces(CollectionId=current_collection_id, FaceIds=face_ids) # Step 3: Add the user and faces to the new collection rekognition.create_user(CollectionId=new_collection_id, UserId=user_id) for face_id in face_ids: rekognition.add_faces_to_collection(CollectionId=new_collection_id, UserId=user_id, ExternalImageId='face-image', FaceId=face_id)
This code retrieves the user and face IDs from the current collection, deletes the user and faces from the current collection, and then creates the user and adds the faces to the new collection.
Make sure to replace the current_collection_id, new_collection_id, and user_id with the appropriate values for your use case.
By following this process, you can move a user and their associated face IDs from one collection to another in Amazon Rekognition.
Relevant content
asked a year ago
asked 2 years ago
asked 5 years ago
- AWS OFFICIALUpdated 3 months ago

in
boto3.client('rekognition'), there is noadd_faces_to_collectionfunction.