Hands-On Lab925 words

Hands-On Lab: Exploring Specialized AWS AI Services

Specialized AI Services

Hands-On Lab: Exploring Specialized AWS AI Services

Welcome to this guided hands-On lab! In this 30-minute session, you will learn how to interact with AWS's Specialized AI Services. These pre-trained models allow developers to seamlessly integrate powerful artificial intelligence capabilities into their applications without needing deep machine learning expertise.

We will focus on two core services from the AWS AI stack:

  1. Amazon Comprehend for Natural Language Processing (NLP) and sentiment analysis.
  2. Amazon Rekognition for Computer Vision and object detection.

Prerequisites

Before you begin, ensure you have the following requirements met:

  • Cloud Account: An active AWS Account.
  • IAM Permissions: An IAM User or Role with the following policies attached:
    • ComprehendFullAccess
    • AmazonRekognitionFullAccess
    • AmazonS3FullAccess
  • Tools: AWS CLI installed and configured locally (aws configure) with your access keys.
  • Sample Data: A local image file named sample.jpg (e.g., a picture of a car, a city, or an animal) saved in your current working directory.

[!NOTE] Estimated Time: 30 minutes Difficulty: Guided


Learning Objectives

By completing this lab, you will be able to:

  1. Extract sentiment and meaning from unstructured text using Amazon Comprehend.
  2. Provision an Amazon S3 bucket to temporarily store image assets for computer vision tasks.
  3. Identify objects, scenes, and concepts within an image using Amazon Rekognition.
  4. Interpret the JSON bounding box coordinate system returned by computer vision APIs.

Architecture Overview

The following diagram illustrates the data flow for this lab. We will send text directly to Amazon Comprehend and route image data through Amazon S3 to be analyzed by Amazon Rekognition.

Loading Diagram...

Step-by-Step Instructions

Step 1: Text Analysis with Amazon Comprehend

Amazon Comprehend is a fully managed NLP service that uncovers insights and relationships in text. We will use it to determine the emotional tone (sentiment) of a customer review.

bash
aws comprehend detect-sentiment \ --text "I absolutely love the new AWS AI services! They make my job so much easier, though the setup was a bit confusing at first." \ --language-code en

[!TIP] You can change the --text payload to any string you like. Try a purely negative or neutral sentence to see how the confidence scores adjust.

Console alternative
  1. Navigate to Amazon Comprehend in the AWS Management Console.
  2. In the left sidebar, click Real-time analysis.
  3. Scroll down to the Input text box and paste your sentence.
  4. Click the Analyze button.
  5. Scroll down to the Insights section and click the Sentiment tab to view the results.

📸 Screenshot: The Comprehend console showing the Sentiment tab with "POSITIVE" highlighted.

Step 2: Prepare S3 for Rekognition

Amazon Rekognition can analyze images stored directly in Amazon S3. We need to create a unique bucket and upload our sample.jpg file.

bash
# Create a globally unique bucket (replace <YOUR_ACCOUNT_ID> and <YOUR_REGION>) aws s3 mb s3://brainybee-lab-rekognition-<YOUR_ACCOUNT_ID> --region <YOUR_REGION> # Upload your local image to the new bucket aws s3 cp sample.jpg s3://brainybee-lab-rekognition-<YOUR_ACCOUNT_ID>/sample.jpg
Console alternative
  1. Navigate to Amazon S3 in the AWS Console.
  2. Click Create bucket.
  3. Enter a globally unique name like brainybee-lab-rekognition-12345 and select your region.
  4. Leave all other defaults and click Create bucket.
  5. Click on your newly created bucket, click Upload, add your sample.jpg file, and click Upload again.

📸 Screenshot: S3 Bucket object list showing sample.jpg successfully uploaded.

Step 3: Image Analysis with Amazon Rekognition

Now we will use Amazon Rekognition's Computer Vision capabilities to detect objects, scenes, and concepts (collectively called "labels") in the image we just uploaded.

