- Newest
- Most votes
- Most comments
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:
-
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. -
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
Relevant content
- asked 5 months ago
- asked 9 months ago
- AWS OFFICIALUpdated 5 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