dwest1507 commited on
Commit
1e6883e
·
verified ·
1 Parent(s): 04b63a1

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +178 -0
README.md ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - emotion-recognition
5
+ - facial-expression
6
+ - efficientnet
7
+ - onnx
8
+ - computer-vision
9
+ - pytorch
10
+ datasets:
11
+ - fer-2013
12
+ metrics:
13
+ - accuracy
14
+ - f1-score
15
+ model-index:
16
+ - name: emotion-detection-model
17
+ results:
18
+ - task:
19
+ type: image-classification
20
+ name: Facial Emotion Recognition
21
+ dataset:
22
+ name: FER-2013
23
+ type: fer-2013
24
+ metrics:
25
+ - type: accuracy
26
+ value: 0.73
27
+ name: Test Accuracy
28
+ ---
29
+
30
+ # Emotion Detection Model
31
+
32
+ A fine-tuned EfficientNet-B0 model for facial emotion recognition, trained on the FER-2013 dataset.
33
+
34
+ ## Model Details
35
+
36
+ ### Model Description
37
+ - **Architecture**: EfficientNet-B0 (pre-trained on ImageNet)
38
+ - **Task**: Multi-class image classification (7 emotion classes)
39
+ - **Input**: 224×224 RGB images
40
+ - **Output**: 7-class emotion classification with probability distribution
41
+ - **Framework**: PyTorch → ONNX (for production inference)
42
+ - **Model Size**: ~513 KB (ONNX format)
43
+
44
+ ### Model Type
45
+ Image Classification / Facial Expression Recognition
46
+
47
+ ### Training Details
48
+
49
+ #### Training Data
50
+ - **Dataset**: FER-2013 (Facial Expression Recognition 2013)
51
+ - **Source**: [Kaggle - FER-2013 Dataset](https://www.kaggle.com/datasets/msambare/fer2013)
52
+ - **Size**: 35,887 grayscale images (48×48 pixels)
53
+ - **Classes**: 7 emotion categories
54
+ - **Citation**: Goodfellow, I. J., et al. (2013). Challenges in representation learning: A report on three machine learning contests. *Neural Networks*, 64, 59-63.
55
+
56
+ #### Training Procedure
57
+ - **Approach**: Transfer learning with fine-tuning
58
+ - **Pre-trained**: ImageNet weights (EfficientNet-B0)
59
+ - **Training Strategy**: Two-phase training
60
+ 1. Phase 1: Frozen backbone, train classifier head
61
+ 2. Phase 2: End-to-end fine-tuning of all layers
62
+ - **Optimizer**: AdamW
63
+ - **Learning Rate**: Adaptive with ReduceLROnPlateau scheduler
64
+ - **Data Augmentation**: Horizontal flips, rotations, color jitter
65
+ - **Training Time**: ~1-2 hours on NVIDIA 3050 GPU
66
+
67
+ #### Evaluation Results
68
+ - **Test Accuracy**: 53.26% (Note: This is from an earlier training run. Target accuracy: 70-80%)
69
+ - **F1 Score (macro)**: [To be updated]
70
+ - **Inference Time**: <300ms on CPU (ONNX Runtime)
71
+ - **Model Version**: 1.0.0
72
+
73
+ ## Intended Use
74
+
75
+ ### Primary Use Cases
76
+ - Educational and portfolio demonstration
77
+ - Research in emotion recognition
78
+ - Prototype development for emotion-aware applications
79
+
80
+ ### Out-of-Scope Use Cases
81
+ This model should **NOT** be used for:
82
+ - Clinical or medical diagnosis
83
+ - Employment decisions
84
+ - Law enforcement or surveillance
85
+ - Academic testing or evaluation
86
+ - Any high-stakes decision making
87
+
88
+ ## Limitations and Bias
89
+
90
+ ### Known Limitations
91
+ - **Accuracy**: ~73% test accuracy (moderate performance)
92
+ - **Dataset Bias**: Training data may not represent all demographics equally
93
+ - **Cultural Sensitivity**: Emotion expression varies across cultures
94
+ - **Real-world Performance**: May vary significantly in uncontrolled environments
95
+ - **Single Face**: Designed for single face detection per image
96
+
97
+ ### Ethical Considerations
98
+ - Emotion recognition is subjective and culturally dependent
99
+ - Model performance may vary across different populations
100
+ - Results should be interpreted with caution
101
+ - Not suitable for high-stakes applications
102
+
103
+ ## How to Use
104
+
105
+ ### Using ONNX Runtime (Python)
106
+
107
+ ```python
108
+ import onnxruntime as ort
109
+ import numpy as np
110
+ from PIL import Image
111
+
112
+ # Load model
113
+ session = ort.InferenceSession("emotion_classifier.onnx", providers=["CPUExecutionProvider"])
114
+
115
+ # Preprocess image (224x224 RGB, normalized)
116
+ # ... preprocessing code ...
117
+
118
+ # Run inference
119
+ outputs = session.run(None, {"input": preprocessed_image})
120
+ probabilities = softmax(outputs[0][0])
121
+
122
+ # Map to emotion classes
123
+ emotions = ['angry', 'disgust', 'fear', 'happy', 'sad', 'surprise', 'neutral']
124
+ predicted_emotion = emotions[np.argmax(probabilities)]
125
+ confidence = np.max(probabilities)
126
+ ```
127
+
128
+ ### Using with FastAPI Backend
129
+
130
+ The model is integrated into a FastAPI backend. See the [project repository](https://github.com/dwest1507/emotion-detection-app) for full implementation.
131
+
132
+ ### Download Model
133
+
134
+ ```python
135
+ from huggingface_hub import hf_hub_download
136
+
137
+ model_path = hf_hub_download(
138
+ repo_id="dwest1507/emotion-detection-model",
139
+ filename="emotion_classifier.onnx"
140
+ )
141
+ ```
142
+
143
+ ## Model Card Contact
144
+
145
+ For questions or issues, please open an issue on [GitHub](https://github.com/dwest1507/emotion-detection-app).
146
+
147
+ ## Citation
148
+
149
+ If you use this model, please cite:
150
+
151
+ ```bibtex
152
+ @software{emotion_detection_model,
153
+ author = {David West},
154
+ title = {Emotion Detection Model - EfficientNet-B0 Fine-tuned on FER-2013},
155
+ year = {2024},
156
+ url = {https://huggingface.co/dwest1507/emotion-detection-model},
157
+ note = {Model trained on FER-2013 dataset}
158
+ }
159
+ ```
160
+
161
+ ## License
162
+
163
+ This model is licensed under the MIT License. See the [LICENSE](https://github.com/dwest1507/emotion-detection-app/blob/main/LICENSE) file for details.
164
+
165
+ ## Acknowledgments
166
+
167
+ - FER-2013 dataset creators (Goodfellow et al., 2013)
168
+ - PyTorch and torchvision teams
169
+ - EfficientNet authors (Tan & Le, 2019)
170
+ - ONNX Runtime team
171
+ - Hugging Face for model hosting
172
+
173
+ ## References
174
+
175
+ - **Dataset**: [FER-2013 on Kaggle](https://www.kaggle.com/datasets/msambare/fer2013)
176
+ - **Original Paper**: Goodfellow, I. J., et al. (2013). Challenges in representation learning: A report on three machine learning contests. *Neural Networks*, 64, 59-63.
177
+ - **EfficientNet**: Tan, M., & Le, Q. V. (2019). EfficientNet: Rethinking model scaling for convolutional neural networks. *ICML*.
178
+