bash
aws rekognition detect-labels \ --image '{"S3Object":{"Bucket":"brainybee-lab-rekognition-<YOUR_ACCOUNT_ID>","Name":"sample.jpg"}}' \ --max-labels 5 \ --min-confidence 75

[!TIP] The --min-confidence flag filters out predictions that the AI is not highly certain about. A value of \mboxConfidence75%\mbox{Confidence} \ge 75\% is a standard baseline for production systems.

Console alternative
  1. Navigate to Amazon Rekognition in the AWS Console.
  2. In the left sidebar, click Label detection.
  3. Under the demo image, click Upload and select your sample.jpg from your local machine.
  4. Expand the Results pane on the right side to see the detected labels and their confidence scores.

📸 Screenshot: Rekognition console showing bounding boxes drawn over the uploaded image.

Step 4: Understanding Rekognition Bounding Boxes

When Rekognition detects a specific object (like a "Car" or a "Person"), it doesn't just tell you the object is there; it tells you exactly where it is by returning a BoundingBox object.

The coordinate system originates at the top-left corner of the image (0,0)(0,0). The values are returned as ratios of the overall image width and height (from $0.0 to $1.0).

Compiling TikZ diagram…
Running TeX engine…
This may take a few seconds

Checkpoints

Take a moment to verify your work. Run these checks before moving to the teardown phase:

  • Checkpoint 1: Review your Comprehend output. Do you see a primary "Sentiment" key (e.g., "MIXED" or "POSITIVE"), accompanied by a "SentimentScore" object detailing the exact probabilistic breakdown?
  • Checkpoint 2: Verify S3 upload. Run aws s3 ls s3://brainybee-lab-rekognition-<YOUR_ACCOUNT_ID> and confirm sample.jpg is listed.
  • Checkpoint 3: Review your Rekognition output. Do you see an array of "Labels"? If the object is localized, do you see the "Instances" array containing "BoundingBox" coordinates?

Troubleshooting

If you run into issues, consult this table for common errors and their fixes:

Error MessageLikely CauseSolution
AccessDeniedExceptionIAM User lacks permissions.Ensure ComprehendFullAccess and AmazonRekognitionFullAccess are attached to your IAM user.
InvalidS3ObjectExceptionRekognition cannot find the image.Check your bucket name and file name for typos. Ensure the file was actually uploaded.
BucketAlreadyExistsS3 bucket name is not unique.S3 bucket names must be globally unique. Add a random string or your AWS Account ID to the end.
UnrecognizedClientExceptionInvalid AWS CLI credentials.Run aws configure again and ensure your Access Key ID and Secret Access Key are correct.

Clean-Up / Teardown

[!WARNING] Cost Warning: Leaving objects in Amazon S3 will incur ongoing storage charges. Amazon Rekognition and Comprehend charge per API call, so they will not accrue passive costs, but cleaning up storage is essential.

Run the following commands to delete the resources provisioned in this lab:

bash
# 1. Delete the image file from S3 aws s3 rm s3://brainybee-lab-rekognition-<YOUR_ACCOUNT_ID>/sample.jpg # 2. Delete the empty S3 bucket aws s3 rb s3://brainybee-lab-rekognition-<YOUR_ACCOUNT_ID>

Verify that the teardown was successful by running aws s3 ls and ensuring your lab bucket is no longer in the list.


Concept Review

In this lab, you experienced the primary advantage of AWS Specialized AI Services: you were able to execute complex machine learning tasks (NLP and Computer Vision) instantly via API calls, without needing to collect data, train a model, or manage underlying infrastructure (like you would with Amazon SageMaker).

FeatureSpecialized AI Services (e.g., Comprehend, Rekognition)Custom ML (e.g., Amazon SageMaker)
Target PersonaSoftware Developers, Application EngineersData Scientists, ML Engineers
Ease of UseHigh (Pre-trained, accessible via simple APIs)Moderate to Advanced
Time to MarketFast (Minutes to hours)Slower (Weeks to months)
CustomizationLimited (Though fine-tuning is sometimes available)Infinite (Complete control over algorithms)

Ready to study AWS Certified AI Practitioner (AIF-C01)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free