Previous site

How can AI tell dogs from cats?

Train an image classifier, then connect its predictions to robot actions.

Middle school★★★★★CuroAI · Machine Learning

What you'll learn

  • Understand supervised learning with labeled examples
  • Train an image classifier with three classes: Dog, Cat, Background
  • Code robot actions for each prediction

You need

  • DC Motor Block ×2
  • LED Block
  • Sound Block
  • CuroAI Studio (web app)
How can AI tell dogs from cats?

Learn about AI

What is supervised learning?

AI learns patterns from many labeled dog and cat photos to tell the two classes apart.

Watch the reference video (Korean) ↗

How does AI learn dogs and cats?

  1. 1. Collect examplesCollect many photos of dogs and cats.
  2. 2. Find patternsCompare features such as ear and face shapes.
  3. 3. Learn patternsLearn patterns that help tell dogs from cats.

AI classifies a new photo

  1. 1. Show a new photoShow a photo AI has not seen before.
  2. 2. Compare patternsCompare it with learned patterns.
  3. 3. PredictChoose a class and show the prediction.
Comparing patternsEar shapeEye shapeNose shapeFace shape
Prediction
Dog92%
Cat8%
Example scores, not accuracy. Few or blurry photos can confuse AI.

💡 AI predicts a class by comparing a new photo with the patterns it learned.

Build

Let's build a dog and a cat!

DC Motor Block ×2Move the dog and cat tails
CommandWhat it does
Turn motor: rotate leftRotate continuously to the left.
Turn motor: rotate rightRotate continuously to the right.
Rotate left for 1 secondRotate left for the set time.
Rotate right for 1 secondRotate right for the set time.
Turn motor offStop the motor.
Sound BlockA dog sound effect
CommandWhat it does
Play notePlay a musical note.
Play note for 0.25 beatsSet the note duration in beats.
Play sound effectPlay a buzzer sound effect.
Play effect for 0.25 beatsSet the effect duration in beats.
LED BlockShow the cat's feelings
CommandWhat it does
Display LED dotsDraw a custom dot pattern.
Display text: AShow letters on the LED block.
Display number: 1Show numbers on the LED block.
Display icon: HeartShow a built-in icon.
Clear LED displayTurn off the LED dots.

Build the dog and cat

Teach the AI

Open CuroAI

Open CuroAI Studio ↗

Add the machine learning extension

Open Extensions and select Cubroid Machine Learning.

Create three classes

Create three classes: Dog, Cat and Background.

💡 What is a label? A class name that tells AI what an example shows.

15+ varied examples per class

Dog
Cat
Background

Name the three classes

Name each label, then click each naming block once to save.

💡 Why train Background? AI needs a class for scenes with no dog or cat.

name label [1 v] as [Dog] :: #52b98a

name label [2 v] as [Cat] :: #52b98a

name label [3 v] as [Background] :: #52b98a

Collect varied training examples

Collect 15+ varied examples per class with the training-label blocks. Vary the angle and background.

💡 Keep other animals out of view when collecting one class.

train label [1 v] :: #52b98a

train label [2 v] :: #52b98a

train label [3 v] :: #52b98a

Connect the blocks (group number)

Power on the blocks, match the block's sticker number, then confirm.

Group Number33

Code & run

Which block does what?

  • DC Motor 1Dog's tail
  • DC Motor 2Cat's tail
  • LED BlockCat's expression
  • Sound BlockDog's sound

Connect predictions to actions

DOG
  • Make a sound effect
  • Move motor 1 left / right
  • Stop motor 1
CAT
  • Show an LED heart
  • Move motor 2 left / right
  • Stop motor 2; clear LEDs
BACKGROUND
  • Stop motor 1
  • Stop motor 2
  • Clear the LED display

Review the complete program

Click the naming and training blocks first. The ‘when received label’ blocks then run by themselves each time the AI recognises a class.

DOG
name label [1 v] as [Dog] :: #52b98a

train label [1 v] :: #52b98a

when received label: [1 v] :: hat #52b98a
play note [Small effect v] :: sound
turn DC Motor Block 1 (1)for [rotate left v] seconds :: motion
wait (1) seconds :: control
turn DC Motor Block 1 (1)for [rotate right v] seconds :: motion
wait (1) seconds :: control
turn DC Motor Block 1 off :: motion
CAT
name label [2 v] as [Cat] :: #52b98a

train label [2 v] :: #52b98a

when received label: [2 v] :: hat #52b98a
display [♥ v] :: looks
turn DC Motor Block 2 (1)for [rotate left v] seconds :: motion
wait (1) seconds :: control
turn DC Motor Block 2 (1)for [rotate right v] seconds :: motion
wait (1) seconds :: control
turn DC Motor Block 2 off :: motion
clear display :: looks
BACKGROUND
name label [3 v] as [Background] :: #52b98a

train label [3 v] :: #52b98a

when received label: [3 v] :: hat #52b98a
turn DC Motor Block 1 off :: motion
turn DC Motor Block 2 off :: motion
clear display :: looks

💡 Train 15+ varied examples per class before testing. Check label changes, timing and motor direction.

Quick quiz

QWhat is the learning method that uses labeled examples?

Show answer

Supervised learning — AI learns from examples with class labels.

Lesson complete!

Built it, coded it and tested it? Tap to save your progress.