-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcheckout.py
46 lines (41 loc) · 1.22 KB
/
checkout.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
36
37
38
39
40
41
42
43
44
import cPickle as pickle
import pprint
import random
import os
import numpy as np
with open('facet.pkl', 'rb') as f:
data = pickle.load(f)
pp = pprint.PrettyPrinter(indent=4)
# pp.pprint(data[0])
# pp.pprint(len(data))
with open('train.pkl', 'rb') as f:
train_data = pickle.load(f)
with open('valid.pkl', 'rb') as f:
valid_data = pickle.load(f)
with open('test.pkl', 'rb') as f:
test_data = pickle.load(f)
for key,value in data.items():
pp.pprint(key)
for key2,value2 in value.items():
if key2 in train_data:
folder_location = "./Multimodal_Emotion_Analysis/vision_files/train/"
elif key2 in valid_data:
folder_location = "./Multimodal_Emotion_Analysis/vision_files/val/"
else:
folder_location = "./Multimodal_Emotion_Analysis/vision_files/test/"
video_name = key2
for key3,value3 in value2.items():
segment_id = key3
pickle_file = folder_location + video_name + '_' + segment_id + '.pkl'
print(pickle_file)
# print(value3[0][2])
for idx,frame in enumerate(value3):
if idx == 0:
facet_features = frame[2]
else:
facet_features = np.vstack((facet_features,frame[2]))
# pp.pprint(facet_features)
pickle.dump(facet_features, open(pickle_file, "wb" ))
# break
# break
# break