0% found this document useful (0 votes)
14 views6 pages

AI Face Emotion Classification Guide

This document outlines a project using Artificial Intelligence to classify faces as happy or sad through the Teachable Machine platform. It details the steps for creating training data, preparing and training the model, testing its performance, and analyzing results. The project encourages iterative improvement by adding more training data and re-evaluating the model's accuracy.

Uploaded by

ogaka2400
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views6 pages

AI Face Emotion Classification Guide

This document outlines a project using Artificial Intelligence to classify faces as happy or sad through the Teachable Machine platform. It details the steps for creating training data, preparing and training the model, testing its performance, and analyzing results. The project encourages iterative improvement by adding more training data and re-evaluating the model's accuracy.

Uploaded by

ogaka2400
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Happy or Sad?

Use Artificial Intelligence to Classify Faces

Experimental Procedure

This project follows the Engineering Design Process. Confirm with your teacher if this is acceptable for your project,
and review the steps before you begin.

Just like little kids learn to distinguish happy from sad faces by seeing examples, Teachable Machine will learn from
examples you provide. We will refer to this set of examples as the training data because your model will learn from this set
of drawings.

Getting Familiar with Teachable Machine

1. Before you start this project, it might be fun and helpful to play with Teachable Machine. Go to the Teachable Machine
new project web page and use the webcam to train the model to recognize whether you or a stuffed animal is looking
at the camera.

The Teachable Machine Tutorial 1 video explains how to gather training data. Go ahead and gather training data. If
your computer does not have a webcam, take digital pictures and upload those to the model instead. Then, watch the
Teachable Machine Tutorial 2 video to learn how to train the model.

The Teachable Machine Tutorial 3 video shows how to understand the predictions.

Try these steps to get familiar with Teachable Machine and be sure to watch the tutorials if you get stuck.

Creating Training Data

1. Draw examples of happy faces in twenty circles (two sheets of the template) and sad faces in another set of twenty
circles (two templates). Always use the same pencil or pen to draw your faces.

2. Cut along the lines and make a stack of happy and a stack of sad faces.

3. If you do not have a digital camera or scanner you can use the webcam to take pictures in Teachable Machine. This
will be explained below. If you have a digital camera or scanner and can easily transfer the files to the computer:
a. For each drawing, place the face on a plain background like a sheet of colored construction paper, as shown in
Figure 5. Take a picture or scan. Try your best to take every picture the same way, laying the sad/happy face in
the same spot, at the same angle, same distance, etc.

b. Transfer the files to the computer. Organize them (by giving them clear filenames or putting them in a folder) so
you can clearly identify them as the training data later.

Copyright © 2002-2025 Science Buddies


[Link] 2024-10-18
Image Credit: Sabine De Brabandere, Science Buddies / Science Buddies

Figure 5. A drawing that is ready to be photographed (lower right corner), and six drawings that have already been
photographed (upper left corner).
Preparing the Model

1. Go to the Teachable Machine new project web page for recognizing images.

2. Label the classes.


The model will classify drawings of faces into two groups or classes: happy faces and sad faces. Rename class 1 as
"Happy" and class 2 as "Sad."

Uploading Training Data

1. If you already saved the learning data files to your computer, use the "Upload" button to upload the training data files
for happy faces to the "Happy" class, and the training data files for the sad face to the "Sad" class.

2. If you will use the webcam in Teachable Machine to take pictures:


a. Start the webcam for the "Happy" class by clicking the "Webcam" button.

b. Place a happy face drawing on a plain background like a sheet of colored construction paper.
c. Hold the drawing close to the lens, so the drawing fills most of the space.

d. Take all the pictures with the camera at the same angle so the lighting stays consistent.

e. Try to keep your fingers out of the picture. Teachable Machine has a function that crops the pictures as you are
taking them. This can help you crop your fingers out of the pictures.
f. Repeat step b–e for all happy drawings in your training data. Try your best to take every picture in the same way.

g. Once all happy faces of the learning data are uploaded, move on to the "Sad" class, repeat steps b–f for
uploading the sad faces learning data. Try your best to take these pictures the same way as you took the happy
face pictures.

You now have twenty pictures in the training data for each class. If this is not the case, remove doubles or add pictures where
needed.

Copyright © 2002-2025 Science Buddies


[Link] 2024-10-18
It is fine if the training data shows some variation in lighting, distance, etc. It is important though that these variations occur in
both classes. For example, it is not OK to have all the pictures in the "Happy" class to be close-ups and all the pictures of the
"Sad" class to be taken from further away. But having about the same portion of close-ups and pictures taken from further
away in both classes is fine.

Training the Model

1. Start the model's learning process by clicking on the "Train Model" button. The model should take less than a minute to
complete this step. In that time, the model for searches patterns in the training data it can use to distinguish between
happy and sad drawings.

Saving the Model

1. All the uploaded data on the machine can be saved to Google Drive and later uploaded from the Drive to continue.
Look for the commands "Save project to Drive" and "Open project from Drive" under the "Teachable Machine" menu. It
will ask you to log in to a Google account to access your Google Drive.
The project can also be saved as a file on your computer and uploaded later. Look for the commands "Download
project as file" and "open project from file" under the "Teachable Machine" menu.

Testing the Model

1. To see how the model performs, you can use the webcam or files. Figure 6 shows how to toggle between the two.

Image Credit: Sabine De Brabandere, Science Buddies / Science Buddies

Figure 6. Teachable Machine allows you to use files you upload or the webcam to test the tool.

One by one, choose a few happy and a few sad drawings from the training data, and test how the model classifies
these drawings.

The bars under the test picture in the "output" box inform you how the model classifies the drawing. Your model will
probably classify its training data with high confidence, as shown in the left image of Figure 7 where we see the model
is certain the image belongs to the "Happy" class.

Sometimes, the model is not clear about how to classify a drawing. The right image in Figure 7 is an example. The
orange bar next to "Happy" shows the model classifies this drawing with a confidence of 59% in the "Happy" class.
The red bar next to "Sad" shows it is 41% confident the drawing belongs to the "Sad" class.

Copyright © 2002-2025 Science Buddies


[Link] 2024-10-18
Image Credit: Sabine De Brabandere, Science Buddies / Science Buddies

Figure 7. Two examples of an AI tool that learned to classify happy and sad face drawings.

In this experiment, you classify a drawing in the class for which the tool shows a confidence of over 50%. With this rule,
the picture on the right in Figure 8 is classified under "Happy" because 59 is higher than 50. Because this drawing is
in fact a sad face, the tool receives a mark in "Sad drawing misclassified as "Happy."

If you use the webcam, try your best to show the drawings the same way as you took pictures previously.

2. In your notebook, draw a confusion matrix like the one shown in Figure 8. Do not forget to fill in the amount of training
data you used in the title.

Image Credit: Sabine De Brabandere, Science Buddies / Science Buddies

Figure 8. A confusion matrix helps organize the test results.

Testing New Data

The real test is seeing how well the tool can classify drawings it has never seen (drawings that were not part of the training
data).

Copyright © 2002-2025 Science Buddies


[Link] 2024-10-18
1. Create five more happy face drawings and five more sad face drawings.

2. One at a time, test each new face.

3. Record a new confusion matrix. How did your model do with the new faces that were not part of the training data?

Adding More Training Data

You have trained and tested a model that used twenty drawings in each class to learn the difference between a happy and
sad face. You will now find out what happens to your model's accuracy if you add more training data.

1. Save the model under a new name. This will keep this model separate from the one that was trained with twenty
drawings per class. You can update the name of your model by clicking the pencil icon located under the "Teachable
Machine" menu.
2. Draw 15 more happy faces and 15 more sad faces. Combined with the 5 each that you drew in the previous section,
you should now have 20 new faces for each class.

3. Using the webcam or file upload feature, add 20 new faces to each one of the classes (the files that you uploaded
previously should still be there).

4. Re-train the model.


5. Re-test the model as you did previously, first with faces that were included in the training data, then with new faces.
Record a new confusion matrix each time.

Analyzing the Data

1. Compare and contrast the confusion matrices you have. The background section can help you understand the
confusion matrix. Remember, blue represents accuracy, yellow represents misclassification. Higher numbers in the
blue squares and lower numbers in the yellow squares indicate a better-performing model.
2. Did adding more training data improve the accuracy of your model? If not, you can continue to iteratively add more
training data, re-test, and re-train the model. Do you reach a point of diminishing returns, where adding more training
data does not significantly improve the model's accuracy?

Communicating the Results

1. Add pictures of the learning data and classifications of the AI tool you created in your report. Figure 2 and Figure 3 are
good examples.

Frequently Asked Questions (FAQ)


If you are having trouble with this project, please read the FAQ below. You may find the answer to your question.

Q: Why does my tool change when I retrain Teachable Machine, even when I do not change the learning data?
A: Teachable Machine uses 85% of the learning data to learn and 15 % of the learning data to test its own performance. The
selection is made at random, so each time you retrain the machine, it learns from a different set of data. This will create
slight variations in your tool.

Last edit date: 2024-10-18

Copyright © 2002-2025 Science Buddies


[Link] 2024-10-18
You can find this page online at: [Link]
ideas/CompSci_p067/computer-science/machine-learning-classification?mode=procedure

You may print and distribute up to 200 copies of this document annually, at no charge, for personal and classroom
educational use. When printing this document, you may NOT modify it in any way. For any other use, please contact
Science Buddies.

Science Buddies is a 501(c)3 nonprofit organization.


Copyright © 2002-2025 Science Buddies. All rights reserved. Reproduction of material from this website without written permission is strictly
prohibited.
Use of this site constitutes acceptance of our Terms and Conditions of Fair Use.
Privacy Policy

Copyright © 2002-2025 Science Buddies


[Link] 2024-10-18

Common questions

Powered by AI

To create and train an AI model to classify facial expressions, follow these steps: 1. Familiarize yourself with the Teachable Machine tool, optionally using the provided tutorial videos to learn about gathering and training data . 2. Create training data by drawing examples of happy and sad faces, ensuring consistency in the drawing style . 3. Capture images of these drawings either using a webcam or by scanning the drawings, organizing them clearly by class. Consistency in how the images are taken (angle, distance) is critical . 4. Upload the classified training data ("Happy" and "Sad") to Teachable Machine. Use the tool to label these images accordingly . 5. Begin the training process, where the model will identify patterns in the data to distinguish between happy and sad faces . 6. Test the model with both training data and new data not seen before to evaluate its accuracy. Measure performance using a confusion matrix to track correct and incorrect classifications .

Consistency in conditions such as lighting, angle, and distance when capturing training images is crucial because it reduces variability that can confuse the model. Consistent captures ensure that the features the model learns to recognize are due to the subject (happy or sad faces) and not extraneous factors. Variability in these conditions across classes (all 'Happy' images being close-ups while 'Sad' images are distant) can introduce bias and reduce model reliability .

Increasing the amount of training data generally improves a model's accuracy by providing more examples for pattern recognition. When more data is added, it allows the model to learn and generalize better across different instances. However, there can be diminishing returns if the model reaches a point where additional data does not significantly enhance accuracy . Testing with different confusion matrices enables comparison of model performance before and after adding more data .

Proper testing involves using two phases: in-training data and novel data testing. Initially, use a portion of the training data to verify that the model accurately classifies images it has seen before, examining confidence levels. Then, introduce novel data that wasn't part of the training set to evaluate the model's generalization abilities. Record results in confusion matrices for each phase to understand strengths and weaknesses in different scenarios. Iteratively adjust training data and re-evaluate to optimize performance .

The Engineering Design Process serves as a structured framework guiding the development of machine learning projects. It involves defining the problem (classifying emotions), brainstorming potential approaches, designing solutions (such as collecting data and selecting features), building and testing models iteratively, and analyzing results to refine the project. This ensures a systematic progression from concept to functional AI application, promoting critical thinking and problem-solving at each stage .

Using a webcam for capturing training data has the benefit of convenience and immediacy, allowing for quick data collection. It supports a dynamic and flexible setup where images can be captured and immediately uploaded for training . However, challenges include ensuring consistent lighting and angles to maintain data quality and using measures to avoid issues such as image noise and variability, which could affect model accuracy .

Teachable Machine randomly splits the training data into a learning set (85%) and a test set (15%) during each training session. This random selection process means that the exact data subset used for training and testing can vary each time the model is trained, which can lead to slight variations in model performance even if the overall data remains unchanged. This approach ensures that the model tests its ability to generalize but means results can fluctuate, emphasizing the need for multiple training runs to understand the model's consistent behavior .

When saving and managing AI projects in Teachable Machine, consider both local and cloud storage. Projects can be saved directly to Google Drive, allowing for easy access and collaboration, or downloaded for offline work. It's important to maintain organization of different project versions, especially after adding new data or making significant model changes, to allow for reliable comparison of performance across different iterations. This ensures data safety and enables ongoing development .

Testing with non-training data, which consists of entirely new samples that the model has not seen during training, is crucial for evaluating its robustness. It allows assessment of the model's ability to generalize beyond memorized patterns and handle variations in unseen instances. It tests the model's adaptive capacity and provides insights into its potential limitations or biases that might not be apparent when testing only with training data. Robust models consistently perform well on both training and non-training data, indicating effective learning and capacity for practical application .

Confusion matrices provide a detailed view of model performance by displaying the counts of true positive, true negative, false positive, and false negative classifications. They help identify specific areas where the model struggles, such as consistently misclassifying a 'Sad' face as 'Happy'. This detailed breakdown facilitates targeted model improvements and helps evaluate the balance between recall and precision. By comparing confusion matrices across different training stages, one can assess how additional data or model adjustments impact performance .

You might also like