From 0c8e86937133879ed1cab95eeb58e2b3848bb2a6 Mon Sep 17 00:00:00 2001 From: Sefik Ilkin Serengil Date: Fri, 22 Mar 2024 10:02:52 +0000 Subject: [PATCH 1/2] enforce tf 2.12 or less --- deepface/basemodels/FbDeepFace.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/deepface/basemodels/FbDeepFace.py b/deepface/basemodels/FbDeepFace.py index 5e41c7d2..278f5cce 100644 --- a/deepface/basemodels/FbDeepFace.py +++ b/deepface/basemodels/FbDeepFace.py @@ -23,7 +23,6 @@ Flatten, Dense, Dropout, - LocallyConnected2D, ) else: from tensorflow.keras.models import Model, Sequential @@ -33,7 +32,6 @@ Flatten, Dense, Dropout, - LocallyConnected2D, ) @@ -45,6 +43,14 @@ class DeepFaceClient(FacialRecognition): """ def __init__(self): + # DeepFace requires tf 2.12 or less + if tf_major == 2 and tf_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 {tf_major}.{tf_minor}. You need to downgrade your tf." + ) + self.model = load_model() self.model_name = "DeepFace" self.input_shape = (152, 152) @@ -69,6 +75,13 @@ def load_model( """ Construct DeepFace model, download its weights and load """ + # we have some checks for this dependency in the init of client + # putting this in global causes library initialization + if tf_major == 1: + from keras.layers import LocallyConnected2D + else: + from tensorflow.keras.layers import LocallyConnected2D + base_model = Sequential() base_model.add( Convolution2D(32, (11, 11), activation="relu", name="C1", input_shape=(152, 152, 3)) From 9957fe68128cb053fcf4a899a57210b05302fa23 Mon Sep 17 00:00:00 2001 From: Sefik Ilkin Serengil Date: Fri, 22 Mar 2024 10:10:50 +0000 Subject: [PATCH 2/2] new version --- deepface/__init__.py | 2 +- package_info.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deepface/__init__.py b/deepface/__init__.py index 8a5bfd7f..a20d2104 100644 --- a/deepface/__init__.py +++ b/deepface/__init__.py @@ -1 +1 @@ -__version__ = "0.0.88" +__version__ = "0.0.89" diff --git a/package_info.json b/package_info.json index a3a883e1..9eac2a23 100644 --- a/package_info.json +++ b/package_info.json @@ -1,3 +1,3 @@ { - "version": "0.0.88" + "version": "0.0.89" } \ No newline at end of file