def set_system_verbosity(log_level): """ Set the verbosity level of tensorflow and suppresses future and deprecation warnings from any modules Parameters ---------- log_level: str The requested Faceswap log level References ---------- https://stackoverflow.com/questions/35911252/disable-tensorflow-debugging-information Can be set to: 0: all logs shown. 1: filter out INFO logs. 2: filter out WARNING logs. 3: filter out ERROR logs. """ logger = logging.getLogger(__name__) # pylint:disable=invalid-name from lib.logger import get_loglevel # pylint:disable=import-outside-toplevel numeric_level = get_loglevel(log_level) log_level = "3" if numeric_level > 15 else "0" logger.debug("System Verbosity level: %s", log_level) os.environ['TF_CPP_MIN_LOG_LEVEL'] = log_level if log_level != '0': for warncat in (FutureWarning, DeprecationWarning, UserWarning): warnings.simplefilter(action='ignore', category=warncat)
def __init__(self, reference_file_paths, nreference_file_paths, detector, aligner, loglevel, multiprocess=False, threshold=0.4): logger.debug( "Initializing %s: (reference_file_paths: %s, nreference_file_paths: %s, " "detector: %s, aligner: %s. loglevel: %s, multiprocess: %s, threshold: %s)", self.__class__.__name__, reference_file_paths, nreference_file_paths, detector, aligner, loglevel, multiprocess, threshold) git_model_id = 7 model_filename = ["vgg_face_v1.caffemodel", "vgg_face_v1.prototxt"] self.input_size = 224 self.numeric_loglevel = get_loglevel(loglevel) self.vgg_face = self.get_model(git_model_id, model_filename) self.filters = self.load_images(reference_file_paths, nreference_file_paths) self.align_faces(detector, aligner, loglevel, multiprocess) self.get_filter_encodings() self.threshold = threshold logger.debug("Initialized %s", self.__class__.__name__)
def __init__(self, reference_file_paths, nreference_file_paths, detector, aligner, loglevel, multiprocess=False, threshold=0.4): logger.debug("Initializing %s: (reference_file_paths: %s, nreference_file_paths: %s, " "detector: %s, aligner: %s. loglevel: %s, multiprocess: %s, threshold: %s)", self.__class__.__name__, reference_file_paths, nreference_file_paths, detector, aligner, loglevel, multiprocess, threshold) self.numeric_loglevel = get_loglevel(loglevel) self.vgg_face = VGGFace() self.filters = self.load_images(reference_file_paths, nreference_file_paths) self.align_faces(detector, aligner, loglevel, multiprocess) self.get_filter_encodings() self.threshold = threshold logger.debug("Initialized %s", self.__class__.__name__)
def set_system_verbosity(loglevel): """ Set the verbosity level of tensorflow and suppresses future and deprecation warnings from any modules From: https://stackoverflow.com/questions/35911252/disable-tensorflow-debugging-information Can be set to: 0 - all logs shown 1 - filter out INFO logs 2 - filter out WARNING logs 3 - filter out ERROR logs """ numeric_level = get_loglevel(loglevel) loglevel = "2" if numeric_level > 15 else "0" logger.debug("System Verbosity level: %s", loglevel) os.environ['TF_CPP_MIN_LOG_LEVEL'] = loglevel if loglevel != '0': for warncat in (FutureWarning, DeprecationWarning, UserWarning): warnings.simplefilter(action='ignore', category=warncat)