-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex_images.py
More file actions
32 lines (25 loc) · 763 Bytes
/
index_images.py
File metadata and controls
32 lines (25 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import boto3
s3 = boto3.resource('s3')
client = boto3.client('rekognition')
def list_images():
images = []
bucket = s3.Bucket('jhmede-fa-images')
for image in bucket.objects.all():
images.append(image.key)
return images
def index_images(images):
for image in images:
client.index_faces(
CollectionId='faces',
DetectionAttributes=[],
ExternalImageId=image[:-4],
Image={
'S3Object': {
'Bucket': 'jhmede-fa-images',
'Name': image
}
}
)
# client.create_collection(CollectionId='faces') -- Used to create a new collection on AWS Rekognition
result = list_images()
index_images(result)