-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlistfile.py
35 lines (27 loc) · 889 Bytes
/
listfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
import os, glob
categoriesEitW = [ 'Angry' , 'Disgust' , 'Fear' , 'Happy' , 'Neutral' , 'Sad' , 'Surprise']
jaffe_categories_map = {
'HA': categoriesEitW.index('Happy'),
'SA': categoriesEitW.index('Sad'),
'NE': categoriesEitW.index('Neutral'),
'AN': categoriesEitW.index('Angry'),
'FE': categoriesEitW.index('Fear'),
'DI': categoriesEitW.index('Disgust'),
'SU': categoriesEitW.index('Surprise')
}
def get_label(fname):
label = fname.split('.')[1][0:2]
return jaffe_categories_map[label]
# File and label list to input to caffe
f = open('jaffe_list.txt', 'w')
# List of images to train on
dir = 'datasets/jaffe'
imgList = glob.glob(dir+'/*')
for img in imgList:
if os.path.isdir(img):
continue
label = get_label(img)
fname = img.split('/')[2]
f.write(fname + ' ' + str(label) + '\n')
f.close()