File size: 3,847 Bytes
6682b02
 
b61f003
 
 
 
 
 
 
6682b02
b61f003
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---

license: mit
library_name: keras
tags:
  - image-classification
  - keras
  - face
  - face-expression
  - facial-expression
---


# Facial expression classification model

This model is designed for facial expression classification and it uses custom CNN model to classify the images into 7 different categories.

This CNN Model is to classify the facial expression into one of the following categories:

1. Anger
2. Disgust
3. Fear
4. Happiness
5. Neutral
6. Sadness
7. Surprise

## Architecture Summary

| Layer (type)                         | Output Shape                |         Param # |
|--------------------------------------|-----------------------------|-----------------|
| conv2d (Conv2D)                      | (None, 46, 46, 32)          |             320 |
| max_pooling2d (MaxPooling2D)         | (None, 23, 23, 32)          |               0 |

| dropout (Dropout)                    | (None, 23, 23, 32)          |               0 |

| conv2d_1 (Conv2D)                    | (None, 21, 21, 64)          |          18,496 |
| max_pooling2d_1 (MaxPooling2D)       | (None, 10, 10, 64)          |               0 |
| batch_normalization (BatchNormalization) | (None, 10, 10, 64)          |             256 |

| dropout_1 (Dropout)                  | (None, 10, 10, 64)          |               0 |
| conv2d_2 (Conv2D)                    | (None, 8, 8, 128)           |          73,856 |

| max_pooling2d_2 (MaxPooling2D)       | (None, 4, 4, 128)           |               0 |

| batch_normalization_1  (BatchNormalization) | (None, 4, 4, 128)           |             512 |

| dropout_2 (Dropout)                  | (None, 4, 4, 128)           |               0 |
| conv2d_3 (Conv2D)                    | (None, 2, 2, 128)           |         147,584 |

| flatten (Flatten)                    | (None, 512)                 |               0 |

| dense (Dense)                        | (None, 96)                  |          49,248 |

| dropout_3 (Dropout)                  | (None, 96)                  |               0 |
| dense_1 (Dense)                      | (None, 96)                  |           9,312 |

| dropout_4 (Dropout)                  | (None, 96)                  |               0 |
| dense_2 (Dense)                      | (None, 64)                  |           6,208 |

| dense_3 (Dense)                      | (None, 7)                   |             455 |

Total params: 306,247 (1.17 MB)

Trainable params: 305,863 (1.17 MB)

Non-trainable params: 384 (1.50 KB)

## Training details

- Dataset: https://www.kaggle.com/datasets/manishshah120/facial-expression-recog-image-ver-of-fercdataset

| Name | Value |
|------|-------|
| Input shape | 48x48 (48, 48, 1) |
| Optimizer | Adam |
| Loss | Crossentropy |
| Max epochs | 200 |
| Early stopping monitor | val_loss |

| Early stopping patience | 12 |



## Model performance



- Training Accuracy: 0.5758 (Epoch #84)

- Training Loss: 1.1272 (Epoch #84)

- Validation Accuracy: 0.5823 (Epoch #84)

- Validation Loss: 1.1285 (Epoch #84)



### Classification report

```

              precision    recall  f1-score   support



           0       0.52      0.40      0.45       491

           1       0.00      0.00      0.00        55

           2       0.43      0.17      0.25       528

           3       0.83      0.84      0.83       879

           4       0.51      0.67      0.58       626

           5       0.39      0.58      0.47       594

           6       0.73      0.72      0.73       416



    accuracy                           0.58      3589

   macro avg       0.49      0.48      0.47      3589

weighted avg       0.58      0.58      0.57      3589

```



## Notebook



Training notebook: https://www.kaggle.com/code/harkishankhuva/facial-expression-classification