forked from zhoubolei/TRN-pytorch
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdatasets_video.py
129 lines (111 loc) · 5.74 KB
/
datasets_video.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import os
import torch
import torchvision
import torchvision.datasets as datasets
ROOT_DATASET = '/home/ubuntu/dvoitekh/TRN-pytorch/dataset'
def return_custom(modality):
filename_categories = 'category.txt'
if modality == 'RGB':
root_data = ROOT_DATASET
filename_imglist_train = 'train_videofolder.txt'
filename_imglist_val = 'val_videofolder.txt'
prefix = '{}.jpg'
else:
print('no such modality:'+modality)
os.exit()
return filename_categories, filename_imglist_train, filename_imglist_val, root_data, prefix
def return_something(modality):
filename_categories = 'something/category.txt'
if modality == 'RGB':
root_data = '/data/vision/oliva/scratch/bzhou/video/something-something/20bn-something-something-v1'
#root_data = '/mnt/localssd1/bzhou/something/20bn-something-something-v1'
filename_imglist_train = 'something/train_videofolder.txt'
filename_imglist_val = 'something/val_videofolder.txt'
prefix = '{:05d}.jpg'
elif modality == 'Flow':
root_data = '/data/vision/oliva/scratch/bzhou/video/something-something/flow'
#root_data = '/mnt/localssd1/bzhou/something/flow'
filename_imglist_train = 'something/train_videofolder.txt'
filename_imglist_val = 'something/val_videofolder.txt'
prefix = '{:05d}.jpg'
else:
print('no such modality:'+modality)
os.exit()
return filename_categories, filename_imglist_train, filename_imglist_val, root_data, prefix
def return_somethingv2(modality):
filename_categories = 'something/v2/category.txt'
if modality == 'RGB':
# root_data = '/data/vision/oliva/scratch/bzhou/video/something-something/v2/20bn-something-something-v2'
root_data = '/mnt/localssd2/aandonia/something/v2/20bn-something-something-v2-frames'
# root_data = '/mnt/localssd1/aandonia/something/v2/20bn-something-something-v2-frames'
filename_imglist_train = 'something/v2/train_videofolder.txt'
filename_imglist_val = 'something/v2/val_videofolder.txt'
prefix = '{:06d}.jpg'
elif modality == 'Flow':
#root_data = '/data/vision/oliva/scratch/bzhou/video/something-something/flow'
# root_data = '/mnt/localssd1/bzhou/something/flow'
root_data = '/mnt/localssd2/aandonia/something/v2/flow'
filename_imglist_train = 'something/v2/train_videofolder.txt'
filename_imglist_val = 'something/v2/val_videofolder.txt'
prefix = '{:06d}.jpg'
else:
print('no such modality:'+modality)
return filename_categories, filename_imglist_train, filename_imglist_val, root_data, prefix
def return_jester(modality):
filename_categories = 'jester/category.txt'
if modality == 'RGB':
prefix = '{:05d}.jpg'
#root_data = '/data/vision/oliva/scratch/bzhou/video/jester/20bn-jester-v1'
root_data = '/mnt/localssd1/bzhou/jester/20bn-jester-v1'
filename_imglist_train = 'jester/train_videofolder.txt'
filename_imglist_val = 'jester/val_videofolder.txt'
elif modality == 'Flow':
root_data = '/data/vision/oliva/scratch/bzhou/video/jester/flow'
#root_data = '/mnt/localssd1/bzhou/something/flow'
filename_imglist_train = 'jester/train_videofolder.txt'
filename_imglist_val = 'jester/val_videofolder.txt'
prefix = '{:05d}.jpg'
else:
print('no such modality:'+modality)
os.exit()
return filename_categories, filename_imglist_train, filename_imglist_val, root_data, prefix
def return_charades(modality):
filename_categories = 'charades/category.txt'
filename_imglist_train = 'charades/train_segments.txt'
filename_imglist_val = 'charades/test_segments.txt'
if modality == 'RGB':
prefix = '{:06d}.jpg'
root_data = '/data/vision/oliva/scratch/bzhou/charades/Charades_v1_rgb'
else:
print('no such modality:'+modality)
os.exit()
return filename_categories, filename_imglist_train, filename_imglist_val, root_data, prefix
def return_moments(modality):
filename_categories = '/data/vision/oliva/scratch/moments/split/categoryList_nov17.csv'
if modality == 'RGB':
prefix = '{:06d}.jpg'
root_data = '/data/vision/oliva/scratch/moments/moments_nov17_frames'
filename_imglist_train = '/data/vision/oliva/scratch/moments/split/rgb_trainingSet_nov17.csv'
filename_imglist_val = '/data/vision/oliva/scratch/moments/split/rgb_validationSet_nov17.csv'
elif modality == 'Flow':
root_data = '/data/vision/oliva/scratch/moments/moments_nov17_flow'
prefix = 'flow_xyz_{:05d}.jpg'
filename_imglist_train = '/data/vision/oliva/scratch/moments/split/flow_trainingSet_nov17.csv'
filename_imglist_val = '/data/vision/oliva/scratch/moments/split/flow_validationSet_nov17.csv'
else:
os.exit()
return filename_categories, filename_imglist_train, filename_imglist_val, root_data, prefix
def return_dataset(dataset, modality):
dict_single = {'jester': return_jester, 'something': return_something, 'somethingv2': return_somethingv2,
'charades': return_charades, 'moments': return_moments, 'custom': return_custom}
if dataset in dict_single:
file_categories, file_imglist_train, file_imglist_val, root_data, prefix = dict_single[dataset](modality)
else:
raise ValueError('Unknown dataset '+dataset)
file_imglist_train = os.path.join(ROOT_DATASET, file_imglist_train)
file_imglist_val = os.path.join(ROOT_DATASET, file_imglist_val)
file_categories = os.path.join(ROOT_DATASET, file_categories)
with open(file_categories) as f:
lines = f.readlines()
categories = [item.rstrip() for item in lines]
return categories, file_imglist_train, file_imglist_val, root_data, prefix