forked from gbrlfaria/rune-breaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.py
58 lines (41 loc) · 1.2 KB
/
common.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
import os
import re
# Classification
INPUT_SHAPE = (60, 60, 1)
CLASSES = ['down', 'left', 'right', 'up']
# Directories
DATA_DIR = './data/'
SAMPLES_DIR = DATA_DIR + 'samples/'
TRAINING_DIR = DATA_DIR + 'training/'
VALIDATION_DIR = DATA_DIR + 'validation/'
TESTING_DIR = DATA_DIR + 'testing/'
LABELED_DIR = DATA_DIR + 'labeled/'
PREPROCESSED_DIR = DATA_DIR + 'preprocessed/'
SCREENSHOTS_DIR = DATA_DIR + 'screenshots/'
MODEL_DIR = './model/'
# Functions
def get_files(directory):
result = []
for name in os.listdir(directory):
path = directory + name
if os.path.isfile(path):
result.append((path, name))
else:
result.extend(get_files(path + '/'))
return result
def arrow_labels(name):
tokens = re.split('_', name)
arrow_direction, arrow_type = tokens[1], tokens[0]
return arrow_direction, arrow_type
def create_directories():
directories = [
SCREENSHOTS_DIR,
LABELED_DIR,
PREPROCESSED_DIR,
SAMPLES_DIR
]
for d in [TRAINING_DIR, VALIDATION_DIR, TESTING_DIR]:
for c in CLASSES:
directories.append(d + c + '/')
for d in directories:
os.makedirs(d, exist_ok=True)