keras报错:AttributeError: '_thread._local' object has no attribute 'value'

用keras框架时候,用模型对预处理后的图片数据进行预测,也就是在运行这样一段代码时,出现了标题中的报错,AttributeError: '_thread._local' object has no attribute 'value'

img_data = self.preprocess(path)
feature = self.model.predict(img_data)
运行报错.png

查找了好多方案,最后采纳这种

pip install tensorflow==1.14 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install keras==2.2.5 -i https://pypi.tuna.tsinghua.edu.cn/simple

如果网络不好,加上“-i https://pypi.tuna.tsinghua.edu.cn/simple”清华的镜像资源后缀可以加速
原因是keras和tensorflow版本不同,导致有些特性不能支持,具体的原因小编也没有深究了
不同的情况解决方法不同,这个方法仅供参考

你可能感兴趣的:(keras报错:AttributeError: '_thread._local' object has no attribute 'value')