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
f7e311af
Commit
f7e311af
authored
Dec 19, 2017
by
Arne Gerdes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Und noch mehr Kommentare hinzugefügt
parent
4918b88e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
14 deletions
+52
-14
projectmood/image_sort.py
projectmood/image_sort.py
+52
-14
No files found.
projectmood/image_sort.py
View file @
f7e311af
"""
Diese Klasse sortiert die source_images anhand der source_emotions in die Ordner des sorted_set ein
"""
import
glob
from
shutil
import
copyfile
emotions
=
[
"neutral"
,
"anger"
,
"contempt"
,
"disgust"
,
"fear"
,
"happy"
,
"sadness"
,
"surprise"
]
# Emotionen - Reihenfolge wichtig!
participants
=
glob
.
glob
(
"basis_data/source_emotion/*"
)
# Eine Liste mit den Dateiordnern aller Teilnehmer
"""
Array der Emotionen
Gibt die Reihenfolge der Emotionen an (Labels von 0-7)
"""
emotions
=
[
"neutral"
,
"anger"
,
"contempt"
,
"disgust"
,
"fear"
,
"happy"
,
"sadness"
,
"surprise"
]
"""
Liste mit den Dateiordnern aller Teilnehmer
"""
participants
=
glob
.
glob
(
"basis_data/source_emotion/*"
)
for
x
in
participants
:
number
=
"%s"
%
x
[
-
4
:]
# Teilnehmernummer
"""
Teilnehmernummer
"""
number
=
"%s"
%
x
[
-
4
:]
for
sessions
in
glob
.
glob
(
"%s/*"
%
x
):
for
files
in
glob
.
glob
(
"%s/*"
%
sessions
):
current_session
=
files
[
31
:
-
30
]
# Sessionnummer
file
=
open
(
files
,
'r'
)
# Öffne die zur aktuellen Emotion korrelierende .txt Datei
"""
Sessionnummer
"""
current_session
=
files
[
31
:
-
30
]
emotion
=
int
(
float
(
file
.
readline
()))
# In der Datei steht die aktuell betrachtete Emotion, kodiert als float-Wert
"""
Öffnet die zur aktuellen Emotion korrelierende .txt Datei
"""
file
=
open
(
files
,
'r'
)
"""
In der Datei steht die aktuell betrachtete Emotion, kodiert als folat-Wert
"""
emotion
=
int
(
float
(
file
.
readline
()))
source_emotions
=
glob
.
glob
(
"basis_data/source_images/%s/%s/*.png"
%
(
number
,
current_session
))
source_emotions
.
sort
()
sourcefile_emotion
=
source_emotions
[
-
1
]
# Das letzte Bild einer Sequenz ist die ausgeprägte Emotion
sourcefile_neutral
=
source_emotions
[
0
]
# Das erste Bild ist ein neutraler Ausdruck
# Erstelle neue Pfade zum einsortieren
dest_neut
=
"basis_data/sorted_set/neutral/%s"
%
sourcefile_neutral
[
36
:]
# für den neutralen Ausdruck
dest_emot
=
"basis_data/sorted_set/%s/%s"
%
(
emotions
[
emotion
],
sourcefile_emotion
[
36
:])
# und die Emotion
"""
Das letzte Bild einer Sequenz ist eine ausgeprägte Emotion
"""
sourcefile_emotion
=
source_emotions
[
-
1
]
"""
Das erste Bild ist ein neutraler Ausdruck
"""
sourcefile_neutral
=
source_emotions
[
0
]
"""
Erstellt neue Pfade zum einsortieren
Für den neutralen Ausdruck
Für die Emotion
"""
dest_neut
=
"basis_data/sorted_set/neutral/%s"
%
sourcefile_neutral
[
36
:]
dest_emot
=
"basis_data/sorted_set/%s/%s"
%
(
emotions
[
emotion
],
sourcefile_emotion
[
36
:])
# Kopiere Dateien
"""Kopiert Dateien"""
copyfile
(
sourcefile_neutral
,
dest_neut
)
copyfile
(
sourcefile_emotion
,
dest_emot
)
\ No newline at end of file
copyfile
(
sourcefile_emotion
,
dest_emot
)
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