-
Notifications
You must be signed in to change notification settings - Fork 41
/
data_count.py
40 lines (34 loc) · 1.09 KB
/
data_count.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
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
''' Imports '''
import os
import collections
import argparse
import numpy as np
import sys
sys.path.insert(0, "lstm")
from Var import Var
''' Import argparse flags '''
parser = argparse.ArgumentParser("Data Counter")
parser.add_argument("--numFrames", "-f", dest="numFrames", default=4, type=int, help="required to access data")
args = parser.parse_args()
num_frames = args.numFrames
''' Create label and data directories '''
label_dir = "data/Labels/%d/" % (num_frames)
data_dir = "data/GestureData/%d/" % (num_frames)
v = Var()
classes = v.classes.values()
res = {}
for val in classes:
res[val] = 0
for label_name in os.listdir(label_dir):
if os.path.isdir(label_dir + label_name):
continue
label_file = open(label_dir + label_name)
num = label_name.split(".")[0].split("label")[-1]
data_name = data_dir + "gestureData%s.npz" % num
num_samples = np.load(data_name)['data'].item()[0].shape[0]
s = label_file.read()
for val in classes:
if s == val:
res[val] += num_samples
print(res)