serengil / deepface

A Lightweight Face Recognition and Facial Attribute Analysis (Age, Gender, Emotion and Race) Library for Python
https://bit.ly/deepface-py
MIT License
14.86k stars 2.24k forks source link

[BUG]: DeepFace is incompatible with 2.15.0 #1389

Open artinZareie opened 6 days ago

artinZareie commented 6 days ago

Before You Report a Bug, Please Confirm You Have Done The Following...

DeepFace's version

0.0.93

Python version

3.11.9

Operating System

Manjaro Linux x86_64

Dependencies

tensorflow: 2.15.0 keras: 2.15.0

absl-py==2.1.0 anyio @ file:///croot/anyio_1706220167567/work argon2-cffi @ file:///opt/conda/conda-bld/argon2-cffi_1645000214183/work argon2-cffi-bindings @ file:///work/ci_py311/argon2-cffi-bindings_1676823553406/work asttokens @ file:///opt/conda/conda-bld/asttokens_1646925590279/work astunparse==1.6.3 async-lru @ file:///croot/async-lru_1699554519285/work attrs @ file:///croot/attrs_1695717823297/work Babel @ file:///work/ci_py311/babel_1676825020543/work beautifulsoup4==4.11.1 bleach @ file:///opt/conda/conda-bld/bleach_1641577558959/work blinker==1.9.0 Brotli @ file:///croot/brotli-split_1714483155106/work cachetools==5.3.2 certifi @ file:///croot/certifi_1720453481653/work/certifi cffi @ file:///croot/cffi_1714483155441/work charset-normalizer==2.1.1 click==8.1.7 comm @ file:///croot/comm_1709322850197/work contourpy==1.2.0 cycler==0.12.1 debugpy @ file:///croot/debugpy_1690905042057/work decorator @ file:///opt/conda/conda-bld/decorator_1643638310831/work deepface==0.0.93 defusedxml @ file:///tmp/build/80754af9/defusedxml_1615228127516/work executing @ file:///opt/conda/conda-bld/executing_1646925071911/work fastjsonschema @ file:///work/ci_py311_2/python-fastjsonschema_1679340124475/work filelock==3.16.1 fire==0.7.0 Flask==3.1.0 Flask-Cors==5.0.0 flatbuffers==23.5.26 fonttools==4.47.2 gast==0.5.4 gdown==5.2.0 google-auth==2.27.0 google-auth-oauthlib==1.2.0 google-pasta==0.2.0 grpcio==1.60.0 gunicorn==23.0.0 h5py==3.10.0 idna @ file:///croot/idna_1714398848350/work imbalanced-learn==0.12.3 imblearn==0.0 install==1.3.5 ipykernel @ file:///croot/ipykernel_1705933831282/work ipython @ file:///croot/ipython_1718287989724/work itsdangerous==2.2.0 jedi @ file:///croot/jedi_1721058342488/work Jinja2 @ file:///croot/jinja2_1716993405101/work joblib==1.4.2 json5 @ file:///tmp/build/80754af9/json5_1624432770122/work jsonschema @ file:///croot/jsonschema_1699041609003/work jsonschema-specifications @ file:///croot/jsonschema-specifications_1699032386549/work jupyter-events @ file:///croot/jupyter_events_1718738097486/work jupyter-lsp @ file:///croot/jupyter-lsp-meta_1699978238815/work jupyter_client @ file:///croot/jupyter_client_1699455897726/work jupyter_core @ file:///croot/jupyter_core_1718818295206/work jupyter_server @ file:///croot/jupyter_server_1718827083372/work jupyter_server_terminals @ file:///croot/jupyter_server_terminals_1686870725608/work jupyterlab @ file:///croot/jupyterlab_1706802623017/work jupyterlab-pygments @ file:///tmp/build/80754af9/jupyterlab_pygments_1601490720602/work jupyterlab_server @ file:///croot/jupyterlab_server_1699555425460/work kaggle==1.6.17 keras==2.15.0 Keras-Applications==1.0.8 kiwisolver==1.4.5 libclang==16.0.6 lz4==4.3.3 Markdown==3.5.2 MarkupSafe==2.1.4 matplotlib==3.8.2 matplotlib-inline @ file:///work/ci_py311/matplotlib-inline_1676823841154/work mistune @ file:///work/ci_py311/mistune_1676823683049/work ml-dtypes==0.2.0 mlxtend==0.23.1 mtcnn==1.0.0 nbclient @ file:///croot/nbclient_1698934205032/work nbconvert @ file:///croot/nbconvert_1699022732553/work nbformat @ file:///croot/nbformat_1694616755618/work nest-asyncio @ file:///croot/nest-asyncio_1708532673751/work networkx==3.4.2 notebook_shim @ file:///croot/notebook-shim_1699455894279/work numpy==1.26.3 nvidia-cublas-cu12==12.2.5.6 nvidia-cuda-cupti-cu12==12.2.142 nvidia-cuda-nvcc-cu12==12.2.140 nvidia-cuda-nvrtc-cu12==12.2.140 nvidia-cuda-runtime-cu12==12.2.140 nvidia-cudnn-cu12==8.9.4.25 nvidia-cufft-cu12==11.0.8.103 nvidia-curand-cu12==10.3.3.141 nvidia-cusolver-cu12==11.5.2.141 nvidia-cusparse-cu12==12.1.2.141 nvidia-nccl-cu12==2.16.5 nvidia-nvjitlink-cu12==12.2.140 oauthlib==3.2.2 opencv-python==4.9.0.80 opt-einsum==3.3.0 overrides @ file:///croot/overrides_1699371140756/work packaging @ file:///croot/packaging_1720101850331/work pandas==2.2.0 pandocfilters @ file:///opt/conda/conda-bld/pandocfilters_1643405455980/work parso @ file:///opt/conda/conda-bld/parso_1641458642106/work patsy==0.5.6 persiantools==4.2.0 pexpect @ file:///tmp/build/80754af9/pexpect_1605563209008/work Pillow==9.3.0 platformdirs @ file:///croot/platformdirs_1692205439124/work prometheus-client @ file:///work/ci_py311_2/prometheus_client_1679340520168/work prompt-toolkit @ file:///croot/prompt-toolkit_1704404351921/work protobuf==4.23.4 psutil @ file:///work/ci_py311_2/psutil_1679337388738/work ptyprocess @ file:///tmp/build/80754af9/ptyprocess_1609355006118/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl pure-eval @ file:///opt/conda/conda-bld/pure_eval_1646925070566/work pyarrow==17.0.0 pyasn1==0.5.1 pyasn1-modules==0.3.0 pycparser @ file:///tmp/build/80754af9/pycparser_1636541352034/work Pygments @ file:///croot/pygments_1684279966437/work pyparsing==3.1.1 PySocks @ file:///work/ci_py311/pysocks_1676822712504/work python-dateutil @ file:///croot/python-dateutil_1716495738603/work python-json-logger @ file:///croot/python-json-logger_1683823803357/work python-slugify==8.0.4 pytz @ file:///croot/pytz_1713974312559/work PyYAML @ file:///croot/pyyaml_1698096049011/work pyzmq @ file:///croot/pyzmq_1705605076900/work referencing @ file:///croot/referencing_1699012038513/work requests==2.28.1 requests-oauthlib==1.3.1 retina-face==0.0.17 rfc3339-validator @ file:///croot/rfc3339-validator_1683077044675/work rfc3986-validator @ file:///croot/rfc3986-validator_1683058983515/work rpds-py @ file:///croot/rpds-py_1698945930462/work rsa==4.9 scikit-learn==1.4.0 scikit-plot==0.3.7 scipy==1.11.4 seaborn==0.13.2 Send2Trash @ file:///croot/send2trash_1699371139552/work six @ file:///tmp/build/80754af9/six_1644875935023/work sniffio @ file:///croot/sniffio_1705431295498/work soupsieve @ file:///croot/soupsieve_1696347547217/work stack-data @ file:///opt/conda/conda-bld/stack_data_1646927590127/work statsmodels==0.14.4 tensorboard==2.15.1 tensorboard-data-server==0.7.2 tensorflow==2.15.0.post1 tensorflow-addons==0.23.0 tensorflow-estimator==2.15.0 tensorflow-io-gcs-filesystem==0.35.0 termcolor==2.4.0 terminado @ file:///work/ci_py311/terminado_1677696151350/work text-unidecode==1.3 threadpoolctl==3.2.0 tinycss2 @ file:///work/ci_py311/tinycss2_1676823757641/work tornado @ file:///croot/tornado_1718740109488/work tqdm==4.64.1 traitlets @ file:///croot/traitlets_1718227057033/work typeguard==2.13.3 typing_extensions @ file:///croot/typing_extensions_1715268824938/work tzdata==2023.4 urllib3==1.26.19 validators==0.22.0 vit-keras==0.1.2 wcwidth @ file:///Users/ktietz/demo/mc3/conda-bld/wcwidth_1629357192024/work webencodings==0.5.1 websocket-client @ file:///croot/websocket-client_1715878298792/work Werkzeug==3.1.3 wrapt==1.14.1 xgboost==2.1.2

