For this final project, I'll work on an image classification model for determining happy and sad images. Similar to the cancer classification, images can be classified with 0 and 1 for happy and sad. I will use the Keras Sequential model with convolutional 2D layers. A model like this could be used for sentiment analysis or determining emotions in real-time. This will be a fairly simplified model with only binary output but could be expanded for other emotions such as angry, scared, surprised, etc.
Most of the images I retrieved from Google searches and some were from a Kaggle dataset for emotions.
After preprocessing the data to rescale, the images are classified as 1 for Sad and 0 for Happy and each image is 256 x 256, lets look at 12 rescaled and classified images
0 = Happy 1 = Sad
For this first Sequential model, I'll use 3 Convolutional 2D layers each with (3x3) filter size and stride of 1. The input shape is (256, 256, 3). 'relu' activation converts negative values from output to 0 and positive stays the same. MaxPooling2D layer takes max value after relu activation and returns that value to condense the info.
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓ ┃ Layer (type) ┃ Output Shape ┃ Param # ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩ │ conv2d (Conv2D) │ (None, 256, 256, 16) │ 448 │ ├─────────────────────────────────┼────────────────────────┼───────────────┤ │ max_pooling2d (MaxPooling2D) │ (None, 128, 128, 16) │ 0 │ ├─────────────────────────────────┼────────────────────────┼───────────────┤ │ conv2d_1 (Conv2D) │ (None, 126, 126, 32) │ 4,640 │ ├─────────────────────────────────┼────────────────────────┼───────────────┤ │ max_pooling2d_1 (MaxPooling2D) │ (None, 63, 63, 32) │ 0 │ ├─────────────────────────────────┼────────────────────────┼───────────────┤ │ conv2d_2 (Conv2D) │ (None, 61, 61, 16) │ 4,624 │ ├─────────────────────────────────┼────────────────────────┼───────────────┤ │ max_pooling2d_2 (MaxPooling2D) │ (None, 30, 30, 16) │ 0 │ ├─────────────────────────────────┼────────────────────────┼───────────────┤ │ flatten (Flatten) │ (None, 14400) │ 0 │ ├─────────────────────────────────┼────────────────────────┼───────────────┤ │ dense (Dense) │ (None, 256) │ 3,686,656 │ ├─────────────────────────────────┼────────────────────────┼───────────────┤ │ dense_1 (Dense) │ (None, 1) │ 257 │ └─────────────────────────────────┴────────────────────────┴───────────────┘
Precision: 1.0, Recall: 1.0, Acc: 1.0