in dags/processing/processing.py [0:0]
def label_images(**kwargs):
"""
Sends images to Rekognition for labeling
:param kwargs:
:return:
"""
import boto3
# list PNG files in S3
prefix = kwargs['ti'].xcom_pull(task_ids=f"bag_file_sensor", key=f"filename_s3_key")[:-4] + "/"
bucket = kwargs['bucket_dest']
table = kwargs['table_dest']
iterator = list_objects(bucket, prefix)
# send to Rekognition for labeling
rek_client = boto3.client("rekognition")
for page in iterator:
for object in page["Contents"]:
key = object["Key"]
if key.endswith(".png"):
response = rek_client.detect_labels(Image={"S3Object": {"Bucket": bucket, "Name": key}})
process_labels(response["Labels"], bucket, key, table)