Reproducible example

from deepface import DeepFace

Relevant Log Output

024-11-22 20:13:41.904896: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable TF_ENABLE_ONEDNN_OPTS=0. 2024-11-22 20:13:41.926741: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered 2024-11-22 20:13:41.926761: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered 2024-11-22 20:13:41.927417: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered 2024-11-22 20:13:41.931375: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. 2024-11-22 20:13:42.309754: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT /home/aritn/.local/lib/python3.11/site-packages/requests/init.py:109: RequestsDependencyWarning: urllib3 (2.2.2) or chardet (None)/charset_normalizer (2.1.1) doesn't match a supported version! warnings.warn(

ModuleNotFoundError Traceback (most recent call last) Cell In[1], line 1 ----> 1 from deepface import DeepFace

File ~/anaconda3/envs/tensorflow/lib/python3.11/site-packages/deepface/DeepFace.py:20 18 from deepface.commons import package_utils, folder_utils 19 from deepface.commons.logger import Logger ---> 20 from deepface.modules import ( 21 modeling, 22 representation, 23 verification, 24 recognition, 25 demography, 26 detection, 27 streaming, 28 preprocessing, 29 ) 30 from deepface import version 32 logger = Logger()

File ~/anaconda3/envs/tensorflow/lib/python3.11/site-packages/deepface/modules/modeling.py:5 2 from typing import Any 4 # project dependencies ----> 5 from deepface.models.facial_recognition import ( 6 VGGFace, 7 OpenFace, 8 FbDeepFace, 9 DeepID, 10 ArcFace, 11 SFace, 12 Dlib, 13 Facenet, 14 GhostFaceNet, 15 ) 16 from deepface.models.face_detection import ( 17 FastMtCnn, 18 MediaPipe, (...) 26 CenterFace, 27 ) 28 from deepface.models.demography import Age, Gender, Race, Emotion

