File size: 1,959 Bytes
9994681 6f58245 9994681 | 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 | ---
license: apache-2.0
---
# Emotion Recognition Model
This repository hosts a custom-tuned Emotion Recognition model designed to analyze facial expressions in real-time video streams. The model predicts seven distinct emotions: **Angry**, **Disgust**, **Fear**, **Happy**, **Neutral**, **Sad**, and **Surprise**, and calculates a positivity level based on the predicted emotions.
## Model Details
- **Model Architecture:** The model is based on a fine-tuned VGG16 architecture using TensorFlow.
- **Input Size:** 224x224 pixels
- **Emotion Labels:**
- Angry
- Disgust
- Fear
- Happy
- Neutral
- Sad
- Surprise
## How to Use
1. Clone the repository and install the dependencies:
```bash
pip install -r requirements.txt
```
2. Load the model and run predictions on images:
```python
from tensorflow.keras.models import load_model
import cv2
import numpy as np
from tensorflow.keras.preprocessing.image import img_to_array
from tensorflow.keras.applications.vgg16 import preprocess_input
model = load_model('emotion_model_finetuned224.h5')
# Example usage with an image
image = cv2.imread('example.jpg')
face = cv2.resize(image, (224, 224))
face = img_to_array(face)
face = preprocess_input(face)
face = np.expand_dims(face, axis=0)
predictions = model.predict(face)
print(predictions)
```
## Gradio Interface (Optional)
If you want to deploy the model using Gradio, you can use the `app.py` file provided:
```bash
pip install gradio
python app.py
```
Visit the Gradio interface at `http://localhost:7860` and upload an image to see the predicted emotion.
## Dependencies
- `tensorflow`
- `opencv-python`
- `numpy`
- `requests`
- `gradio` (for optional web interface)
## License
This project is licensed under the MIT License. Feel free to use and modify as needed.
## Contact
For questions or support, please open an issue on the GitHub repository or contact Ahmad directly at [migdady@gmail.com](mailto:migdady@gmail.com).
|