Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
medienverarbeitung17.projectmood
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Frank Tjado Ihmels
medienverarbeitung17.projectmood
Commits
7a36fef0
Commit
7a36fef0
authored
Dec 06, 2017
by
tihmels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nachbesserung Sorted_set
parent
5545121a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
projectmood/process_model.py
projectmood/process_model.py
+19
-6
No files found.
projectmood/process_model.py
View file @
7a36fef0
...
...
@@ -2,15 +2,19 @@ import cv2
import
glob
import
random
import
numpy
as
np
import
logging
import
sys
import
signal
emotions
=
[
"neutral"
,
"anger"
,
"disgust"
,
"happy"
,
"surprise"
]
# Emotion list
fishface
=
cv2
.
face
.
FisherFaceRecognizer_create
()
data
=
{}
logging
.
basicConfig
(
level
=
logging
.
DEBUG
,
format
=
'%(asctime)s %(name)-12s %(levelname)-8s %(message)s'
,
datefmt
=
'%m-%d %H:%M'
,
filename
=
'logs/process_model.log'
)
emotions
=
[
"anger"
,
"disgust"
,
"happy"
,
"neutral"
,
"surprise"
]
# Emotion list
fishface
=
cv2
.
face
.
FisherFaceRecognizer_create
()
def
get_files
(
emotion
):
# Define function to get file list, randomly shuffle it and split 80/20
files
=
glob
.
glob
(
"Basis_data
\\
dataset
\\
%s
\\
*"
%
emotion
)
files
=
glob
.
glob
(
'Basis_data/dataset/%s/*'
%
emotion
)
random
.
shuffle
(
files
)
training
=
files
[:
int
(
len
(
files
)
*
0.8
)]
# get first 80% of file list
prediction
=
files
[
-
int
(
len
(
files
)
*
0.2
):]
# get last 20% of file list
...
...
@@ -37,6 +41,7 @@ def make_sets():
prediction_data
.
append
(
gray
)
prediction_labels
.
append
(
emotions
.
index
(
emotion
))
return
training_data
,
training_labels
,
prediction_data
,
prediction_labels
...
...
@@ -64,11 +69,19 @@ def run_recognizer():
# Now run it
metascore
=
[]
logging
.
debug
(
"fisherface training initialized"
)
for
i
in
range
(
0
,
10
):
correct
=
run_recognizer
()
print
(
"got"
,
correct
,
"percent correct!"
)
metascore
.
append
(
correct
)
print
(
"
\n\n
end score:"
,
np
.
mean
(
metascore
),
"percent correct!"
)
print
(
"
\n
end score:"
,
np
.
mean
(
metascore
),
"percent correct!"
)
logging
.
info
(
"finished {} iterations:"
.
format
(
len
(
metascore
)))
for
idx
,
meta
in
enumerate
(
metascore
):
logging
.
debug
(
"{} : {}%"
.
format
(
idx
,
meta
))
logging
.
debug
(
"fisherface finished with {}%
\n
"
.
format
(
np
.
mean
(
metascore
)))
fishface
.
write
(
'Basis_data/models/detection_model.xml'
)
\ No newline at end of file
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