File size: 1,563 Bytes
4d89257
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---

license: mit
language:
- en
metrics:
- accuracy
- precision
- recall
library_name: keras
tags:
- computer-vision
- image-classification
- tensorflow
- keras
- emotion-detection
---

# Emotion Classifier (Happy vs. Sad)

## Model Description
This is a custom **Convolutional Neural Network (CNN)** built using TensorFlow and Keras. The model is designed to perform binary image classification to distinguish between "Happy" and "Sad" facial expressions.

- **Model Type:** CNN (Sequential)
- **Task:** Binary Image Classification
- **Framework:** TensorFlow/Keras

## Training Data
The model was trained on a localized dataset of approximately 300 images. 
- **Preprocessing:** Images were resized to 256x256 pixels and normalized (pixel values scaled between 0 and 1).
- **Data Integrity:** A pre-training script was used to validate image headers and remove corrupted files.



[Image of a convolutional neural network architecture]


## Performance
During evaluation, the model achieved the following results:
- **Training Accuracy:** 98.9%
- **Validation Accuracy:** 96.9%
- **Precision:** 1.0 (on test batch)
- **Recall:** 1.0 (on test batch)



## How to Use
To load this model in Python:

```python
from tensorflow.keras.models import load_model
import cv2
import numpy as np

model = load_model('imageclassifier.h5')
img = cv2.imread('your_image.jpg')
resize = tf.image.resize(img, (256, 256))
prediction = model.predict(np.expand_dims(resize/255, 0))

if prediction > 0.5:
    print('Predicted: Sad')
else:
    print('Predicted: Happy')