File ~/anaconda3/envs/tensorflow/lib/python3.11/site-packages/deepface/models/facial_recognition/VGGFace.py:6 4 import numpy as np 5 from deepface.commons import package_utils, folder_utils ----> 6 from deepface.modules import verification 7 from deepface.models.FacialRecognition import FacialRecognition 8 from deepface.commons.logger import Logger

File ~/anaconda3/envs/tensorflow/lib/python3.11/site-packages/deepface/modules/verification.py:9 6 import numpy as np 8 # project dependencies ----> 9 from deepface.modules import representation, detection, modeling 10 from deepface.models.FacialRecognition import FacialRecognition 11 from deepface.commons.logger import Logger

File ~/anaconda3/envs/tensorflow/lib/python3.11/site-packages/deepface/modules/representation.py:9 7 # project dependencies 8 from deepface.commons import image_utils ----> 9 from deepface.modules import modeling, detection, preprocessing 10 from deepface.models.FacialRecognition import FacialRecognition 13 def represent( 14 img_path: Union[str, np.ndarray], 15 model_name: str = "VGG-Face", (...) 22 max_faces: Optional[int] = None, 23 ) -> List[Dict[str, Any]]:

File ~/anaconda3/envs/tensorflow/lib/python3.11/site-packages/deepface/modules/preprocessing.py:16 14 from keras.preprocessing import image 15 elif tf_major_version == 2: ---> 16 from tensorflow.keras.preprocessing import image 19 def normalize_input(img: np.ndarray, normalization: str = "base") -> np.ndarray: 20 """Normalize input image. 21 22 Args: (...) 28 numpy array: the normalized image. 29 """

ModuleNotFoundError: No module named 'tensorflow.keras'

Expected Result

I expected the library to import without any problems.

What happened instead?

Got an error about tensorflow: ModuleNotFoundError: No module named 'tensorflow.keras'

Additional Info

No response