-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathimage_data.py
More file actions
29 lines (25 loc) · 885 Bytes
/
image_data.py
File metadata and controls
29 lines (25 loc) · 885 Bytes
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
import numpy as np
import os
import matplotlib.image as mpimg
## floyd run --data bic2ggTB3rbGMTAvryPP5S:d1 --data chdojajSk9EFvbmZqDfohn:d2 "ls /d1; echo '******'; ls /d2"
## d1 train , d2 val
subset = 'val'
root = os.getcwd() + '/'
if subset == 'train':
data_root = root + 'Train_AFEW/AlignedFaces_LBPTOP_Points/Faces/'
else:
data_root = root + 'Val_AFEW/AlignedFaces_LBPTOP_Points_Val/Faces/'
data = {}
len1 = len(os.listdir(data_root))
c1, c2 = 1, 1
for file in sorted(os.listdir(data_root)):
data[file] = {}
len2 = len(os.listdir(data_root+file))
for frame in sorted(os.listdir(data_root+file)):
print('%d/%d %d/%d %s/%s' % (c1, len1, c2, len2, file, frame))
image = mpimg.imread(data_root+file+'/'+frame)
data[file][frame[:-4]] = image.copy()
c2 += 1
c1 += 1
c2 = 1
np.save('image_data_%s_%d.npy'%(subset,c1), data)