-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.py
35 lines (32 loc) · 1.31 KB
/
config.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
"""Configuration class that interfaces the config file."""
import json
import os
from hardware.hardware import Hardware
class Config(object):
DATA_FOLDER = "dataset"
NAME = "config.json"
def __init__(self, path):
# check if json file given or folder
if path[-5:] != ".json":
path = os.path.join(path, self.NAME)
with open(path) as file:
self.config = json.load(file)
self.label_configs = self.config['Actions']
self.labels = ["No gesture"]
for index, label_config in enumerate(self.config['Actions']):
self.labels.append(label_config['Name'])
self.labels.append("blank")
self.num_labels = len(self.labels)
self.hardware = Hardware(self.config['hardware'])
self.streams = self.hardware.from_module("STREAMS")
self.size = {}
for stream in self.streams:
width = self.hardware.from_module(stream + "_WIDTH")
height = self.hardware.from_module(stream + "_HEIGHT")
self.size[stream] = (width, height)
self.data_dir = os.path.join("datasets", self.hardware.name)
def dump(self, location):
"""Dump the current config."""
name = os.path.join(location, self.NAME)
with open(name, 'w') as out:
json.dump(self.config, out)