Hands-On Lab962 words

Hands-On Lab: Exploring Basic AI Concepts and Terminology

AI Concepts and Terminology

Hands-On Lab: Exploring Basic AI Concepts and Terminology

Welcome to this guided hands-on lab! This module bridges the theoretical concepts from Chapter 1 (Fundamentals of AI and ML) with practical reality. You will interact with pre-trained Artificial Intelligence (AI) models using AWS managed services to perform Computer Vision and Natural Language Processing (NLP) tasks.

By completing this lab, abstract terms like unstructured data, real-time inferencing, and confidence scores will become tangible.

Prerequisites

Before starting, ensure you have the following:

  • AWS Account: An active AWS account with administrative or developer access.
  • CLI Tools: AWS CLI installed and configured (aws configure) on your local machine or AWS CloudShell.
  • Prior Knowledge: Familiarity with basic terminal commands and a conceptual understanding of AI vs. Machine Learning (ML).

Learning Objectives

  1. Differentiate AI fields in practice: Use distinct services for Computer Vision (Amazon Rekognition) and Natural Language Processing (Amazon Comprehend).
  2. Understand Data Types: Work with unstructured data formats (images and raw text) rather than tabular data.
  3. Perform Real-Time Inferencing: Send data to an ML model and receive immediate probabilistic predictions.
  4. Analyze Model Outputs: Interpret JSON responses containing confidence scores to understand the probabilistic nature of AI.

Architecture Overview

This lab uses a simple serverless architecture to demonstrate real-time inferencing on unstructured data.

Loading Diagram...

Step-by-Step Instructions

Step 1: Prepare Unstructured Data (Amazon S3)

In Machine Learning, images and text are considered unstructured data. Deep learning models are particularly adept at processing this format. Let's create a storage bucket and upload a sample image.

bash
# 1. Create a globally unique S3 bucket (replace <YOUR_ACCOUNT_ID>) aws s3 mb s3://brainybee-lab-vision-<YOUR_ACCOUNT_ID> # 2. Download a sample image of a city skyline (or use any local JPEG) curl -o sample.jpg https://raw.githubusercontent.com/aws-samples/amazon-rekognition-developer-guide/master/images/city.jpg # 3. Upload the unstructured data to S3 aws s3 cp sample.jpg s3://brainybee-lab-vision-<YOUR_ACCOUNT_ID>/

📸 Screenshot: A terminal showing the successful upload: sample.jpg to s3://... output.

Console alternative
  1. Navigate to Amazon S3 in the AWS Console.
  2. Click Create bucket, name it brainybee-lab-vision-<YOUR_ACCOUNT_ID>, and click Create bucket.
  3. Select your new bucket, click Upload, and upload a local image file named sample.jpg.

Step 2: Real-Time Inferencing with Computer Vision

Computer Vision is an AI field enabling systems to derive information from images. We will use Amazon Rekognition to perform real-time inferencing (getting immediate predictions) on our unstructured image.

bash
# Run real-time inferencing to detect labels (objects, scenes) in the image aws rekognition detect-labels \ --image '{"S3Object":{"Bucket":"brainybee-lab-vision-<YOUR_ACCOUNT_ID>","Name":"sample.jpg"}}' \ --max-labels 5

[!TIP] Look at the JSON response. Notice the Confidence attribute next to each label. AI models do not return absolute facts; they return probabilities based on their training data.

Console alternative
  1. Navigate to Amazon Rekognition in the AWS Console.
  2. In the left sidebar, click Label detection.
  3. Under the demo section, expand the Upload panel and upload your sample.jpg.
  4. Observe the detected labels and their percentage scores (confidence) in the Results pane.

Step 3: Natural Language Processing (NLP)

Natural Language Processing (NLP) allows computers to interpret human language. We will use Amazon Comprehend to analyze the sentiment of unstructured text.

bash
# Perform NLP inferencing to determine text sentiment aws comprehend detect-sentiment \ --text "Artificial intelligence is a fascinating and transformative technology, though data drift can occasionally cause headaches!" \ --language-code "en"

📸 Screenshot: The JSON output from Comprehend showing a Sentiment of MIXED or POSITIVE, along with SentimentScore breakdowns.

Console alternative
  1. Navigate to Amazon Comprehend in the AWS Console.
  2. Scroll down to the Real-time analysis section.
  3. Paste the text: "Artificial intelligence is a fascinating and transformative technology, though data drift can occasionally cause headaches!"
  4. Click Analyze and view the Sentiment results in the Insights tab.

Checkpoints

Verify your progress after completing the steps above:

  • Checkpoint 1: Run aws s3 ls s3://brainybee-lab-vision-<YOUR_ACCOUNT_ID>. You should see sample.jpg listed.
  • Checkpoint 2: In your Rekognition JSON output, did you receive a list of Labels? If you used a city image, you should see labels like City, Building, or Urban.
  • Checkpoint 3: In your Comprehend JSON output, locate the SentimentScore object. Notice how the scores for Positive, Negative, Neutral, and Mixed all add up to approximately 1.0 (100%).

Concept Review

To solidify your understanding of Chapter 1, let's visually review the hierarchy of AI and the services you just used.

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

Terminology Mapping Table

Textbook ConceptLab ApplicationDescription
Unstructured Datasample.jpg, Raw TextData that does not fit neatly into rows and columns.
Inferencingdetect-labels, detect-sentimentThe process of passing new data through a trained model to make a prediction.
Real-time InferenceCLI Command ResponseReceiving immediate, synchronous predictions with low latency.
Computer VisionAmazon RekognitionDeep learning applied to visual data extraction.
NLPAmazon ComprehendDeep learning applied to human language understanding.

Clean-Up / Teardown

[!WARNING] Remember to run the teardown commands to avoid ongoing charges. While Rekognition and Comprehend charge per-request, S3 storage incurs ongoing costs.

Execute the following commands to delete the resources created in this lab:

bash
# Empty the S3 bucket aws s3 rm s3://brainybee-lab-vision-<YOUR_ACCOUNT_ID> --recursive # Delete the S3 bucket aws s3 rb s3://brainybee-lab-vision-<YOUR_ACCOUNT_ID>

Note: Amazon Rekognition and Amazon Comprehend APIs used in this lab do not provision permanent infrastructure; they are stateless API calls.

Troubleshooting

Error MessageLikely CauseSolution
AccessDeniedIAM User lacks permissions.Ensure your IAM user has AmazonS3FullAccess, AmazonRekognitionFullAccess, and ComprehendFullAccess policies attached.
BucketAlreadyExistsS3 bucket names are globally unique.Change <YOUR_ACCOUNT_ID> to something highly unique (e.g., your name plus random numbers).
InvalidImageFormatExceptionRekognition doesn't support the file.Ensure the image uploaded to S3 is a .jpg or .png file under 5MB.
Could not connect to the endpoint URLCLI region configuration issue.Run aws configure and ensure you have a valid default region set (e.g., us-east-1).

Stretch Challenge

Want to test your skills further without step-by-step guidance?

Challenge: Try passing an image containing printed text (like a picture of a street sign or a book page) to Amazon Rekognition to extract the words. Hint: Look up the detect-text API method for Rekognition.

Show solution
bash
# Upload an image with text first aws s3 cp sign.jpg s3://brainybee-lab-vision-<YOUR_ACCOUNT_ID>/ # Run the detect-text API (Optical Character Recognition - OCR) aws rekognition detect-text \ --image '{"S3Object":{"Bucket":"brainybee-lab-vision-<YOUR_ACCOUNT_ID>","Name":"sign.jpg"}}'

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

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

Start Studying — Free