Installing tensorflow with version as following
pip uninstall tensorflow -y
pip uninstall keras -y
pip install tensorflow==2.4.3
pip install keras==2.4.0
After above, some errors will arise. You could solve them by following steps.
@Error: [module 'tensorflow' has no attribute XXXXXXXX]
In the model.py
or your code, resolving some api with tf.compat.v1
, e.g. tf.compat.v1.Session
or import tensorflow.compat.v1 as tf
@Error: [ValueError: Tried to convert 'shape' to a tensor and failed. Error: None values not supported.]
mrcnn_bbox = KL.Reshape((-1, num_classes, 4), name="mrcnn_bbox")(x)
replace with this this if-else code block:
if s[1]==None:
mrcnn_bbox = KL.Reshape((-1, num_classes, 4), name="mrcnn_bbox")(x)
else:
mrcnn_bbox = KL.Reshape((s[1], num_classes, 4), name="mrcnn_bbox")(x)
@Error: [ValueError: None values not supported.]
indices = tf.stack([tf.range(probs.shape[0]), class_ids], axis=1)
replace with
indices = tf.stack([tf.range(tf.shape(probs)[0]), class_ids], axis = 1)
@Error: [AttributeError: module 'keras.engine.saving' has no attribute 'load_weights_from_hdf5_group_by_name']
from keras import saving
replace with
from tensorflow.python.keras.saving import hdf5_format
and
saving.load_weights_from_hdf5_group(f, layers)
saving.load_weights_from_hdf5_group_by_name(f, layers)
replace with
hdf5_format.load_weights_from_hdf5_group(f, layers)
hdf5_format.load_weights_from_hdf5_group_by_name(f, layers)
Reference: