Emotion AI Slides PDF
Emotion AI Slides PDF
2 FACIAL
EXPRESSION EMOTION
(EMOTION) CLASS:
DETECTION HAPPINESS
MODEL
PART 1. KEY FACIAL POINTS DETECTION
• In part #1, we will create a deep learning model based on Convolutional
Neural Network and Residual Blocks to predict facial key-
key-points.
.
TRAINED KEY
.
FACIAL POINTS
DETECTOR MODEL
96
5
PART 2. FACIAL EXPRESSION
(EMOTION) DETECTION
• The second model will classify people’s emotion.
• Data contains images that belong to 5 categories:
o 0 = Angry ANGER DIGUST
o 1 = Disgust
o 2 = Sad
o 3 = Happy
o 4 = Surprise SURPRISE!
SAD HAPPINESS
INPUT IMAGE
TARGET
CLASSES
CLASSIFIER Angry
48 (DEEP LEARNING Disgust
MODEL) Sad
Happiness
Surprise
48
7
NEURON MATHEMATICAL MODEL
• The brain has over 100 billion neurons communicating through
electrical & chemical signals. Neurons communicate with each other
and help us see, think, and generate ideas.
• Human brain learns by creating connections among these neurons.
ANNs are information processing models inspired by the human brain.
• The neuron collects signals from input channels named dendrites,
processes information in its nucleus, and then generates an output in
a long thin branch called axon.
,
P1
Performance measure
Training Predicted
$%#
Error = #
56788
1. Calculate the gradient (derivative) of the Loss function
59
2. Pick random values for weights (m, b) and substitute
3. Calculate the step size (how much are we going to update
the parameters?)
56788
:;<= 8>?< 6<@AB>BC A@;< ∗ CA@D><B; E ∗ 59
4. Update the parameters and repeat Parameters (m, b)
B<9 9<>CF; 76D 9<>CF; – 8;<= 8>?<
56788
9B<9 976D % E ∗ 59
*Note: in reality, this graph is 3D and has three axes, one for m, b and sum of squared residuals
CONVOLUTIONAL NEURAL NETWORKS:
ENTIRE NETWORK OVERVIEW
FACIAL KEY
POINTS
PREDICTION
CONVOLUTION
KERNELS/ POOLING POOLING FLATTENING
FILTERS
FEATURE
DETECTORS
POOLING LAYER EMOTION
CONVOLUTIONAL LAYER (DOWNSAMPLING) ANGRY PREDICTION
HAPPY
SAD
….
Conv2D
IDENTITY BLOCK BatchNorm, Relu
MaxPool2D
IDENTITY BLOCK
RES-BLOCK
OUTPUT RES-BLOCK
AveragePooling2D
Flatten()
KEY-POINTS OR
EMOTION
CONVOLUTION BLOCK IDENTITY BLOCK
INPUT INPUT
Conv2D Conv2D
BatchNorm, Relu
Conv2D Conv2D
BatchNorm
BatchNorm BatchNorm
+ +
Relu Relu
CONFUSION MATRIX
TRUE CLASS
TYPE I
+ - ERROR
PREDICTIONS
+ TRUE + FALSE +
FALSE - TRUE -
TYPE II -
ERROR
DEFINITIONS AND KPIS
• A confusion matrix is used to describe the performance of a
classification model:
o True positives (TP): cases when classifier predicted TRUE (they have
the disease), and correct class was TRUE (patient has disease).
o True negatives (TN): cases when model predicted FALSE (no disease),
and correct class was FALSE (patient do not have disease).
o False positives (FP) (Type I error): classifier predicted TRUE, but
correct class was FALSE (patient did not have disease).
o False negatives (FN) (Type II error): classifier predicted FALSE (patient
do not have disease), but they actually do have the disease
o Classification Accuracy = (TP+TN) / (TP + TN + FP + FN)
o Misclassification rate (Error Rate) = (FP + FN) / (TP + TN + FP + FN)
o Precision = TP/Total TRUE Predictions = TP/ (TP+FP) (When model
predicted TRUE class, how often was it right?)
o Recall = TP/ Actual TRUE = TP/ (TP+FN) (when the class was actually
TRUE, how often did the classifier get it right?)
PRECISION Vs. RECALL EXAMPLE
FACTS:
TRUE CLASS 100 PATIENTS TOTAL
91 PATIENTS ARE HEALTHY
+ - 9 PATIENTS HAVE CANCER
PREDICTIONS
• Accuracy is generally
TP = 1 FP = 1 misleading and is not enough
+ to assess the performance of
a classifier.
• Recall is an important KPI in
situations where:
- FN = 8 TN = 90 o Dataset is highly
imbalanced; cases when
you have small cancer
patients compared to
healthy ones.