Closed pierre-jezegou closed 3 months ago
This is taken care of in the feature/error-states branch:
def detect_faces(object_name):
rekognition_client = boto3.client("rekognition")
try:
response = rekognition_client.detect_faces(
Image={
"S3Object": {
"Bucket": APP_BUCKET_NAME,
"Name": object_name,
}
},
Attributes=["ALL"]
)
except rekognition_client.exceptions.InvalidImageFormatException as e:
print(f"Invalid image format for {object_name}: {e}")
return None, "invalid-image-format"
except Exception as e:
print(f"Error detecting faces: {e}")
return None, f"error-detecting-faces: {e}"
return len(response["FaceDetails"]), None
Rekognition only supports
png
andjpg
file types https://docs.aws.amazon.com/rekognition/latest/dg/images-information.html So maybe we can restrict the user input