Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing tensorflow before deepface breaks it #1390

Open
2 tasks done
jbellis opened this issue Nov 26, 2024 · 1 comment
Open
2 tasks done

Importing tensorflow before deepface breaks it #1390

jbellis opened this issue Nov 26, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@jbellis
Copy link

jbellis commented Nov 26, 2024

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

  • I have updated to the latest version of the packages.
  • I have searched for both existing issues and closed issues and found none that matched my issue.

DeepFace's version

v.0.0.94 [git sha be99b00]

Python version

3.10

Operating System

Windows 10 / WSL2 / Ubuntu 22.04

Dependencies

absl-py==2.1.0
astunparse==1.6.3
beautifulsoup4==4.12.3
blinker==1.9.0
cachetools==5.5.0
certifi==2024.8.30
charset-normalizer==3.4.0
click==8.1.7
deepface @ file:///home/jonathan/Projects/deepface
filelock==3.16.1
fire==0.7.0
Flask==3.1.0
Flask-Cors==5.0.0
flatbuffers==24.3.25
gast==0.6.0
gdown==5.2.0
google-auth==2.36.0
google-auth-oauthlib==1.0.0
google-pasta==0.2.0
grpcio==1.68.0
gunicorn==23.0.0
h5py==3.12.1
idna==3.10
itsdangerous==2.2.0
Jinja2==3.1.4
joblib==1.4.2
keras==3.6.0
libclang==18.1.1
lz4==4.3.3
Markdown==3.7
markdown-it-py==3.0.0
MarkupSafe==3.0.2
mdurl==0.1.2
ml-dtypes==0.4.1
mtcnn==1.0.0
namex==0.0.8
numpy==1.26.4
oauthlib==3.2.2
opencv-python==4.10.0.84
opt_einsum==3.4.0
optree==0.13.1
packaging==24.2
pandas==2.2.3
pillow==11.0.0
protobuf==4.25.5
pyasn1==0.6.1
pyasn1_modules==0.4.1
Pygments==2.18.0
PySocks==1.7.1
python-dateutil==2.9.0.post0
pytz==2024.2
requests==2.32.3
requests-oauthlib==2.0.0
retina-face==0.0.17
rich==13.9.4
rsa==4.9
scikit-learn==1.5.2
scipy==1.14.1
six==1.16.0
soupsieve==2.6
tensorboard==2.18.0
tensorboard-data-server==0.7.2
tensorflow==2.18.0
tensorflow-estimator==2.14.0
tensorflow-io-gcs-filesystem==0.37.1
termcolor==2.5.0
tf_keras==2.18.0
threadpoolctl==3.5.0
tqdm==4.67.1
typing_extensions==4.12.2
tzdata==2024.2
urllib3==2.2.3
Werkzeug==3.1.3
wrapt==1.14.1

Reproducible example

import tensorflow as tf

from deepface import DeepFace
import sys

image_path = sys.argv[1]
# Attempt to get face embedding
embedding_objs = DeepFace.represent(
    img_path=str(image_path),
    enforce_detection=True,
    detector_backend='retinaface'
)
print(embedding_objs)

Relevant Log Output

Traceback (most recent call last):
File "/home/jonathan/Projects/randomphoto/test.py", line 9, in
embedding_objs = DeepFace.represent(
File "/home/jonathan/miniforge3/envs/randomphoto-rf/lib/python3.10/site-packages/deepface/DeepFace.py", line 430, in represent
return representation.represent(
File "/home/jonathan/miniforge3/envs/randomphoto-rf/lib/python3.10/site-packages/deepface/modules/representation.py", line 68, in represent
model: FacialRecognition = modeling.build_model(
File "/home/jonathan/miniforge3/envs/randomphoto-rf/lib/python3.10/site-packages/deepface/modules/modeling.py", line 96, in build_model
cached_models[task][model_name] = model()
File "/home/jonathan/miniforge3/envs/randomphoto-rf/lib/python3.10/site-packages/deepface/models/facial_recognition/VGGFace.py", line 52, in init
self.model = load_model()
File "/home/jonathan/miniforge3/envs/randomphoto-rf/lib/python3.10/site-packages/deepface/models/facial_recognition/VGGFace.py", line 161, in load_model
vgg_face_descriptor = Model(inputs=model.input, outputs=base_model_output)
File "/home/jonathan/miniforge3/envs/randomphoto-rf/lib/python3.10/site-packages/keras/src/ops/operation.py", line 254, in input
return self._get_node_attribute_at_index(0, "input_tensors", "input")
File "/home/jonathan/miniforge3/envs/randomphoto-rf/lib/python3.10/site-packages/keras/src/ops/operation.py", line 285, in _get_node_attribute_at_index
raise AttributeError(
AttributeError: The layer sequential has never been called and thus has no defined input.. Did you mean: 'inputs'?

Expected Result

Without the "import tensorflow" line it works as expected.

It also works with the import moved after the deepface import.

What happened instead?

No response

Additional Info

No response

@jbellis jbellis added the bug Something isn't working label Nov 26, 2024
@serengil
Copy link
Owner

Seems you already found the workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants