1# Copyright Niantic 2019. Patent Pending. All rights reserved. 2# 3# This software is licensed under the terms of the Monodepth2 licence 4# which allows for non-commercial use only, the full terms of which are made 5# available in the LICENSE file. 6 7from __future__ import absolute_import, division, print_function 8 9import os 10import time 11import logging 12 13from trainer import Trainer 14from options import MonodepthOptions 15 16options = MonodepthOptions() 17opts = options.parse() 18 19if __name__ == "__main__": 20 # build logger 21 # logging and checkpoint saving 22 log_path = os.path.join(opts.log_dir, opts.model_zoo) 23 if not os.path.exists(log_path): 24 os.makedirs(log_path) 25 file_handler = logging.FileHandler(os.path.join(log_path, "train.log")) 26 stream_handler = logging.StreamHandler() 27 logger = logging.getLogger('') 28 logger.setLevel(logging.INFO) 29 logger.addHandler(file_handler) 30 logger.addHandler(stream_handler) 31 logger.info(opts) 32 33 trainer = Trainer(opts, logger) 34 35 tic = time.time() 36 trainer.train() 37 logger.info("Training Finished! Total training time is %dh %dm" % 38 (int((time.time() - tic) / 3600), int((time.time() - tic) % 3600 / 60))) 39