当前位置:网站首页>mask rcnn 加载权重报错
mask rcnn 加载权重报错
2022-07-21 05:03:00 【萝卜炖着吃】
mask rcnn 加载权重报错
in load_weights_from_hdf5_group
original_keras_version = f.attrs[‘keras_version’].decode(‘utf8’)
AttributeError: ‘str’ object has no attribute ‘decode’
试过其他博客的方法
卸载原来的h5py模块,安装2.10版本
pip install h5py==2.10 -i https://pypi.tuna.tsinghua.edu.cn/simple/
仍然不行,那只有从报错的源码入手了
根据报错提示问题出在
xxx\Lib\site-packages\keras\engine\topology.py
这个文件的3418,3422行。
python3中,编码的时候区分了字符串和二进制
python3在bytes和str两种类型转换,所需要的函数依次是encode(),decode()
这里f.attrs[‘keras_version’]类型我们不知道,因此需要判断是str还是bytes以便使用相应的方法
如果不判断,这个类型一会是str,一会是bytes,这个bug让我找了好久
代码如下
if 'keras_version' in f.attrs:
original_keras_version = f.attrs['keras_version'].encode('utf-8') if isinstance(f.attrs['keras_version'],str) else f.attrs['keras_version'].decode('utf-8')
else:
original_keras_version = '1'
if 'backend' in f.attrs:
original_backend = f.attrs['backend'].encode('utf-8') if isinstance(f.attrs['backend'],str) else f.attrs['backend'].decode('utf-8')
else:
original_backend = None
``
正常运行截图
边栏推荐
- 对象拷贝工具类(fastjson)
- ownCloud 9.0 更好的跨服务器共享和扩展性
- NIO三大核心详解
- Projet d'intégration du cadre SSM
- 14. Can you tell the difference between process and thread
- MySQL exception: Legal mix of settlements (utf8_general_ci, implicit) and (utf8mb4_general_ci, coalible)***
- 数据库设计 数据库系统概论(第五版)
- MySQL之数据库设计三范式
- Single project - Ruiji takeout
- @Scheduled scheduled task details
猜你喜欢
利用反汇编调试与补码解释0x80000000 / -1整形输出异常不一致
CentOS 8中Docker安装MySQL8
Quartz创建定时任务(入门)
[untitled]
4.paddlepaddle之10行代码mnist手写数字识别
拉取项目pom文件报错,jai_core-1.1.3.jar,解决jar引入问题
JSON tool class
Detailed explanation and use of swagger
fastJson数据类型中,解析JSONObject出现$ref: “$.list[0]“问题
Matlab natural spline function (spline, non matlab built-in function)
随机推荐
markdown及IDEA快捷键
[untitled]
pytorch的安装
【GeoServer二次开发】基于GeoServer-Manager的REST自动部署模块开发
mysql/sql server通过JDBC连接数据库进行增删改查的步骤
Original code, inverse code, complement and logical operation "and or not"
Nacos注册中心集群数据一致性问题
yum安装gcc报错
Share the experience of big factories, come quickly
Linux redis-6.2.6 stand alone deployment
PyTorch基础知识
ownCloud 9.0 更好的跨服务器共享和扩展性
Linux Redis-6.2.6单机部署
Gaode map API obtains the surrounding information corresponding to the current location
fastJson数据类型中,解析JSONObject出现$ref: “$.list[0]“问题
PyTorch基础模块和实践
Jd.com's popular architect growth manual is launched, and you deserve the architect aura
MySQL之DQL(数据查询语言)-常见关键字
解决:Connections could not be acquired from the underlying database!
JSON工具类