Mask R-cnn 代码运行报错总结
- 环境版本
- 1. 数据集下载与参数配置
- 2. 运行报错开始
- 报错1
- 报错2
- 报错3
- 报错4
- 报错5
- 报错6
- 参考文章
- 文章1
- 文章2
环境版本
- TensorFlow 2.1.0
- Python 3.7
- keras 2.3.1
1. 数据集下载与参数配置
-
下载链接
- https://github.com/matterport/Mask_RCNN/releases
-
保存路径
-
balloon.py
运行参数配置train --dataset=..\\..\\balloon --wieghts=coco
2. 运行报错开始
报错1
AttributeError: module 'tensorflow' has no attribute 'random_shuffle'
- 将
random_shuffle
改为random.shuffle
报错2
AttributeError: module 'tensorflow' has no attribute 'log''
- 将
log
改为math.log
报错3
- AttributeError:‘str’ object has no sttribute decode
h5py
版本太高,降低版本pip install h5py==0.10.2
报错4
- tensorflow.python.framework.errors_impl.OperatorNotAllowedInGraphError: using a
tf.Tensor
as a Pythonbool
is not allowed in Graph execution. Use Eager execution or decorate this function with @tf.function. - 修改
报错5
- AttributeError: ‘Model’ object has no attribute ‘metrics_tensors’
- 修改,添加代码
self.keras_model.metrics_tensors = []
报错6
-
AttributeError: ‘Model’ object has no attribute ‘_get_distribution_strategy’
-
修改文件
..\Lib\site-packages\tensorflow_core\python\keras\callbacks.py
【自己找自己环境位置】 -
修改代码
# In case this callback is used via native Keras, _get_distribution_strategy does not exist. if hasattr(self.model, '_get_distribution_strategy'): # TensorBoard callback involves writing a summary file in a # possibly distributed settings. self._log_write_dir = distributed_file_utils.write_dirpath( self.log_dir, self.model._get_distribution_strategy()) # pylint: disable=protected-access else: self._log_write_dir = self.log_dir
- 修改前文件
- 修改后文件
-
修改代码
# In case this callback is used via native Keras, _get_distribution_strategy does not exist. if hasattr(self.model, '_get_distribution_strategy'): # Safely remove the unneeded temp files. distributed_file_utils.remove_temp_dirpath( self.log_dir, self.model._get_distribution_strategy()) # pylint: disable=protected-access
- 修改前文件
修改后文件
- 修改前文件