-
Notifications
You must be signed in to change notification settings - Fork 25
/
validation-sample.py
50 lines (43 loc) · 1.6 KB
/
validation-sample.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
'''
If you use your personal computer, often you will not have the performance needed to work on all this data.
this script will help you bring out a sample that you can work on.
if you want to work with all data, ignore this file.
'''
import csv
import shutil
def copyDirectory(src , dest):
try:
shutil.copytree(src, dest)
return 1
# Directories are the same
except shutil.Error as e:
print('Directory not copied. Error: %s' % e)
return 2
#Any error saying that the directory doesn't exist
except OSError as e:
print('Directory not copied. Error: %s' % e)
return 3
path_dest = 'validation_samples' # The folder where we will put all our validation samples
path_source = '20BN-JESTER' # The folder that contains all the data (Jester 20bn)
csv_file = 'data_csv/jester-v1-validation.csv' # validation csv file
file = open(csv_file, 'r')
reader = csv.reader(file, delimiter=';')
count = 0
simple = 500 # number of samples by class for validation
class_ = ['Thumb Up', 'Swiping Right', 'Sliding Two Fingers Left', 'No gesture'] # The classes we want to use
rows = []
for c in class_:
for line in reader:
target = line[1]
ref = line[0]
if target == c:
dep = copyDirectory(path_source+ref , path_dest+ref)
if dep == 1:
count += 1
rows.append([ref, target])
if count == simple:
break
# you can uncomment this code if you want to create your own csv for the samples
'''with open(path_dest+'validation.csv', 'wt') as f:
csv_writer = csv.writer(f, quoting = csv.QUOTE_ALL)
csv_writer.writerows(rows)'''