Commit ·
efae1c1
1
Parent(s): e4fc860
face expressions
Browse files
app/Hackathon_setup/exp_recognition.py
CHANGED
|
@@ -23,6 +23,7 @@ import torch.nn.functional as F
|
|
| 23 |
|
| 24 |
# Current_path stores absolute path of the file from where it runs.
|
| 25 |
current_path = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
#1) The below function is used to detect faces in the given image.
|
|
@@ -171,4 +172,4 @@ def get_expression(img):
|
|
| 171 |
probs = F.softmax(outputs, dim=1)
|
| 172 |
predicted_class = probs.argmax(dim=1).item()
|
| 173 |
|
| 174 |
-
return predicted_class
|
|
|
|
| 23 |
|
| 24 |
# Current_path stores absolute path of the file from where it runs.
|
| 25 |
current_path = os.path.dirname(os.path.abspath(__file__))
|
| 26 |
+
classes = {0: 'ANGER', 1: 'DISGUST', 2: 'FEAR', 3: 'HAPPINESS', 4: 'NEUTRAL', 5: 'SADNESS', 6: 'SURPRISE'}
|
| 27 |
|
| 28 |
|
| 29 |
#1) The below function is used to detect faces in the given image.
|
|
|
|
| 172 |
probs = F.softmax(outputs, dim=1)
|
| 173 |
predicted_class = probs.argmax(dim=1).item()
|
| 174 |
|
| 175 |
+
return classes[predicted_class]
|