0

When I try to train my object detection model, I get the following error:

    Traceback (most recent call last):
  File "train.py", line 53, in <module>
    from object_detection.builders import model_builder
  File "C:\Users\hp\models\research\object_detection\builders\model_builder.py", line 63, in <module>
    from object_detection.models import ssd_efficientnet_bifpn_feature_extractor as ssd_efficientnet_bifpn
  File "C:\Users\hp\models\research\object_detection\models\ssd_efficientnet_bifpn_feature_extractor.py", line 33, in <module>
    from official.vision.image_classification.efficientnet import efficientnet_model
  File "C:\Users\hp\models\official\vision\image_classification\efficientnet\efficientnet_model.py", line 35, in <module>
    from official.modeling import tf_utils
  File "C:\Users\hp\models\official\modeling\tf_utils.py", line 25, in <module>
    from official.modeling import activations
  File "C:\Users\hp\models\official\modeling\activations\__init__.py", line 16, in <module>
    from official.modeling.activations.gelu import gelu
  File "C:\Users\hp\models\official\modeling\activations\gelu.py", line 26, in <module>
    @tf.keras.utils.register_keras_serializable(package='Text')
AttributeError: module 'tensorflow_core.keras.utils' has no attribute 'register_keras_serializable'

What will be the reason behind this and how to solve it?

I am using Tensorflow 2.0.0.

1
  • Doing a quick search for register_keras_serializable in the repository: github.com/tensorflow/tensorflow/… it looks like that method might be in keras.utils.generic_utils.register_keras_serializable, in that case your import is incorrect. Commented Jul 25, 2020 at 23:57

3 Answers 3

5

I am assuming you are using Tensorflow model garden. I spent a good half of today trying to resolve this.

What i have realized is that we need to upgrade Tensorflow to 2.2.0 (pip install "tensorflow >2.2.0" and furthermore in the python scripts in official/modeling/activations in gelu.py and swish.py remove the '@' symbol before tf. I tried with just removing the '@' symbol and it didnt work for me , however upgrading TF 2.0.0 to TF 2.2.0 helped. Also like Ben mentioned the register_keras_serializable function is not available in generic_utils in TF2.0.0 folder - i tried manually adding the function block and also including a reference in init.py but that also didnt work.

Net summary - please upgrade to tensorflow 2.2.0 and remove the '@' symbol

Sign up to request clarification or add additional context in comments.

Comments

0

I resolved this error by building a virtual environment with pip virtualenv instead of conda using TF 2.0.0.

Comments

0

For me, setting the tensorflow version to 2.1.0 solved the issue

pip install tensorflow==2.1.0

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.