From 0e2f34f8cfb499538dad9aa55617a75ef24b0815 Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Mon, 17 Feb 2020 12:46:00 +0100 Subject: [PATCH] Synchronize TensorFlow logging with --log_level flag --- DeepSpeech.py | 10 +++++++++- util/flags.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/DeepSpeech.py b/DeepSpeech.py index 27f801b9..96a8ba5c 100755 --- a/DeepSpeech.py +++ b/DeepSpeech.py @@ -6,7 +6,8 @@ import os import sys LOG_LEVEL_INDEX = sys.argv.index('--log_level') + 1 if '--log_level' in sys.argv else 0 -os.environ['TF_CPP_MIN_LOG_LEVEL'] = sys.argv[LOG_LEVEL_INDEX] if 0 < LOG_LEVEL_INDEX < len(sys.argv) else '3' +DESIRED_LOG_LEVEL = sys.argv[LOG_LEVEL_INDEX] if 0 < LOG_LEVEL_INDEX < len(sys.argv) else '3' +os.environ['TF_CPP_MIN_LOG_LEVEL'] = DESIRED_LOG_LEVEL import absl.app import json @@ -17,6 +18,13 @@ import tensorflow as tf import tensorflow.compat.v1 as tfv1 import time +tfv1.logging.set_verbosity({ + '0': tfv1.logging.DEBUG, + '1': tfv1.logging.INFO, + '2': tfv1.logging.WARN, + '3': tfv1.logging.ERROR +}.get(DESIRED_LOG_LEVEL)) + from datetime import datetime from ds_ctcdecoder import ctc_beam_search_decoder, Scorer from evaluate import evaluate diff --git a/util/flags.py b/util/flags.py index 5b5fee0d..6f3d1bea 100644 --- a/util/flags.py +++ b/util/flags.py @@ -119,7 +119,7 @@ def create_flags(): # Reporting - f.DEFINE_integer('log_level', 1, 'log level for console logs - 0: INFO, 1: WARN, 2: ERROR, 3: FATAL') + f.DEFINE_integer('log_level', 1, 'log level for console logs - 0: DEBUG, 1: INFO, 2: WARN, 3: ERROR') f.DEFINE_boolean('show_progressbar', True, 'Show progress for training, validation and testing processes. Log level should be > 0.') f.DEFINE_boolean('log_placement', False, 'whether to log device placement of the operators to the console')