Skip to content

AWS Rekognition: Image moderation detection API response getting empty

0

Hey,

I'm using Boto3 with Python to get image properties, detect face and get image moderation data. Issue is, getting response for image properties and faces but not getting moderation data for the same image. Also, it's working on local machine. It's not working when deployed to server. Sharing response and reference image. Enter image description here

On server, moderation API response is {'ModerationLabels': [], 'ModerationModelVersion': '7.0', 'ContentTypes': [], 'ResponseMetadata': {'RequestId': 'bb7bde7c-6052-42c7-ab8b-52a852c0ec65', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': 'bb7bde7c-6052-42c7-ab8b-52a852c0ec65', 'content-type': 'application/x-amz-json-1.1', 'content-length': '72', 'date': 'Mon, 19 May 2025 14:25:23 GMT'}, 'RetryAttempts': 0}}

On local, moderation API response is: {'ModerationLabels': [{'Confidence': 94.3687973022461, 'Name': 'Swimwear or Underwear', 'ParentName': '', 'TaxonomyLevel': 1}, {'Confidence': 94.3687973022461, 'Name': 'Female Swimwear or Underwear', 'ParentName': 'Swimwear or Underwear', 'TaxonomyLevel': 2}, {'Confidence': 91.51679992675781, 'Name': 'Non-Explicit Nudity of Intimate parts and Kissing', 'ParentName': '', 'TaxonomyLevel': 1}, {'Confidence': 91.51679992675781, 'Name': 'Non-Explicit Nudity', 'ParentName': 'Non-Explicit Nudity of Intimate parts and Kissing', 'TaxonomyLevel': 2}, {'Confidence': 91.51679992675781, 'Name': 'Partially Exposed Female Breast', 'ParentName': 'Non-Explicit Nudity', 'TaxonomyLevel': 3}], 'ModerationModelVersion': '7.0', 'ContentTypes': []}

Could you please tell what can be reason for this behaviour?

asked a year ago311 views

2 Answers
5

Below the suggested steps to locate the issue:

  1. Image File Integrity • Ensure the image file on the server is identical to the one used locally. • Sometimes, file encoding or transfer methods (e.g., via HTTP or FTP) can alter the image slightly.

  2. Image Format and Size • Rekognition supports JPEG and PNG formats. • Images must be less than 15MB (for base64-encoded) or 5MB (for S3 objects).

  3. Permissions and IAM Role • Ensure the server has the correct IAM role or credentials to access Rekognition. • The role must have rekognition:DetectModerationLabels permission.

  4. Image Source Method • Are you using S3 object or byte stream? • If using S3, ensure the object is publicly accessible or the IAM role has access.

  5. Environment Differences • Local machine might have different versions of boto3, botocore, or Python. • Server might have a proxy, firewall, or network restriction affecting the API call.

  6. Logging and Debugging

EXPERT

answered a year ago

0

Hey,

Hope you're keeping well.

If the same image returns moderation labels locally but not on the server, it usually means the image content being sent to Rekognition from the server is not identical to what you tested locally. Double-check that the server is reading the correct file and not compressing, resizing, or stripping metadata before calling detect_moderation_labels. Also verify your IAM role or credentials on the server have the rekognition:DetectModerationLabels permission and that the API call is going to the same AWS Region as your local test. You can log the base64 size or S3 object key right before the API call to confirm the input matches exactly.

Thanks and regards,
Taz

answered a year ago

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.