【tf-efficientdet】训练自己的数据集问题总结

【tf-efficientdet】训练自己的数据集问题总结

我的环境:
在这里插入图片描述
参考的博客大大都说最好安装tensorflow2.1.0版本,可惜我的python是3.8的,好像安装不了,只能安了2.2.0,以下大半问题都是环境问题,害。

1.yaml

ModuleNotFoundError: No module named ‘yaml’
yaml包安装时名为pyyaml

pip install pyyaml

2.has no attribute

(1)‘enable_v2_dtype_behavior’

AttributeError: module ‘tensorflow.python.keras.api._v1.keras.layers’ has no attribute ‘enable_v2_dtype_behavior’
原句

 tf.compat.v1.keras.layers.enable_v2_dtype_behavior()

改为

  tf.compat.v1.enable_v2_behavior()
(2)AUTOTUNE

‘tensorflow._api.v2.data’ has no attribute ‘AUTOTUNE’
tf.data.AUTOTUNE,改为

tf.data.experimental.AUTOTUNE
(3)no attribute ‘Policy’

tensorflow.python.keras.api._v2.keras.mixed_precision’ has no attribute ‘Policy’
原句:

tf2.keras.mixed_precision.Policy(policy_name)

改为

tf2.keras.mixed_precision.experimental.Policy
(4)‘set_global_policy’

module ‘tensorflow.python.keras.api._v2.keras.mixed_precision’ has no attribute ‘set_global_policy’
将set_global_policy改为set_policy

  #tf2.keras.mixed_precision.set_global_policy(policy)
  tf2.keras.mixed_precision.experimental.set_policy(policy)
(5) ‘variance_scaling’

AttributeError: module ‘tensorflow.keras.initializers’ has no attribute ‘variance_scaling’
'variance_scaling’改为VarianceScaling(),

 # pointwise_initializer=tf.initializers.variance_scaling(),
 pointwise_initializer=tf.initializers.VarianceScaling(),

3.载入模型报错

Unsuccessful TensorSliceReader constructor: Failed to find any matching files for efficientdet-d0

这个问题众说纷纭,很多人是模型保存时出现这个问题,解决方法就是修改保存模型那句代码,或是说因为tf版本不兼容导致的,要修改tf版本,不过我这儿是载入efficientdet-d0时出现的,于是将参数里的预训练模型所在目录相对路径改为绝对路径,

#--ckpt=efficientdet-d0 \
--ckpt=F:/Efficientdet/automl-master/efficientdet-d0 \

注意,这时会报一个错误,文件名要以“efficientdet”开始,这时只要进入那个子函数,将相关代码的返回错误那句删掉,不进行文件名的判断,直接return结果即可。

4.TypeError: ‘<’ not supported between instances of ‘str’ and ‘int’

TypeError: ‘<’ not supported between instances of ‘str’ and ‘int’
数据类型错误,提示错误句是这句,那只能是sorted()函数排序时的数据类型了,于是把label_map打印出来看一下,

for i, cid in enumerate(sorted(label_map.keys())):

在这里插入图片描述
前面哪个地方写类别时错了,内容写进了索引,害,改之。


今天,你debug了吗
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值