Hi Team, I’m trying to run this “model_main_tf2.py” from this link
I’m getting this attribute error.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
File ~/Documents/Indian_License_Plate_Recognition/models/research/object_detection/model_main_tf2.py:32
30 import tensorflow.compat.v2 as tf
31 #from object_detection import model_lib_v2
---> 32 import model_lib_v2
34 flags.DEFINE_string('pipeline_config_path', None, 'Path to pipeline config '
35 'file.')
36 flags.DEFINE_integer('num_train_steps', None, 'Number of train steps.')
File ~/Documents/Indian_License_Plate_Recognition/models/research/object_detection/model_lib_v2.py:30
27 import tensorflow.compat.v1 as tf
29 from object_detection import eval_util
---> 30 from object_detection import inputs
31 from object_detection import model_lib
32 from object_detection.builders import optimizer_builder
File ~/anaconda3/envs/tfsetup/lib/python3.10/site-packages/object_detection/inputs.py:27
25 from object_detection.builders import dataset_builder
26 from object_detection.builders import image_resizer_builder
---> 27 from object_detection.builders import model_builder
28 from object_detection.builders import preprocessor_builder
29 from object_detection.core import box_list
File ~/anaconda3/envs/tfsetup/lib/python3.10/site-packages/object_detection/builders/model_builder.py:25
23 from object_detection.builders import anchor_generator_builder
24 from object_detection.builders import box_coder_builder
---> 25 from object_detection.builders import box_predictor_builder
26 from object_detection.builders import hyperparams_builder
27 from object_detection.builders import image_resizer_builder
File ~/anaconda3/envs/tfsetup/lib/python3.10/site-packages/object_detection/builders/box_predictor_builder.py:20
18 import collections
19 import tensorflow.compat.v1 as tf
---> 20 from object_detection.predictors import convolutional_box_predictor
21 from object_detection.predictors import convolutional_keras_box_predictor
22 from object_detection.predictors import mask_rcnn_box_predictor
File ~/anaconda3/envs/tfsetup/lib/python3.10/site-packages/object_detection/predictors/convolutional_box_predictor.py:25
23 import tensorflow.compat.v1 as tf
24 import tf_slim as slim
---> 25 from object_detection.core import box_predictor
26 from object_detection.utils import shape_utils
27 from object_detection.utils import static_shape
File ~/anaconda3/envs/tfsetup/lib/python3.10/site-packages/object_detection/core/box_predictor.py:137
111 """Implementations must override this method.
112
113 Args:
(...)
132 feature map in the input `image_features` list.
133 """
134 pass
--> 137 class KerasBoxPredictor(tf.keras.layers.Layer):
138 """Keras-based BoxPredictor."""
140 def __init__(self, is_training, num_classes, freeze_batchnorm,
141 inplace_batchnorm_update, name=None):
File ~/anaconda3/envs/tfsetup/lib/python3.10/site-packages/tensorflow/python/util/lazy_loader.py:58, in LazyLoader.__getattr__(self, item)
57 def __getattr__(self, item):
---> 58 module = self._load()
59 return getattr(module, item)
File ~/anaconda3/envs/tfsetup/lib/python3.10/site-packages/tensorflow/python/util/lazy_loader.py:41, in LazyLoader._load(self)
39 """Load the module and insert it into the parent's globals."""
40 # Import the target module and insert it into the parent's namespace
---> 41 module = importlib.import_module(self.__name__)
42 self._parent_module_globals[self._local_name] = module
44 # Emit a warning if one was specified
File ~/anaconda3/envs/tfsetup/lib/python3.10/importlib/__init__.py:126, in import_module(name, package)
124 break
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
File ~/anaconda3/envs/tfsetup/lib/python3.10/site-packages/keras/api/_v1/__init__.py:8
3 """Public API for tf. namespace.
4 """
6 import sys as _sys
----> 8 from keras.api._v1 import keras
9 from tensorflow.python.util import module_wrapper as _module_wrapper
11 if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper):
File ~/anaconda3/envs/tfsetup/lib/python3.10/site-packages/keras/api/_v1/keras/__init__.py:27
25 from keras.api._v1.keras import metrics
26 from keras.api._v1.keras import mixed_precision
---> 27 from keras.api._v1.keras import models
28 from keras.api._v1.keras import optimizers
29 from keras.api._v1.keras import preprocessing
File ~/anaconda3/envs/tfsetup/lib/python3.10/site-packages/keras/api/_v1/keras/models/__init__.py:16
14 from keras.saving.legacy.model_config import model_from_json
15 from keras.saving.legacy.model_config import model_from_yaml
---> 16 from keras.saving.legacy.save import load_model
17 from keras.saving.legacy.save import save_model
18 from tensorflow.python.util import module_wrapper as _module_wrapper
File ~/anaconda3/envs/tfsetup/lib/python3.10/site-packages/keras/saving/legacy/save.py:24
22 from keras.saving.legacy import serialization
23 from keras.saving.legacy.saved_model import load as saved_model_load
---> 24 from keras.saving.legacy.saved_model import load_context
25 from keras.saving.legacy.saved_model import save as saved_model_save
26 from keras.utils import traceback_utils
File ~/anaconda3/envs/tfsetup/lib/python3.10/site-packages/keras/saving/legacy/saved_model/load_context.py:68
64 """Returns whether under a load context."""
65 return _load_context.in_load_context()
---> 68 tf.__internal__.register_load_context_function(in_load_context)
AttributeError: module 'tensorflow.compat.v2.__internal__' has no attribute 'register_load_context_function'
I checked this thread and tried everything suggested there. but the error doesnt go. Can you please help