Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-060
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
2021-060
2021-060
Commits
8ca84f52
Commit
8ca84f52
authored
Nov 23, 2021
by
Dhananjaya Jayashanka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changers done
parent
65f680f9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
9 deletions
+11
-9
Emotion/emotions.txt
Emotion/emotions.txt
+2
-0
Emotion/videoAnalyzing.py
Emotion/videoAnalyzing.py
+5
-7
UI/application.js
UI/application.js
+4
-2
No files found.
Emotion/emotions.txt
View file @
8ca84f52
...
@@ -20,7 +20,9 @@
...
@@ -20,7 +20,9 @@
'oppressed': 'Angry',
'oppressed': 'Angry',
'anguished': 'Sad',
'anguished': 'Sad',
'animated': 'Happy',
'animated': 'Happy',
'happen': 'Sad',
'annoyed': 'Angry',
'annoyed': 'Angry',
'simply': 'Angry',
'appalled': 'Angry',
'appalled': 'Angry',
'beatific': 'Happy',
'beatific': 'Happy',
'bereaved': 'Sad',
'bereaved': 'Sad',
...
...
Emotion/videoAnalyzing.py
View file @
8ca84f52
#
from skimage import io
#
Import useful libraries
import
cv2
import
cv2
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
numpy
as
np
import
tensorflow
as
tf
import
tensorflow
as
tf
from
keras.preprocessing
import
image
from
keras.preprocessing
import
image
#Load the trained model
Saved_model
=
tf
.
keras
.
models
.
load_model
(
'emotion_lts.h5'
)
Saved_model
=
tf
.
keras
.
models
.
load_model
(
'emotion_lts.h5'
)
Saved_model
.
summary
()
Saved_model
.
summary
()
#Prediction categories
objects
=
(
'Angry'
,
'Happy'
,
'Sad'
,
'Neutral'
)
objects
=
(
'Angry'
,
'Happy'
,
'Sad'
,
'Neutral'
)
vid
=
cv2
.
VideoCapture
(
0
)
vid
=
cv2
.
VideoCapture
(
0
)
...
@@ -21,16 +23,15 @@ def emotion_analysis(emotions):
...
@@ -21,16 +23,15 @@ def emotion_analysis(emotions):
plt
.
ylabel
(
'percentage'
)
plt
.
ylabel
(
'percentage'
)
plt
.
title
(
'emotion'
)
plt
.
title
(
'emotion'
)
#Predict facial expressions
def
get_emotions
(
filePath
):
def
get_emotions
(
filePath
):
cap
=
cv2
.
VideoCapture
(
filePath
)
cap
=
cv2
.
VideoCapture
(
filePath
)
emotions
=
[]
emotions
=
[]
#Define emotion list
while
(
cap
.
isOpened
()):
while
(
cap
.
isOpened
()):
try
:
try
:
ret
,
frame
=
cap
.
read
()
ret
,
frame
=
cap
.
read
()
# img = image.load_img(frame,grayscale=True, target_size=(48, 48))
frame
=
cv2
.
resize
(
frame
,
(
48
,
48
))
frame
=
cv2
.
resize
(
frame
,
(
48
,
48
))
frame
=
cv2
.
cvtColor
(
frame
,
cv2
.
COLOR_BGR2GRAY
)
frame
=
cv2
.
cvtColor
(
frame
,
cv2
.
COLOR_BGR2GRAY
)
x
=
image
.
img_to_array
(
frame
)
x
=
image
.
img_to_array
(
frame
)
...
@@ -39,12 +40,9 @@ def get_emotions(filePath):
...
@@ -39,12 +40,9 @@ def get_emotions(filePath):
x
/=
255
x
/=
255
custom
=
Saved_model
.
predict
(
x
)
custom
=
Saved_model
.
predict
(
x
)
# print(custom[0])
emotion_analysis
(
custom
[
0
])
emotion_analysis
(
custom
[
0
])
x
=
np
.
array
(
x
,
'float32'
)
x
=
np
.
array
(
x
,
'float32'
)
x
=
x
.
reshape
([
48
,
48
]);
x
=
x
.
reshape
([
48
,
48
]);
m
=
0.000000000000000000001
m
=
0.000000000000000000001
a
=
custom
[
0
]
a
=
custom
[
0
]
for
i
in
range
(
0
,
len
(
a
)):
for
i
in
range
(
0
,
len
(
a
)):
...
...
UI/application.js
View file @
8ca84f52
...
@@ -53,6 +53,7 @@ app.controller('MainController', ['$scope', '$rootScope', '$location', '$route',
...
@@ -53,6 +53,7 @@ app.controller('MainController', ['$scope', '$rootScope', '$location', '$route',
});
});
}
}
//facial expression diagram
$scope
.
selectVideoFile
=
function
(
e
)
{
$scope
.
selectVideoFile
=
function
(
e
)
{
$scope
.
chartLabels
=
[];
$scope
.
chartLabels
=
[];
$scope
.
chartdata
=
[];
$scope
.
chartdata
=
[];
...
@@ -136,7 +137,7 @@ app.controller('MainController', ['$scope', '$rootScope', '$location', '$route',
...
@@ -136,7 +137,7 @@ app.controller('MainController', ['$scope', '$rootScope', '$location', '$route',
console
.
log
(
error
);
console
.
log
(
error
);
});
});
//emotion graph
//emotion graph text analyzing
MainFactory
.
emotionSentence
({
text
:
$scope
.
audioText
})
MainFactory
.
emotionSentence
({
text
:
$scope
.
audioText
})
.
then
(
function
(
response
)
{
.
then
(
function
(
response
)
{
console
.
log
(
response
.
data
);
console
.
log
(
response
.
data
);
...
@@ -152,7 +153,6 @@ app.controller('MainController', ['$scope', '$rootScope', '$location', '$route',
...
@@ -152,7 +153,6 @@ app.controller('MainController', ['$scope', '$rootScope', '$location', '$route',
$scope
.
chartdata
=
[];
$scope
.
chartdata
=
[];
for
(
let
i
=
0
;
i
<
$scope
.
emotions
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
$scope
.
emotions
.
length
;
i
++
)
{
// $scope.chartLabels.push(i+1);
if
(
$scope
.
emotions
[
i
]
==
'
Angry
'
)
{
if
(
$scope
.
emotions
[
i
]
==
'
Angry
'
)
{
$scope
.
chartdata
.
push
(
1
);
$scope
.
chartdata
.
push
(
1
);
$scope
.
emotionScore
+=
0.25
;
$scope
.
emotionScore
+=
0.25
;
...
@@ -288,6 +288,8 @@ app.controller('MainController', ['$scope', '$rootScope', '$location', '$route',
...
@@ -288,6 +288,8 @@ app.controller('MainController', ['$scope', '$rootScope', '$location', '$route',
console
.
log
(
error
);
console
.
log
(
error
);
});
});
//comparison between the expression prediction results and emotional moment results
MainFactory
.
textAnalyzeEmotion
({
text
:
$scope
.
audioText
})
MainFactory
.
textAnalyzeEmotion
({
text
:
$scope
.
audioText
})
.
then
(
function
(
response
)
{
.
then
(
function
(
response
)
{
console
.
log
(
response
);
console
.
log
(
response
);
...
...
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