Search code examples
amazon-web-servicesreact-nativeaws-amplifyamazon-rekognition

How to get the full face recognition information from @aws-amplify/predictions?


I'm using face recognition from @aws-amplify/predictions in a React Native app. In Predictions.identify I'd like to get all the information back such as the attributes of a face detected. I'm getting landmarks, boundingbox (of a detected face) and metadata. As per the documentation for other examples this appears to be the default information, to get all of it back I have to pass in "format: [ALL]" or similar but I have not been able to find how this is structured for the entities detection that I'm using, only for text recognition etc.

entities: {
  source: {
    bytes
  },
  format: ["ALL"]
}

Does @aws-amplify/predictions give me all the information I want and if so, how do I make the request to get the full face recognition information back?

The documentation seems conflicting as in I'm asked to upload my image in an S3 bucket and analyse it from there. I'm using a local image that's being sent as an arraybuffer.

Documentation followed:

https://aws-amplify.github.io/docs/js/predictions https://docs.aws.amazon.com/rekognition/latest/dg/faces-detect-images.html https://docs.aws.amazon.com/rekognition/latest/dg/API_DetectFaces.html


Solution

  • This is understandable. The Amplify AmazonAIIdentifyPredictionsProvider simplifies the Rekognition DetectFaces() request. That means the provider does not allow a requester to pass in the parameter key 'format' with a value. Click on the AmazonAIIdentifyPredictionsProvider link to see the Amplify prediction javascript code. Just note how the request input param dictionary has just one key, 'Image.'

    const param = { Image: inputImage };
    

    To get unstuck, simply invoke the API in the react-native app with the aws-sdk 'aws-sdk/clients/rekognition' class in the react-native app. A requester can pass in the 'format' key with the aws-sdk client.

    Rekognition DetectFaces accepts one blob of bytes. DetectFaces also accepts one S3 object.