Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
21_22-J-02
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
21_22-J-02
21_22-J-02
Commits
cdc8ecba
Commit
cdc8ecba
authored
May 02, 2022
by
Kethmini Rupasinghe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change the code for Emotion detection video
parent
89892984
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
Presently/presently/users/emotiondetectionvideo.py
Presently/presently/users/emotiondetectionvideo.py
+6
-4
No files found.
Presently/presently/users/emotiondetectionvideo.py
View file @
cdc8ecba
...
@@ -5,7 +5,7 @@ import sys
...
@@ -5,7 +5,7 @@ import sys
import
pandas
as
pd
import
pandas
as
pd
import
numpy
as
np
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"
cascPath
=
"F:
\\
CDAP-PRESENTLY
\\
21_22-j-02
\\
Presently
\\
presently
\\
users
\\
models
\\
abc.xml"
def
_get_labels
():
def
_get_labels
():
...
@@ -68,9 +68,11 @@ from collections import OrderedDict
...
@@ -68,9 +68,11 @@ from collections import OrderedDict
from
matplotlib
import
pyplot
as
plt
from
matplotlib
import
pyplot
as
plt
import
cv2
import
cv2
from
tensorflow.keras.models
import
load_model
from
tensorflow.keras.models
import
load_model
def
detect_emotions
(
location_videofile
,
NumberofFrames
):
def
detect_emotions
(
location_videofile
,
NumberofFrames
):
PADDING
=
40
PADDING
=
40
NumberofFrames
=
50
emotion_labels
=
_get_labels
()
emotion_labels
=
_get_labels
()
arry
=
{}
arry
=
{}
...
@@ -126,7 +128,7 @@ def detect_emotions(location_videofile, NumberofFrames):
...
@@ -126,7 +128,7 @@ def detect_emotions(location_videofile, NumberofFrames):
except
Exception
as
e
:
except
Exception
as
e
:
continue
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
)
gray_face
=
np
.
expand_dims
(
np
.
expand_dims
(
gray_face
,
0
),
-
1
)
emotion_prediction
=
model
.
predict
(
gray_face
)[
0
]
emotion_prediction
=
model
.
predict
(
gray_face
)[
0
]
...
@@ -150,8 +152,8 @@ def detect_emotions(location_videofile, NumberofFrames):
...
@@ -150,8 +152,8 @@ def detect_emotions(location_videofile, NumberofFrames):
vidcap
.
release
()
vidcap
.
release
()
break
break
if
len
(
arry
)
==
0
:
if
len
(
arry
)
==
0
:
return
"
Cannot detect emotion"
,
arry
return
"
Neutral"
else
:
else
:
return
max
(
arry
,
key
=
arry
.
get
)
,
arry
return
max
(
arry
,
key
=
arry
.
get
)
emo
,
arr1
=
detect_emotions
(
location_videofile
,
300
)
emo
,
arr1
=
detect_emotions
(
location_videofile
,
300
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment