in usecases/image-processing/dags/1.10/image_processing.py [0:0]
def face_detection(ds, **kwargs):
client = boto3.client('rekognition')
arg = kwargs['dag_run'].conf
print(arg)
print(kwargs['dag_run'])
try:
response = client.detect_faces(
Image={
'S3Object': {
'Bucket': arg['s3Bucket'],
'Name': arg['s3Key'],
}
},
Attributes=['ALL']
)
print(response)
if len(response['FaceDetails']) != 1:
return "photo_not_meet_requirement"
if response['FaceDetails'][0]['Sunglasses']['Value']:
return "photo_not_meet_requirement"
kwargs['ti'].xcom_push(key="FaceDetails", value=response['FaceDetails'][0])
return "check_duplicate"
except Exception as e:
print(e)
return "failure"