-
Notifications
You must be signed in to change notification settings - Fork 11
/
main.py
79 lines (61 loc) · 2.83 KB
/
main.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pathlib import Path
from loguru import logger
from processes import method, dataset
from tools.file_io import load_yaml_file
from tools.printing import init_loggers
from tools.argument_parsing import get_argument_parser
__author__ = 'Konstantinos Drossos -- Tampere University'
__docformat__ = 'reStructuredText'
__all__ = ['main']
def main():
args = get_argument_parser().parse_args()
file_dir = args.file_dir
config_file = args.config_file
file_ext = args.file_ext
verbose = args.verbose
settings = load_yaml_file(Path(
file_dir, f'{config_file}.{file_ext}'))
init_loggers(verbose=verbose,
settings=settings['dirs_and_files'])
logger_main = logger.bind(is_caption=False, indent=0)
logger_inner = logger.bind(is_caption=False, indent=1)
if settings['workflow']['dataset_creation']:
logger_main.info('Starting creation of dataset')
logger_inner.info('Creating examples')
dataset.create_dataset(
settings_dataset=settings['dataset_creation_settings'],
settings_dirs_and_files=settings['dirs_and_files'])
logger_inner.info('Examples created')
logger_inner.info('Extracting features')
dataset.extract_features(
root_dir=settings['dirs_and_files']['root_dirs']['data'],
settings_data=settings['dirs_and_files']['dataset'],
settings_features=settings['feature_extraction_settings'])
logger_inner.info('Features extracted')
logger_main.info('Creation of dataset ended')
if settings['workflow']['dnn_testing']:
# Create test dataset if not yet created
test_split_feat_dir = Path(settings['dirs_and_files']['root_dirs']['data']) \
.joinpath(settings['dirs_and_files']['dataset']['features_dirs']['output'],
settings['dirs_and_files']['dataset']['features_dirs']['test'])
if not test_split_feat_dir.exists():
logger_main.info('Starting creation of test dataset')
logger_inner.info('Extracting features')
dataset.extract_features_test(
root_dir=settings['dirs_and_files']['root_dirs']['data'],
settings_data=settings['dirs_and_files']['dataset'],
settings_features=settings['feature_extraction_settings'],
settings_audio=settings['dataset_creation_settings']['audio'])
logger_inner.info('Features extracted')
logger_main.info('Creation of test dataset ended')
else:
logger_inner.info('Found existing test data')
if settings['workflow']['dnn_training'] or \
settings['workflow']['dnn_evaluation'] or \
settings['workflow']['dnn_testing']:
method.method(settings)
if __name__ == '__main__':
main()
# EOF