-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreating_vision_files-SDKalign.py
58 lines (49 loc) · 1.41 KB
/
creating_vision_files-SDKalign.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
45
46
47
48
49
50
51
52
53
54
55
56
# import cPickle as pickle
from mmdata import Dataloader, Dataset
import pickle
import pprint
import random
import os
import numpy as np
mosei=Dataloader('')
mosei_facet=mosei.facet()
mosei_covarep=mosei.covarep()
mosei_av=Dataset.merge(mosei_facet,mosei_covarep)
data=mosei_av.align('covarep')
train_data=mosei.train()
valid_data=mosei.valid()
test_data=mosei.test()
os.system("mkdir -p vision_files_align")
os.system("mkdir -p vision_files_align/train")
os.system("mkdir -p vision_files_align/val")
os.system("mkdir -p vision_files_align/test")
# for key,value in data.items():
for key,value in data.items():
if key != 'facet':
print('I am skipping '+key)
continue
else:
print('Start dumping '+key)
for key2,value2 in value.items():
if key2 in train_data:
folder_location = "./vision_files_align/train/"
elif key2 in valid_data:
folder_location = "./vision_files_align/val/"
else:
folder_location = "./vision_files_align/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