-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathdatasets_video.py
69 lines (61 loc) · 2.62 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
import os
import torch
import torchvision
import torchvision.datasets as datasets
ROOT_DATASET= '/usr/home/kop/MFF-pytorch'
def return_jester(modality):
filename_categories = 'jester/category.txt'
filename_imglist_train = 'jester/train_videofolder.txt'
filename_imglist_val = 'jester/val_videofolder.txt'
if modality == 'RGB':
prefix = '{:05d}.jpg'
root_data = '/usr/home/kop/MFF-pytorch/datasets/jester'
elif modality == 'RGBFlow':
prefix = '{:05d}.jpg'
root_data = '/usr/home/kop/MFF-pytorch/datasets/jester'
else:
print('no such modality:'+modality)
os.exit()
return filename_categories, filename_imglist_train, filename_imglist_val, root_data, prefix
def return_nvgesture(modality):
filename_categories = 'nvgesture/category.txt'
filename_imglist_train = 'nvgesture/train_videofolder.txt'
filename_imglist_val = 'nvgesture/val_videofolder.txt'
if modality == 'RGB':
prefix = '{:05d}.jpg'
root_data = '/data2/nvGesture'
elif modality == 'RGBFlow':
prefix = '{:05d}.jpg'
root_data = '/data2/nvGesture'
else:
print('no such modality:'+modality)
os.exit()
return filename_categories, filename_imglist_train, filename_imglist_val, root_data, prefix
def return_chalearn(modality):
filename_categories = 'chalearn/category.txt'
filename_imglist_train = 'chalearn/train_videofolder.txt'
filename_imglist_val = 'chalearn/val_videofolder.txt'
#filename_imglist_val = 'chalearn/test_videofolder.txt'
if modality == 'RGB':
prefix = '{:05d}.jpg'
root_data = '/data2/ChaLearn'
elif modality == 'RGBFlow':
prefix = '{:05d}.jpg'
root_data = '/data2/ChaLearn'
else:
print('no such modality:'+modality)
os.exit()
return filename_categories, filename_imglist_train, filename_imglist_val, root_data, prefix
def return_dataset(dataset, modality):
dict_single = {'jester':return_jester, 'nvgesture': return_nvgesture, 'chalearn': return_chalearn}
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