I'm following the official MS Azure quickstart guide (https://learn.microsoft.com/en-gb/azure/cognitive-services/face/quickstarts/client-libraries?tabs=visual-studio&pivots=programming-language-rest-api), specifically the "Get face attributes" part and when replicating provided cURL examples in Postman, I'm getting the following error:

{
    "error": {
        "code": "BadArgument",
        "message": "Attribute 'qualityForRecognition' is only supported for recognition_03 and recognition_04."
    }
}

Any ideas? It seems like they've updated their API without updating documentation, which is something I wouldn've expected from a corp like Microsoft, but it's the only thing I can think of why it wouldn't be working. For reference, here's a screenshot of my Postman request. enter image description here

1

There are 1 answers

1
Ecstasy On BEST ANSWER

As per documentation:

To extract face attributes, call the Detect API again, but set detectionModel to detection_01. Add the returnFaceAttributes query parameter as well.

Detect with stream example:

POST {Endpoint}/face/v1.0/detect?overload=stream&returnFaceAttributes=age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise&recognitionModel=recognition_01&returnRecognitionModel=True&detectionModel=detection_01
Ocp-Apim-Subscription-Key: {API key}
  • returnFaceAttributes: Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender".

Note: detection_01 supports age, gender, headPose, smile, facialHair, glasses, emotion, hair, makeup, occlusion, accessories, blur, exposure, noise, and qualityForRecognition While detection_02 does not support any attributes and detection_03 only supports mask and qualityForRecognition. qualityForRecognition is only supported when the 'recognitionModel' is specified as 'recognition_03' or 'recognition_04'.

As per Add QualityForRecognition in Face how-to samples, detection_01 is used with recognition_04

var faces3 = await faceClient.Face.DetectWithUrlAsync(url: imageUrl, returnFaceId: true, returnFaceAttributes: requiredFaceAttributes, detectionModel: DetectionModel.Detection01, recognitionModel: RecognitionModel.Recognition04);

You can also refer to Add qualityForRecognition attribute to Face Detection