|
7 | 7 | import copy |
8 | 8 | import csv |
9 | 9 | import json |
10 | | -import logging as _logging |
11 | 10 | import os |
12 | 11 | import requests |
13 | 12 | import sys |
|
22 | 21 |
|
23 | 22 | from tensorflow.python.compiler.tensorrt import trt_convert as trt |
24 | 23 | from tensorflow.python.framework.errors_impl import OutOfRangeError |
| 24 | +from tensorflow.python.platform import tf_logging |
25 | 25 | from tensorflow.python.saved_model import signature_constants |
26 | 26 | from tensorflow.python.saved_model import tag_constants |
27 | 27 |
|
@@ -87,8 +87,19 @@ def __init__(self, args): |
87 | 87 | os.environ["NVIDIA_TF32_OVERRIDE"] = "0" |
88 | 88 |
|
89 | 89 | # Hide unnecessary TensorFlow DEBUG Python Logs |
90 | | - _logging.getLogger("tensorflow").setLevel(_logging.INFO) |
91 | | - _logging.disable(_logging.WARNING) |
| 90 | + tf_logger = tf_logging.get_logger() |
| 91 | + tf_logger.setLevel(tf_logging.INFO) |
| 92 | + tf_logger.propagate = False |
| 93 | + |
| 94 | + # disable TF warnings |
| 95 | + tf_logging.get_logger().warning = lambda *a, **kw: None |
| 96 | + tf_logging.get_logger().warn = lambda *a, **kw: None |
| 97 | + old_log = tf_logging.get_logger().log |
| 98 | + tf_logging.get_logger().log = lambda level, msg, *a, **kw: ( |
| 99 | + old_log(level, msg, *a, **kw) |
| 100 | + if level != tf_logging.WARN else |
| 101 | + None |
| 102 | + ) |
92 | 103 |
|
93 | 104 | # TensorFlow can execute operations synchronously or asynchronously. |
94 | 105 | # If asynchronous execution is enabled, operations may return |
|
0 commit comments