-
Notifications
You must be signed in to change notification settings - Fork 1
/
__centernet__.py
91 lines (67 loc) · 3.06 KB
/
__centernet__.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
80
81
82
83
84
85
86
87
88
89
90
91
import logging
import os
import absl.logging
import tensorflow as tf
from networks.classes.centernet.pipeline.Pipeline import CenterNetPipeline
from networks.classes.general_utilities.Logger import Logger
from networks.classes.general_utilities.Params import Params
def main():
# -- TENSORFLOW BASIC CONFIG ---
# Enable eager execution
tf.compat.v1.enable_eager_execution()
eager_exec_status = str('Yes') if tf.executing_eagerly() else str('No')
# Set up the log for tensorflow
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
# Remove absl logs
logging.root.removeHandler(absl.logging._absl_handler)
absl.logging._warn_preinit_stderr = False
# --- PARAMETERS INITIALIZATION ---
# Set the path to the configuration folder
config_path = os.path.join(os.getcwd(), 'networks', 'configuration')
# Set the path to experiments folder
base_experiments_path = os.path.join(os.getcwd(), 'networks', 'experiments')
# Load the model parameters from json file
centernet_params = Params(os.path.join(config_path, 'params_model_CenterNet.json'))
dataset_params = centernet_params.dataset
# Get the info for the current run
run_id = centernet_params.run_id
# --- LOGGERS ---
log_handler = Logger(run_id)
exe_log = log_handler.get_logger('execution')
train_log = log_handler.get_logger('training')
test_log = log_handler.get_logger('testing')
logs = {
'execution': exe_log,
'training': train_log,
'test': test_log
}
# Log configuration
exe_log.info('Software versions:')
exe_log.info('* Tensorflow version: ' + tf.__version__)
exe_log.info('* Keras version: ' + tf.__version__)
exe_log.info('* Executing eagerly? ' + eager_exec_status)
exe_log.info('General parameters:')
exe_log.info('* Model: CenterNet')
exe_log.info('* Training dataset: ' + dataset_params['train_images_path'])
exe_log.info('* Test dataset: ' + dataset_params['test_images_path'] + '\n')
# Log general and training parameters
log_handler.log_configuration(run_id, 'CenterNet', implementation=False)
# --- LEARNING PIPELINE --
# Initialize a learning pipeline for CenterNet
pipeline = CenterNetPipeline(dataset_params=dataset_params,
logs=logs)
common_operations = {
'preprocess': ['preprocessing'],
'detect': ['preprocessing', 'detection'],
'classify': ['preprocessing', 'detection', 'classification'],
'write_submission': ['preprocessing', 'detection', 'classification', 'submission'],
'test_submission': ['submission', 'test_submission'],
'test_bboxes': ['visualization'],
'all': ['preprocessing', 'detection', 'classification', 'submission', 'visualization']
}
# Run the pipeline
pipeline.run_pipeline(operations=common_operations['classify'],
params=centernet_params,
experiment_path=os.path.join(base_experiments_path, run_id))
if __name__ == '__main__':
main()