in usecases/image-processing/dags/1.10/image_processing.py [0:0]
def check_duplicate(ds, **kwargs):
client = boto3.client('rekognition')
arg = kwargs['dag_run'].conf
try:
response = client.search_faces_by_image(
CollectionId=arg['RekognitionCollectionId'],
Image={
"S3Object": {
"Bucket": arg['s3Bucket'],
"Name": arg['s3Key']
}
},
FaceMatchThreshold=70.0,
MaxFaces=3
)
print(response)
if len(response['FaceMatches']) > 0: #Face already exist
return "duplicate_face"
return "parallel_processing"
# kwargs['ti'].xcom_push(key="FaceDetails", value=response.FaceDetails[0])
except Exception as e:
print(e)
return "failure"