Commit 63320e11 authored by Wandana RAK - IT18227550's avatar Wandana RAK - IT18227550

Merge branch 'feat/it18227550' into 'develop'

Change the code for Emotion detection video

See merge request !55
parents 89892984 cdc8ecba
......@@ -5,7 +5,7 @@ import sys
import pandas as pd
import numpy as np
location_videofile = "F:\\CDAP-PRESENTLY\\21_22-j-02\\Presently\\presently\\media\\video\\22\\publicspeech.mp4"
location_videofile = "F:\\CDAP-PRESENTLY\\21_22-j-02\\Presently\\presently\\media\\video\\22\\testvideo.mp4"
cascPath = "F:\\CDAP-PRESENTLY\\21_22-j-02\\Presently\\presently\\users\\models\\abc.xml"
def _get_labels():
......@@ -68,9 +68,11 @@ from collections import OrderedDict
from matplotlib import pyplot as plt
import cv2
from tensorflow.keras.models import load_model
def detect_emotions(location_videofile, NumberofFrames):
PADDING = 40
NumberofFrames = 50
emotion_labels = _get_labels()
arry = {}
......@@ -126,7 +128,7 @@ def detect_emotions(location_videofile, NumberofFrames):
except Exception as e:
continue
gray_face = __preprocess_input(gray_face, True)
#gray_face = __preprocess_input(gray_face, True)
gray_face = np.expand_dims(np.expand_dims(gray_face, 0), -1)
emotion_prediction = model.predict(gray_face)[0]
......@@ -150,8 +152,8 @@ def detect_emotions(location_videofile, NumberofFrames):
vidcap.release()
break
if len(arry) == 0:
return "Cannot detect emotion", arry
return "Neutral"
else:
return max(arry, key=arry.get), arry
return max(arry, key=arry.get)
emo, arr1 = detect_emotions(location_videofile, 300)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment