AttributeError: 'KerasHistory' object has no attribute 'layer'
Closed this issue · 2 comments
I'm having the following error when trying to execute the train.py
Traceback (most recent call last): File "/Volumes/Dev/Python/FaceRecognition-MTCNN-ArcFace/train.py", line 35, in <module> model = ArcFace.loadModel() ^^^^^^^^^^^^^^^^^^^ File "/Volumes/Dev/Python/FaceRecognition-MTCNN-ArcFace/ArcFace.py", line 17, in loadModel base_model = ResNet34() ^^^^^^^^^^ File "/Volumes/Dev/Python/FaceRecognition-MTCNN-ArcFace/ArcFace.py", line 49, in ResNet34 model = training.Model(img_input, x, name='ResNet34') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Volumes/Dev/Python/FaceRecognition-MTCNN-ArcFace/.venv/lib/python3.12/site-packages/tensorflow/python/trackable/base.py", line 204, in _method_wrapper result = method(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Volumes/Dev/Python/FaceRecognition-MTCNN-ArcFace/.venv/lib/python3.12/site-packages/tensorflow/python/keras/engine/functional.py", line 116, in __init__ self._init_graph_network(inputs, outputs) File "/Volumes/Dev/Python/FaceRecognition-MTCNN-ArcFace/.venv/lib/python3.12/site-packages/tensorflow/python/trackable/base.py", line 204, in _method_wrapper result = method(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Volumes/Dev/Python/FaceRecognition-MTCNN-ArcFace/.venv/lib/python3.12/site-packages/tensorflow/python/keras/engine/functional.py", line 152, in _init_graph_network self._validate_graph_inputs_and_outputs() File "/Volumes/Dev/Python/FaceRecognition-MTCNN-ArcFace/.venv/lib/python3.12/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'
Hi @h-azad ,
which version of keras is using ?
In ArcFace.py:
- Use import keras instead of from tensorflow import keras
- Replacing all tensorflow.keras.layers. with keras.layers.