deepface: AttributeError: module 'deepface.modules.modeling' has no attribute 'build_model'
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
0.0.93
Python version
3.10
Operating System
Ubuntu 20.04
Dependencies
absl-py==2.1.0 actionlib==1.14.0 ajsonrpc==1.2.0 angles==1.9.13 antlr4-python3-runtime==4.9.3 anyio==4.4.0 asttokens==2.4.1 astunparse==1.6.3 beautifulsoup4==4.12.3 blinker==1.8.2 bondpy==1.8.6 bottle==0.12.25 camera-calibration==1.17.0 camera-calibration-parsers==1.12.0 catkin==0.8.10 certifi==2024.7.4 charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 comm==0.2.2 contourpy==1.2.1 controller-manager==0.20.0 controller-manager-msgs==0.20.0 cv-bridge==1.16.2 cycler==0.12.1 Cython==3.0.11 cython-bbox==0.1.5 debugpy==1.8.5 decorator==5.1.1 deepface==0.0.93 diagnostic-analysis==1.11.0 diagnostic-common-diagnostics==1.11.0 diagnostic-updater==1.11.0 dill==0.3.8 dynamic-reconfigure==1.7.3 exceptiongroup==1.2.2 executing==2.0.1 filelock==3.13.1 fire==0.6.0 Flask==3.0.3 Flask-Cors==5.0.0 flatbuffers==24.3.25 fonttools==4.53.1 fsspec==2024.2.0 gast==0.6.0 gazebo_plugins==2.9.2 gazebo_ros==2.9.2 gdown==5.2.0 gencpp==0.7.0 geneus==3.0.0 genlisp==0.4.18 genmsg==0.6.0 gennodejs==2.0.2 genpy==0.6.15 google-pasta==0.2.0 grpcio==1.65.4 gunicorn==23.0.0 h11==0.14.0 h5py==3.11.0 idna==3.7 image-geometry==1.16.2 interactive-markers==1.12.0 ipykernel==6.29.5 ipython==8.26.0 itsdangerous==2.2.0 jedi==0.19.1 Jinja2==3.1.3 joint-state-publisher==1.15.1 joint-state-publisher-gui==1.15.1 jupyter_client==8.6.2 jupyter_core==5.7.2 keras==3.5.0 kiwisolver==1.4.5 lap==0.4.0 laser_geometry==1.6.7 libclang==18.1.1 loguru==0.7.2 Markdown==3.6 markdown-it-py==3.0.0 MarkupSafe==2.1.5 marshmallow==3.21.3 matplotlib==3.9.0 matplotlib-inline==0.1.7 mdurl==0.1.2 message-filters==1.16.0 ml-dtypes==0.4.1 mpmath==1.3.0 mtcnn==0.1.1 namex==0.0.8 nest-asyncio==1.6.0 networkx==3.2.1 numpy==1.26.3 nvidia-cublas-cu12==12.4.2.65 nvidia-cuda-cupti-cu12==12.4.99 nvidia-cuda-nvrtc-cu12==12.4.99 nvidia-cuda-runtime-cu12==12.4.99 nvidia-cudnn-cu12==9.1.0.70 nvidia-cufft-cu12==11.2.0.44 nvidia-curand-cu12==10.3.5.119 nvidia-cusolver-cu12==11.6.0.99 nvidia-cusparse-cu12==12.3.0.142 nvidia-nccl-cu12==2.20.5 nvidia-nvjitlink-cu12==12.4.99 nvidia-nvtx-cu12==12.4.99 omegaconf==2.3.0 opencv-python==4.10.0.84 opt-einsum==3.3.0 optree==0.12.1 packaging==24.1 pandas==2.2.2 parso==0.8.4 pexpect==4.9.0 pillow==10.2.0 platformdirs==4.2.2 platformio==6.1.15 prompt_toolkit==3.0.47 protobuf==4.25.4 psutil==6.0.0 ptyprocess==0.7.0 pure_eval==0.2.3 py-cpuinfo==9.0.0 pyelftools==0.31 Pygments==2.18.0 pyparsing==3.1.2 pyserial==3.5 PySocks==1.7.1 python-dateutil==2.9.0.post0 python-qt-binding==0.4.4 pytz==2024.1 PyYAML==6.0.1 pyzmq==26.1.0 qt-dotgraph==0.4.2 qt-gui==0.4.2 qt-gui-cpp==0.4.2 qt-gui-py-common==0.4.2 requests==2.32.3 resource_retriever==1.12.7 retina-face==0.0.17 rich==13.8.1 rosbag==1.16.0 rosboost-cfg==1.15.8 rosclean==1.15.8 roscreate==1.15.8 rosgraph==1.16.0 roslaunch==1.16.0 roslib==1.15.8 roslint==0.12.0 roslz4==1.16.0 rosmake==1.15.8 rosmaster==1.16.0 rosmsg==1.16.0 rosnode==1.16.0 rosparam==1.16.0 rospy==1.16.0 rosservice==1.16.0 rostest==1.16.0 rostopic==1.16.0 rosunit==1.15.8 roswtf==1.16.0 rqt-console==0.4.12 rqt-image-view==0.4.17 rqt-logger-level==0.4.12 rqt-moveit==0.5.11 rqt-reconfigure==0.5.5 rqt-robot-dashboard==0.5.8 rqt-robot-monitor==0.5.15 rqt-runtime-monitor==0.5.10 rqt-rviz==0.7.0 rqt-tf-tree==0.6.4 rqt_action==0.4.9 rqt_bag==0.5.1 rqt_bag_plugins==0.5.1 rqt_dep==0.4.12 rqt_graph==0.4.14 rqt_gui==0.5.3 rqt_gui_py==0.5.3 rqt_launch==0.4.9 rqt_msg==0.4.10 rqt_nav_view==0.5.7 rqt_plot==0.4.13 rqt_pose_view==0.5.11 rqt_publisher==0.4.10 rqt_py_common==0.5.3 rqt_py_console==0.4.10 rqt_robot_steering==0.5.12 rqt_service_caller==0.4.10 rqt_shell==0.4.11 rqt_srv==0.4.9 rqt_top==0.4.10 rqt_topic==0.4.13 rqt_web==0.4.10 rviz==1.14.25 scipy==1.14.0 seaborn==0.13.2 semantic-version==2.10.0 sensor-msgs==1.13.1 six==1.16.0 smach==2.5.2 smach-ros==2.5.2 smclib==1.8.6 sniffio==1.3.1 soupsieve==2.6 stack-data==0.6.3 starlette==0.37.2 sympy==1.12 tabulate==0.9.0 tensorboard==2.17.0 tensorboard-data-server==0.7.2 tensorflow==2.17.0 tensorflow-io-gcs-filesystem==0.37.1 termcolor==2.4.0 tf==1.13.2 tf-conversions==1.13.2 tf2-geometry-msgs==0.7.7 tf2-kdl==0.7.7 tf2-py==0.7.7 tf2-ros==0.7.7 tf_keras==2.17.0 thop==0.1.1.post2209072238 topic-tools==1.16.0 torch==2.4.0+cu124 torchaudio==2.4.0+cu124 torchvision==0.19.0+cu124 tornado==6.4.1 tqdm==4.66.5 traitlets==5.14.3 triton==3.0.0 typing_extensions==4.9.0 tzdata==2024.1 ultralytics==8.2.73 ultralytics-thop==2.0.0 urllib3==2.2.2 uvicorn==0.29.0 wcwidth==0.2.13 Werkzeug==3.0.3 wrapt==1.16.0 wsproto==1.2.0 xacro==1.14.18
Reproducible example
from deepface import DeepFace
import cv2
import matplotlib.pyplot as plt
cap = cv2.VideoCapture(0)
img = cv2.imread("../videos/hamza.jpg")
img = img[:,:,::-1]
while cap.isOpened():
ret, frame = cap.read()
result = DeepFace.verify(frame, img ,model_name="Facenet",distance_metric='euclidean_l2')
print(result)
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
Relevant Log Output
AttributeError: module ‘deepface.modules.modeling’ has no attribute ‘build_model’
Expected Result
No response
What happened instead?
No response
Additional Info
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 23 (6 by maintainers)
I was also facing the same issue, but installing tensorrt (
pip install tensorrt) resolved it for me.I managed to make it work by restarting python kernel ¯_(ツ)_/¯
instead of using
I used
and able to solve this issue
I was getting this issue in a notebook using a .venv managed by UV. I was able to resolve it by running a simple deepface analysis (getting the results from one image) first in a normal .py file (in the same .venv) before moving it back to my .ipynb
BTW, what is the name of the file you are running? It must not be
deepface.py.