Skip to content

Commit

Permalink
Merge pull request serengil#1083 from serengil/feat-task-0902-enhance…
Browse files Browse the repository at this point in the history
…ments

Feat task 0902 enhancements
  • Loading branch information
serengil authored Mar 9, 2024
2 parents 46f0141 + ca4bd25 commit cdb0fa0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion deepface/DeepFace.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def verify(
- '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.
- 'img1': {'x': int, 'y': int, 'w': int, 'h': int}
Expand Down
9 changes: 9 additions & 0 deletions deepface/basemodels/FbDeepFace.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ class DeepFaceClient(FacialRecognition):
"""

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_name = "DeepFace"
self.input_shape = (152, 152)
Expand Down
9 changes: 9 additions & 0 deletions deepface/commons/package_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ def get_tf_major_version() -> int:
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:
"""
Find the hash of given image file with its properties
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ gdown>=3.10.1
tqdm>=4.30.0
Pillow>=5.2.0
opencv-python>=4.5.5.64
tensorflow>=1.9.0,<=2.12.0
tensorflow>=1.9.0
keras>=2.2.0
Flask>=1.1.2
mtcnn>=0.1.0
Expand Down

0 comments on commit cdb0fa0

Please sign in to comment.