-
Notifications
You must be signed in to change notification settings - Fork 1
/
__yolo__.py
74 lines (50 loc) · 2.03 KB
/
__yolo__.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
import logging
import os
import absl.logging
import tensorflow as tf
from networks.classes.general_utilities.Logger import Logger
from networks.classes.yolo.ModelYOLO import ModelYOLO
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.compat.v1.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
# --- GENERAL PARAMETERS ---
# Set the path to the configuration folder
config_path = os.path.join(os.getcwd(), 'networks', 'configuration')
# Load the training parameters from json file
model_params = Params(os.path.join(config_path, 'params_model_YOLO.json'))
# Get the info for the current run
run_id = model_params.run_id
# --- LOGGER ---
log_handler = Logger(run_id)
log = log_handler.get_logger('execution')
# Log configuration
log.info('Software versions:')
log.info('* Tensorflow version: ' + tf.__version__)
log.info('* Keras version: ' + tf.__version__)
log.info('* Executing eagerly? ' + eager_exec_status)
log.info('General parameters:')
log.info('* Model: YOLO')
log.info('* Training dataset: ' + model_params.dataset + '\n')
# Log general and training parameters
log_handler.log_configuration(run_id, 'YOLO', implementation=False)
# --- MODEL ---
log.info('Building the model...')
# Build the model
model = ModelYOLO(run_id, model_params, log_handler)
# --- TRAINING ---
# Train the model
if model_params.train:
log.info('Starting the training procedure...')
model.train()
log.info('Testing the model against an image in the training set...')
model.predict()
if __name__ == '__main__':
main()