From b0f152ab3124c5a7e8f2a915571862a218d0eebf Mon Sep 17 00:00:00 2001 From: Sefik Ilkin Serengil Date: Sun, 11 Apr 2021 14:25:22 +0300 Subject: [PATCH] ignore tf2 warnings --- deepface/DeepFace.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/deepface/DeepFace.py b/deepface/DeepFace.py index 579a2f9..a8eb95f 100644 --- a/deepface/DeepFace.py +++ b/deepface/DeepFace.py @@ -1,7 +1,11 @@ import warnings warnings.filterwarnings("ignore") -import time + import os +#os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' +os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' + +import time from os import path import numpy as np import pandas as pd @@ -12,6 +16,12 @@ from deepface.basemodels import VGGFace, OpenFace, Facenet, FbDeepFace, DeepID, from deepface.extendedmodels import Age, Gender, Race, Emotion from deepface.commons import functions, realtime, distance as dst +import tensorflow as tf +tf_version = int(tf.__version__.split(".")[0]) +if tf_version == 2: + import logging + tf.get_logger().setLevel(logging.ERROR) + def build_model(model_name): """ @@ -596,7 +606,7 @@ def find(img_path, db_path, model_name ='VGG-Face', distance_metric = 'cosine', for j in model_names: custom_model = models[j] - + target_representation = represent(img_path = img_path , model_name = model_name, model = custom_model , enforce_detection = enforce_detection, detector_backend =detector_backend) @@ -720,11 +730,13 @@ def represent(img_path, model_name = 'VGG-Face', model = None, enforce_detection #decide input shape input_shape = input_shape_x, input_shape_y= functions.find_input_shape(model) + #detect and align img = functions.preprocess_face(img = img_path , target_size=(input_shape_y, input_shape_x) , enforce_detection = enforce_detection , detector_backend = detector_backend) + #represent embedding = model.predict(img)[0].tolist() return embedding