Describing and Moderating Images with Amazon Rekognition and Amazon Bedrock
Build an image pipeline with Amazon Rekognition and Amazon Bedrock. Moderate uploads, apply a block, review or allow policy, tag images with labels and text, generate alt text with a vision model, and handle privacy and bias responsibly.
Series: Amazon Bedrock (18 articles)
- …
- 18Describing and Moderating Images with Amazon Rekognition and Amazon Bedrock This article
Use Rekognition for fast, structured checks on every image, and a Bedrock vision model for the descriptions only a language model can write. Here's a pipeline that does both, with a human in the loop for the grey areas.
If your app accepts images, such as product photos, user uploads or scanned receipts, you quickly run into two needs. First, you want to know whether an image is safe to accept at all. Second, you often want to know what's in it, whether to create a caption, add alt text for accessibility or make it searchable.
Two AWS services suit those jobs differently. Amazon Rekognition is a computer vision service: quick, consistent and cheap, returning structured labels and confidence scores. A multimodal model on Amazon Bedrock can look at an image and write a natural description or answer a question about it, but it's slower, costs more per image and can be less predictable.
In this article we'll combine them. Rekognition screens and tags every image, and Bedrock writes descriptions for the images that pass.
First, a status check
AWS has been moving several services and features into maintenance mode this year. For Rekognition, AWS's service availability notice lists the Streaming Events and Batch Image Content Moderation features. Third-party coverage says they entered maintenance mode on 30 April 2026, while the core APIs, including
DetectLabels , DetectText , DetectFaces and DetectModerationLabels , remain active and supported. I confirmed the feature names on AWS's own page, but not the dates or the "core APIs unaffected" detail, so check AWS's availability page before you build.That matters here because this article uses the per-image moderation call, which is the core API, and not the batch moderation feature. If you were planning to use batch moderation, process images one at a time with a trigger, as we did in the EventBridge article, instead.
Who does what
| Amazon Rekognition | A Bedrock vision model |
|---|---|---|
Strength | Consistent labels, moderation categories and detected text with confidence scores | Natural-language descriptions, reasoning about a scene, answering questions about an image |
Output | Structured data | Free text |
Speed and cost per image | Fast and low | Slower and higher |
Predictability | High | Lower |
Best used for | Screening and tagging every image | Describing, summarising or interpreting selected images |
A good rule: use Rekognition to filter and tag at volume, and a language model for the work that needs language.
The pipeline
- Upload the image to S3.
- Moderate it with Rekognition. If it's clearly unsafe, stop.
- Tag it with labels and detected text.
- Decide: allow, block or send to a person.
- Describe the allowed images with a Bedrock vision model.
- Store the results with the image.
What you need
- The setup from the earlier articles: Python, boto3 and an S3 bucket in your chosen Region
- Test images you're allowed to use. Include ordinary photos, and avoid uploading anything harmful just to test. Rekognition's documentation and sample sets cover testing without that.
- Access to a Bedrock model that accepts images, with its ID from the model's documentation
- About an hour
Image handling raises privacy questions. Read the privacy section before you use real user photos.
Step 1: Check images for unsafe content
The
DetectModerationLabels operation looks for unsafe or inappropriate content in an image. AWS's documentation says it works on JPEG and PNG images. You can pass the image from S3 or as bytes, and set a minimum confidence so that low-confidence labels aren't returned.import boto3
REGION = "us-east-1"BUCKET = "my-ai-project-dev"
rekognition = boto3.client("rekognition", region_name=REGION)
def moderate(key, min_confidence=70): response = rekognition.detect_moderation_labels( Image={"S3Object": {"Bucket": BUCKET, "Name": key}}, MinConfidence=min_confidence, ) return [ { "name": label["Name"], "parent": label.get("ParentName", ""), "confidence": round(label["Confidence"], 1), } for label in response["ModerationLabels"] ]
print(moderate("raw/images/photo-001.jpg"))The result is a list of labels, each with a name, a confidence score and a parent. The labels form a hierarchy, with broad top-level categories and more specific labels beneath them. For example, a specific label might sit beneath a general category. The taxonomy has been updated over time, so read the current Rekognition documentation for the names and structure, and don't copy category names from an old blog post.
A few points:
- No labels means nothing was found above your threshold, not that the image is guaranteed safe.
- The confidence threshold is a trade-off. A low value catches more but flags more harmless images. A high value flags fewer but may miss some.
- Different products need different rules. A children's app, a general marketplace and a medical imaging tool have very different ideas of what's acceptable.
Step 2: Turn the labels into a decision
Don't hard-code decisions deep in your logic. Put your policy in one place, mapping each top-level category to an action:
# Your policy. Replace the names with those from the current Rekognition taxonomy.POLICY = { "Explicit": "block", "Violence": "block", "Visually Disturbing": "review", "Alcohol": "review",}DEFAULT_ACTION = "allow"
ORDER = {"allow": 0, "review": 1, "block": 2}
def decide(flags): decision = "allow" for flag in flags: category = flag["parent"] or flag["name"] # use the top-level category action = POLICY.get(category, DEFAULT_ACTION) if ORDER[action] > ORDER[decision]: decision = action return decisionThe three outcomes matter:
- Block: clearly against your rules. Reject it automatically.
- Review: uncertain or context-dependent. Send it to a person.
- Allow: continue the pipeline.
The middle category is the most important one. Automated moderation makes mistakes in both directions: it flags harmless images, such as medical, artistic or news content, and misses some that should be caught. A human review queue is how you handle the uncertain cases fairly.
Step 3: Add labels and text
For the images that pass, Rekognition can also tell you what's in them.
def tag(key, max_labels=10, min_confidence=80): response = rekognition.detect_labels( Image={"S3Object": {"Bucket": BUCKET, "Name": key}}, MaxLabels=max_labels, MinConfidence=min_confidence, ) return [(label["Name"], round(label["Confidence"], 1)) for label in response["Labels"]]
def read_text(key): response = rekognition.detect_text( Image={"S3Object": {"Bucket": BUCKET, "Name": key}} ) return [ item["DetectedText"] for item in response["TextDetections"] if item["Type"] == "LINE" ]Labels such as "Chair", "Table" and "Indoors" are great for search and filtering. Detected text helps with signs, labels and screenshots. Both come with confidence scores, so keep them and use them.
Step 4: Describe the image with Bedrock
Now the part that Rekognition can't do well: writing a natural description. Bedrock's Converse API accepts images as part of a message when the model supports them.
s3 = boto3.client("s3", region_name=REGION)bedrock = boto3.client("bedrock-runtime", region_name=REGION)MODEL_ID = "YOUR_VISION_MODEL_ID" # a model that accepts images
def describe(key, labels=None): image_bytes = s3.get_object(Bucket=BUCKET, Key=key)["Body"].read() image_format = key.rsplit(".", 1)[-1].lower().replace("jpg", "jpeg")
hint = "" if labels: hint = "Detected objects: " + ", ".join(name for name, _ in labels) + "\n\n"
response = bedrock.converse( modelId=MODEL_ID, messages=[{ "role": "user", "content": [ {"image": {"format": image_format, "source": {"bytes": image_bytes}}}, {"text": hint + "Write alt text for this image in one or two sentences, " "describing only what is visible. Do not guess names or identities."}, ], }], inferenceConfig={"maxTokens": 150, "temperature": 0.2}, ) return response["output"]["message"]["content"][0]["text"].strip()Things to notice:
- The image goes in as bytes inside the message. Check the model's documentation for supported formats, size limits and how many images you can include.
- Passing Rekognition's labels as a hint can anchor the description and reduce guessing.
- The instruction says what not to do: "describing only what is visible" and "do not guess names or identities." Vision models can speculate, and for people in photos you generally don't want that.
- The output is short and capped, which keeps cost down and makes alt text readable.
Putting it together
def process(key): flags = moderate(key) decision = decide(flags) if decision != "allow": return {"key": key, "decision": decision, "flags": flags}
labels = tag(key) return { "key": key, "decision": "allow", "labels": labels, "text": read_text(key), "description": describe(key, labels), }
print(process("raw/images/photo-001.jpg"))Store each result, with the confidence scores and the decision, in a table such as DynamoDB, linked to the image's S3 key. Keep a record of why each image was blocked or sent for review, so you can explain the decision later.
To run it automatically when an image is uploaded, trigger it with EventBridge and a Lambda function or Step Functions workflow, as in the earlier article.
Test it properly
Use the evaluation habits from earlier articles.
- Collect 50 or more varied images that represent your real uploads, including awkward cases: dark or blurry photos, unusual angles, text-heavy images and borderline content such as swimwear or medical images.
- Decide the right outcome for each before you run anything.
- Run the pipeline and compare. Count three things: harmless images that were wrongly blocked, images that should have been caught but weren't, and how many went to review.
- Check the descriptions for accuracy, invented details and bias.
- Tune your thresholds and policy, then retest.
The number that matters most is images that should have been blocked but passed. The harm from those is usually greater than from over-blocking, though your own situation decides how to balance the two.
Responsible use, privacy and limits
Images often contain people, and that calls for care.
- Faces and people. Rekognition can analyse faces, and that capability needs particular caution. Face analysis and identification are sensitive and regulated in many places. For this pipeline, don't identify people, and tell the description model not to guess identities.
- Consent and data protection. Know what rules apply to photos of people and to storing them. Tell users how images are processed.
- Bias and errors. Vision systems can perform unevenly across skin tones, cultures and contexts. Test with a diverse set of images, and don't treat the output as fact.
- Moderation is imperfect. Expect false positives and false negatives. Keep a human review path and an appeal route for users.
- Sensitive content in storage. Lock down the bucket, encrypt it and set retention. Be careful about who can view flagged images, and consider the wellbeing of the reviewers who must look at them.
- Illegal content. If your service could receive illegal material, you may have legal duties to report it. Get proper advice, and don't build handling for that kind of content yourself without it.
- Descriptions can be wrong. A model may state something confidently that isn't in the image. Don't use generated alt text for anything critical without checking.
- Accessibility. Good alt text helps people who use screen readers, but it should be accurate and useful, not just present.
What it costs
Rekognition charges per image analysed, with different prices for different operations, so a pipeline that runs moderation, labels and text on every image pays for three calls. The Bedrock step charges per token, including a token cost for the image itself. Run your test set, count the cost per image, and multiply by your monthly volume. Check the current pricing for both, and consider describing only the images that need it.
Common mistakes
- Treating "no labels" as "safe."
- Using old category names from out-of-date guides.
- No human review path.
- Trusting generated descriptions without checking.
- Letting the model guess identities.
- Describing every image when a cheaper label would do.
- Keeping flagged images in an open bucket.
- Never testing diverse or borderline images.
A checklist
- Have you confirmed Rekognition's current status and the APIs you use on AWS's pages?
- Is your moderation policy written down, with block, review and allow outcomes?
- Are the category names taken from the current taxonomy?
- Do borderline images go to a person?
- Do your prompts forbid guessing identities and invented details?
- Have you tested diverse images, and measured wrongly blocked and wrongly passed ones?
- Is storage locked down, with retention set?
- Have you thought about privacy, consent and reviewer wellbeing?
Where we go next
Next, we'll look at running an AI service on Amazon ECS with AWS Fargate.
Rekognition's APIs, moderation taxonomy, supported formats, limits and pricing change often, and AWS has changed the status of some Rekognition features this year. Check the current Amazon Rekognition and Bedrock documentation before you follow any step here, and test everything in a non-production account first.
Series: Amazon Bedrock (18 articles)
- …
- 18Describing and Moderating Images with Amazon Rekognition and Amazon Bedrock This article
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article