Bootstrap

mask rcnn运行demo时遇到的问题

运行mask rcnn的demo,提示AttributeError: 'str' object has no attribute 'decode'

mask rcnn采坑

问题描述

AttributeError Traceback (most recent call last)<ipython-input-15-138183a2a830> in <module> 3 4 # Load weights trained on MS-COCO 
 ----> 5 model.load_weights(COCO_MODEL_PATH, by_name=True) D:\software\Anaconda3\envs\maskrcnn\lib\site-packages\mask_rcnn-2.1-py3.7.egg\mrcnn\model.py in load_weights(self, filepath, by_name, exclude) 2128 2129 if by_name: 
--> 2130 hdf5_format.load_weights_from_hdf5_group_by_name(f, layers) 
    2131 else: 
    2132 hdf5_format.load_weights_from_hdf5_group(f, layers) 
D:\software\Anaconda3\envs\maskrcnn\lib\site-packages\tensorflow_core\python\keras\saving\hdf5_format.py in load_weights_from_hdf5_group_by_name(f, layers) 
       716 """ 
       717 if 'keras_version' in f.attrs:
 --> 718 original_keras_version = f.attrs['keras_version'].decode('utf-8') 
       719 else: 720 original_keras_version = '1' 
AttributeError: 'str' object has no attribute 'decode'

原因

h5py 3.0版本更改了字符串的存储和读取方式

解决方法

重新安装较低版本的h5py(h5py<3.0.0)

pip install h5py==2.10 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

(看到有大佬说直接去掉decode(‘utf8’),试了一下并没有解决问题,可能本人愚笨,要是有内行人慷慨赐教,不胜感激)

;