Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/emotion.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions emotion/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions emotion/.idea/emotion.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions emotion/.idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions emotion/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions emotion/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions emotion/Emotional_recoLITE.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do need these imports for?


import cv2
import numpy as np

from PIL import Image

import tensorflow as tf

def init():
global labels
global interpreter

labels = ['Angry', 'Disgusted', 'Fear', 'Happy', 'Neutral', 'Sad', 'Surprised']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make an Arabic copy of the labels; detect should return an Arabic result.

interpreter = tf.lite.Interpreter(model_path="model.tflite")
interpreter.allocate_tensors()



def detect(image):
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
height = 48
width = 48
data = image
gray = (np.float32(data), cv2.COLOR_RGB2GRAY)
data = np.array(gray)
data = data.resize((width, height))


interpreter.invoke()

output_data = interpreter.get_tensor(output_details[0]['index'])
results = np.squeeze(output_data)
top_percentage = results.argsort()[-1:][::-1]

for i in top_percentage:

print('{:08.6f}: {}'.format(float(results[i]), labels[i]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

detect should return the result, not print it. if the model returns multiple results return the fittest one.


if __name__ == '__main__':

init()
img = Image.open('sad.jpg')
detect(img)
3 changes: 2 additions & 1 deletion emotion/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#Facial Emotion Sensing
# Facial Expression Recognition

Binary file added emotion/emojis/Angry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added emotion/emojis/Fear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added emotion/emojis/Happy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added emotion/emojis/Neutral.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added emotion/emojis/Sad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added emotion/emojis/Surprised.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added emotion/model.tflite
Binary file not shown.
Binary file added emotion/model/emotion_best_weights.h5
Binary file not shown.
Binary file added emotion/model/emotion_recognition.h5
Binary file not shown.
Loading