forked from cmusatyalab/change-detection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_filelist_vlcmucd.py
68 lines (59 loc) · 1.89 KB
/
create_filelist_vlcmucd.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
'''
Create and save list of all file paths in the UCF dataset
To be used in the UCF dataset loader
'''
import argparse
import os
from pdb import set_trace as st
import pickle
def parse_args():
parser = argparse.ArgumentParser(description='Extract file lists from preprocessed paths')
parser.add_argument(
'--train',
help='location of VL-CMU-CD train folder',
default='./train',
type=str
)
parser.add_argument(
'--test',
help='location of VL-CMU-CD test folder',
default='./test',
type=str
)
parser.add_argument(
'--train_list',
help='location of VL-CMU-CD train dict',
default='./train/train.txt',
type=str
)
parser.add_argument(
'--test_list',
help='location of VL-CMU-CD test dict',
default='./test/test.txt',
type=str
)
return parser.parse_args()
def main(args):
train_dict = {}
train_dict['gt'] = []
train_dict['im1'] = []
train_dict['im2'] = []
for i, _ in enumerate(os.listdir(args.train + '/gt')):
train_dict['gt'].append(args.train + '/gt/gt' + str(i) + '.png')
train_dict['im1'].append(args.train + '/im1/1_im' + str(i) + '.png')
train_dict['im2'].append(args.train + '/im2/2_im' + str(i) + '.png')
test_dict = {}
test_dict['gt'] = []
test_dict['im1'] = []
test_dict['im2'] = []
for i, _ in enumerate(os.listdir(args.test + '/gt')):
test_dict['gt'].append(args.test + '/gt/gt' + str(i) + '.png')
test_dict['im1'].append(args.test + '/im1/1_im' + str(i) + '.png')
test_dict['im2'].append(args.test + '/im2/2_im' + str(i) + '.png')
with open(args.train_list, "wb") as fp:
pickle.dump(train_dict, fp)
with open(args.test_list, "wb") as fp:
pickle.dump(test_dict, fp)
if __name__ == '__main__':
args = parse_args()
main(args)