What Is AI? Let the Computer Look at a Picture


Welcome to Phase IV — the grand finale! You’ve learned to draw, to code with words and logic, and to explore real data. Now you’ll meet Artificial Intelligence: programs that learn patterns from huge amounts of examples. The best way to understand AI is to use one, so today you’ll point a ready-made AI at a photo and watch it guess what’s in the picture.

You’re back in Google Colab (the tool from Phase III). Everything runs there.

What “AI” really means

AI isn’t magic and it isn’t a robot brain. An AI is a program that has been shown millions of examples until it learned the patterns — millions of labeled photos until it learned what a “cat” or a “pizza” looks like. We’ll use one of those trained programs first, then later teach our own. The key idea: AI learns from examples, not from rules someone typed.

Borrow a trained AI

There’s a library called transformers full of AIs other people already trained. Install it and load an image recognizer (run this in a cell):

!pip install -q transformers
from transformers import pipeline

recognizer = pipeline("image-classification")

💡 The first time you run this, it downloads the AI model — that can take a minute, and needs internet. The !pip install line installs the library. If you ever see “module not found,” run that line again.

Show it a photo

In Colab, upload a picture from your computer (a pet, a toy, some food):

from google.colab import files
uploaded = files.upload()          # a button appears — choose a photo
filename = list(uploaded.keys())[0]

Then ask the AI what it sees:

results = recognizer(filename)
for r in results:
    print(r["label"], "-", round(r["score"] * 100), "percent sure")

The AI prints its top guesses, each with how confident it is. Show it a dog and it might say “Labrador retriever - 84 percent sure.” You didn’t write a single rule about dogs — the AI learned what dogs look like from examples.

💡 Not on Colab? In Jupyter, skip the upload step and pass a path to an image file you have, like recognizer("myphoto.jpg").

Try it 🎯

  1. Upload a few different photos and see what it guesses.
  2. Try a tricky one — a cartoon, or two animals at once. Does it still do well?
  3. Find a photo it gets wrong. (You will — that’s important, and we’ll talk about it soon.)

It’s just a function that returns

Look closely: recognizer(filename) is a function that returns a list of guesses — exactly the function-and-return idea from Phase II. AI tools are normal Python you call like anything else. The “intelligence” is inside the trained model; using it is just code.

Think about it 🔮

The AI says “85 percent sure.” Does that mean it’s right 85% of the time, or that it’s fairly confident about this one picture? (It means confident about this picture — and confident isn’t the same as correct. AIs can be very sure and still wrong.)

Your mission 🚀

Be an AI tester. Upload five different photos and write down (in print statements or on paper): what the AI guessed, how confident it was, and whether it was right. Find at least one photo it gets wrong.

What you learned today

  • AI is a program that learned patterns from huge numbers of examples — not hand-written rules.
  • transformers lets you borrow AIs other people trained; pipeline("image-classification") recognizes photos.
  • You use an AI by calling it like a function that returns its guesses.
  • A confidence score is how sure the AI is — not a guarantee it’s right.

Next time, a different AI: one that reads a sentence and tells you whether it sounds happy or sad. 😀😢