Rekognition.detectLabels.withMaxLabels error

0

Hello,

I invoked AWS SDK method Rekognition.detectLabels.withMaxLabels(10).withMinConfidence(75F), MaxLabels option that have apidocs:

The service returns the specified number of highest confidence labels.

The service returned 10 labels where the the Confidence of the 10-th was: 80,1.

While invoking the same service, with same picture, from the Management Console Demo (Rekognition->Demos->Label detection), I received a Response with 24 labels, where 10-th has Confidence: 98,01.

The version of the responses are the same : "LabelModelVersion": "3.0", but there are some wording differences: SDK JSON: "name": "Buildings and Architecture", while Console JSON: "Name": "Buildings and Architecture"

So, the AWS SDK of Rekognition did not returned all the first 10 HIGHEST confidence labels. Is this test ok, or how should I make the SDK call to get the highest 10 confidence labels?

Thank you,
Mihai

1 Answer
0

Hello Mihai,

The behavior you're experiencing with the AWS SDK for Amazon Rekognition is expected, and I'll explain why you're seeing a difference in the results between the SDK and the Management Console Demo.

When using the withMaxLabels and withMinConfidence parameters in the AWS SDK for Amazon Rekognition, it does not guarantee that you will receive exactly the specified number of labels (in your case, 10) with the highest confidence. Instead, it limits the number of labels returned that meet the specified minimum confidence threshold.

Here's how it works:

  1. withMaxLabels: This parameter limits the maximum number of labels that can be returned, but it doesn't guarantee that you will receive the exact number of labels you specify. If there are more labels that meet the confidence threshold, you will receive as many as are available up to the specified limit.

  2. withMinConfidence: This parameter sets the minimum confidence level that a label must have to be included in the response. Labels with confidence levels below this threshold are excluded.

In the Management Console Demo, the tool may be configured to show more labels with higher confidence by default for a better user experience.

If you want to receive more labels with higher confidence, you can increase the withMinConfidence threshold, which will result in fewer labels being returned, but those returned will have higher confidence scores. You can also set withMaxLabels to a larger number if you want to receive more labels in total.

For example:

DetectLabelsRequest request = new DetectLabelsRequest()
    .withImage(new Image().withS3Object(new S3Object().withName("your-image-key").withBucket("your-bucket")))
    .withMaxLabels(20) // Increase the maximum number of labels
    .withMinConfidence(90F); // Increase the minimum confidence threshold

Remember that the specific labels returned can depend on the content of the image and the model used by Amazon Rekognition at the time of analysis, which may evolve over time.

Please give a thumbs up if my suggestion help

profile picture
answered 8 months ago
  • Hello,

    Regarding: "Instead, it limits the number of labels returned that meet the specified minimum confidence threshold.", the details that I presented shows that all the test happened at a Confidence over 80 (the returned Labels are ordered by Confidence and 10-ths were as described, over 80), so the WithMinConfidence parameter was not considered, it did not influenced the Responses.

    So, the questions remains.

    Thank you,
    Mihai

  • Hello,

    I made Rekognition SDK invocation with no parameters (Rekognition.detectLabels.withImage()), and the results were the same with those from Console Demo. It seams that the service has some issues when invoked with parameters (Rekognition.detectLabels.withImage().withMaxLabels(10).withMinConfidence(75F)): it does not return the first 10 HIGHEST confidence labels.

    Have a good day,
    Mihai

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions