-
Stage 1 – Frozen Base Training (10 Epochs):
- The convolutional base (VGG19) was frozen.
- Only newly added dense layers were trained.
- Purpose: Train classifier layers without disrupting pre-trained features.
-
Stage 2 – Unfrozen Base Fine-Tuning (30 Epochs):
- The base model was unfrozen and fine-tuned with a low learning rate.
- Purpose: Enhance generalization and feature learning for emotion-specific characteristics.
These visualizations clearly demonstrate model learning stability, class balance, and classification performance across emotions.
1import tensorflow as tf
2from tensorflow.keras.preprocessing import image
3import numpy as np
4
5# Load original model
6model_path = 'emotion_vgg19_model.h5'
7model = tf.keras.models.load_model(model_path)
8
9# Prepare input
10img = image.load_img('test_face.jpg', target_size=(224, 224))
11input_data = np.expand_dims(image.img_to_array(img) / 255.0, axis=0)
12
13# Run inference with original model
14pred = model.predict(input_data)
15classes = ['Angry', 'Disgust', 'Fear', 'Happy', 'Neutral', 'Sad', 'Surprise']
16print("Original Model Prediction:", classes[np.argmax(pred)])
17
18# Load TFLite optimized model
19tflite_model_path = 'emotion_vgg19_optimized.tflite'
20interpreter = tf.lite.Interpreter(model_path=tflite_model_path)
21interpreter.allocate_tensors()
22input_index = interpreter.get_input_details()[0]['index']
23output_index = interpreter.get_output_details()[0]['index']
24interpreter.set_tensor(input_index, input_data.astype(np.float32))
25interpreter.invoke()
26output = interpreter.get_tensor(output_index)
27print("TFLite Model Prediction:", classes[np.argmax(output)])
1@misc{pasindu_sewmuthu_abewickrama_singhe_2025,
2 author = { Pasindu Sewmuthu Abewickrama Singhe },
3 title = { vgg19-emotion-recognition-ckplus-rafdb (Revision dad246e) },
4 year = 2025,
5 url = { https://huggingface.co/PSewmuthu/vgg19-emotion-recognition-ckplus-rafdb },
6 doi = { 10.57967/hf/6651 },
7 publisher = { Hugging Face }
8}