Merge pull request #1083 from serengil/feat-task-0902-enhancements

Feat task 0902 enhancements
This commit is contained in:
Sefik Ilkin Serengil 2024-03-09 21:16:51 +00:00 committed by GitHub
commit cdb0fa0b95
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 2 deletions

View File

@ -111,7 +111,7 @@ def verify(
- 'model' (str): The chosen face recognition model. - 'model' (str): The chosen face recognition model.
- 'similarity_metric' (str): The chosen similarity metric for measuring distances. - 'distance_metric' (str): The chosen similarity metric for measuring distances.
- 'facial_areas' (dict): Rectangular regions of interest for faces in both images. - 'facial_areas' (dict): Rectangular regions of interest for faces in both images.
- 'img1': {'x': int, 'y': int, 'w': int, 'h': int} - 'img1': {'x': int, 'y': int, 'w': int, 'h': int}

View File

@ -44,6 +44,15 @@ class DeepFaceClient(FacialRecognition):
""" """
def __init__(self): def __init__(self):
major = package_utils.get_tf_major_version()
minor = package_utils.get_tf_minor_version()
if major == 2 and minor > 12:
# Ref: https://github.com/serengil/deepface/pull/1079
raise ValueError(
"DeepFace model requires LocallyConnected2D but it is no longer supported"
f" after tf 2.12 but you have {major}.{minor}. You need to downgrade your tf."
)
self.model = load_model() self.model = load_model()
self.model_name = "DeepFace" self.model_name = "DeepFace"
self.input_shape = (152, 152) self.input_shape = (152, 152)

View File

@ -20,6 +20,15 @@ def get_tf_major_version() -> int:
return int(tf.__version__.split(".", maxsplit=1)[0]) return int(tf.__version__.split(".", maxsplit=1)[0])
def get_tf_minor_version() -> int:
"""
Find tensorflow's minor version
Returns
minor_version (int)
"""
return int(tf.__version__.split(".", maxsplit=-1)[1])
def find_hash_of_file(file_path: str) -> str: def find_hash_of_file(file_path: str) -> str:
""" """
Find the hash of given image file with its properties Find the hash of given image file with its properties

View File

@ -4,7 +4,7 @@ gdown>=3.10.1
tqdm>=4.30.0 tqdm>=4.30.0
Pillow>=5.2.0 Pillow>=5.2.0
opencv-python>=4.5.5.64 opencv-python>=4.5.5.64
tensorflow>=1.9.0,<=2.12.0 tensorflow>=1.9.0
keras>=2.2.0 keras>=2.2.0
Flask>=1.1.2 Flask>=1.1.2
mtcnn>=0.1.0 mtcnn>=0.1.0