Closed FabioCanavarro closed 8 months ago
Which tensorflow version?
sorry for the late reply
2.16.1 is my tensorflow version 3.0.5 is my keras version i dont use opencv but i use opencv-contib-python 4.9.0.80
would you please downgrade tensorflow?
e.g.
pip uninstall tensorflow && pip install tensorflow==2.7.0
ERROR: Could not find a version that satisfies the requirement tensorflow==2.7.0 (from versions: 2.16.0rc0, 2.16.1) ERROR: No matching distribution found for tensorflow==2.7.0
may i know the version of python and pip, i am sorry for the inconvinience
Python 3.8.12 pip 21.2.4
i am so sorry but are there anyways to switch tensorflow to a lower version since after vigorous testing python 3.12, 3.11 and 3.8 doest let me download older version of tensorflow and i fi wanna change my pip this happened:
PS C:\Users\ASUS> pip install tensorflow==1
Traceback (most recent call last):
File "
@FabioCanavarro recommend to create a fresh virtual environment with my python version. You may consider to use conda or pipenv.
thank you i will try to do so
its working thank you so much
Cheers!
I am running the following code but it keeps telling me that AttributeError: 'KerasHistory' object has no attribute 'layer', are there anything i can use to fix this issue. this is the code:
TF_ENABLE_ONEDNN_OPTS=0 import cv2 import pandas as pd import keras from deepface import DeepFace as df cap = cv2.VideoCapture(0) cascade = cv2.CascadeClassifier(r"D:\FaceDetect\haarcascade_frontalface_default.xml") while True: face = [] ret, frame = cap.read() if cv2.waitKey(1) and (0XFF == ord("q")): break for (x,y,w,h) in cascade.detectMultiScale(frame,1.15,3): face.append(frame[x:x+w,y:y+h]) cv2.rectangle(frame,(x,y),(x+w,y+h),(255,255,255),1) for img in face: df.find(img,r"D:\FaceDetect\database","ArcFace")
cap.release() cv2.destroyAllWindows()
my deepface is in its latest version 0.086 this is the error message:
Traceback (most recent call last): File "d:\FaceDetect\FaceDetect.py", line 16, in
df.find(img,r"D:\FaceDetect\database","ArcFace")
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\deepface\DeepFace.py", line 301, in find
return recognition.find(
^^^^^^^^^^^^^^^^^
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\deepface\modules\recognition.py", line 96, in find
model: FacialRecognition = modeling.build_model(model_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\deepface\modules\modeling.py", line 46, in build_model
model_obj[model_name] = model()
^^^^^^^
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\deepface\basemodels\ArcFace.py", line 54, in init
self.model = load_model()
^^^^^^^^^^^^
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\deepface\basemodels\ArcFace.py", line 80, in load_model
base_model = ResNet34()
^^^^^^^^^^
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\deepface\basemodels\ArcFace.py", line 130, in ResNet34
model = training.Model(img_input, x, name="ResNet34")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\tensorflow\python\trackable\base.py", line 204, in _method_wrapper
result = method(self, *args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\tensorflow\python\keras\engine\functional.py", line 116, in init
self._init_graph_network(inputs, outputs)
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\tensorflow\python\trackable\base.py", line 204, in _method_wrapper
result = method(self, *args, *kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\tensorflow\python\keras\engine\functional.py", line 152, in _init_graph_network
self._validate_graph_inputs_and_outputs()
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\tensorflow\python\keras\engine\functional.py", line 694, in _validate_graph_inputs_and_outputs
layer = x._keras_history.layer
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'KerasHistory' object has no attribute 'layer'
PS C:\Users\ASUS> ^C
PS C:\Users\ASUS> & C:/Users/ASUS/AppData/Local/Microsoft/WindowsApps/python3.12.exe d:/FaceDetect/FaceDetect.py
2024-03-10 16:51:33.062190: 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
df.find(img,r"D:\FaceDetect\database","ArcFace")
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\deepface\DeepFace.py", line 301, in find
return recognition.find(
^^^^^^^^^^^^^^^^^
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\deepface\modules\recognition.py", line 96, in find
model: FacialRecognition = modeling.build_model(model_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\deepface\modules\modeling.py", line 46, in build_model
model_obj[model_name] = model()
^^^^^^^
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\deepface\basemodels\ArcFace.py", line 54, in init
self.model = load_model()
^^^^^^^^^^^^
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\deepface\basemodels\ArcFace.py", line 80, in load_model
base_model = ResNet34()
^^^^^^^^^^
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\deepface\basemodels\ArcFace.py", line 130, in ResNet34
model = training.Model(img_input, x, name="ResNet34")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\tensorflow\python\trackable\base.py", line 204, in _method_wrapper
result = method(self, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\tensorflow\python\keras\engine\functional.py", line 116, in init
self._init_graph_network(inputs, outputs)
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\tensorflow\python\trackable\base.py", line 204, in _method_wrapper
result = method(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\tensorflow\python\keras\engine\functional.py", line 152, in _init_graph_network
self._validate_graph_inputs_and_outputs()
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\tensorflow\python\keras\engine\functional.py", line 694, in _validate_graph_inputs_and_outputs
layer = x._keras_history.layer
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'KerasHistory' object has no attribute 'layer'
TF_ENABLE_ONEDNN_OPTS=0
. 2024-03-10 16:51:33.441281: 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 variableTF_ENABLE_ONEDNN_OPTS=0
. 2024-03-10 16:51:37.024612: I tensorflow/core/platform/cpu_feature_guard.cc:210] 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. Traceback (most recent call last): File "d:\FaceDetect\FaceDetect.py", line 17, in