forked from rekon/T3D-keras
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_train_test_split.py
41 lines (30 loc) · 1.15 KB
/
make_train_test_split.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
from random import shuffle
import csv
import glob
action_classes = ['Cut-in', 'LanePass']
def create_csvs():
train = []
test = []
for myclass, directory in enumerate(action_classes):
for filename in glob.glob('data/train/{}/*.avi'.format(directory)):
train.append([filename, myclass, directory])
for myclass, directory in enumerate(action_classes):
for filename in glob.glob('data/test/{}/*.avi'.format(directory)):
test.append([filename, myclass, directory])
shuffle(train)
shuffle(test)
# print('train', len(total_train))
# print('test', len(total_test))
with open('train.csv', 'w') as csvfile:
mywriter = csv.writer(csvfile)
mywriter.writerow(['path', 'class', 'action'])
mywriter.writerows(train)
print('Training CSV file created successfully')
with open('test.csv', 'w') as csvfile:
mywriter = csv.writer(csvfile)
mywriter.writerow(['path', 'class', 'action'])
mywriter.writerows(test)
print('Testing CSV file created successfully')
print('CSV files created successfully')
if __name__ == "__main__":
create_csvs()