python - AttributeError:模块“tensorboard.compat.tensorflow_stub.io.gfile”没有属性“FastGFile”?
问题描述
if image_path:
# Read the image_data
image_data = tf.io.gfile.GFile(image_path, 'rb').read()
# Loads label file, strips off carriage return
label_lines = [line.rstrip() for line in tf.io.gfile.GFile("/tf_files/retrained_labels.txt", "r")]
# Unpersists graph from file
with tf.io.gfile.FastGFile("tf_files/retrained_graph.pb", 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
_ = tf.import_graph_def(graph_def, name='')
这是我从https://github.com/burliEnterprises/tensorflow-image-classifier获得的代码 ,我看到的其他页面使用了相同的代码
但是当我运行时它给出了这个错误
Traceback (most recent call last):
File "classify.py", line 29, in <module>
with tf.io.gfile.FastGFile("tf_files/retrained_graph.pb", 'rb') as f: AttributeError: module 'tensorboard.compat.tensorflow_stub.io.gfile' has no attribute 'FastGFile'
解决方案
推荐阅读
- android - 如何在没有 ActionBar 的片段中实现 SeachView
- javascript - 为什么 Vue.js 使用单字标签
,这违反了自己的风格指南? - algorithm - 如何判断两个序列是否因排列不同?
- python - 在 DataFrame pandas 中合并两列
- phpstorm - 如何在 PhpStorm 上使用 Codecept 和 Puppeteer 包
- python-3.x - 用于二维数组的 numpy loadtxt
- c++ - 如何不从矢量 C++ 中打印选定的元素/元素
- python-3.x - xirr: TypeError: 'float' 对象不可调用
- python - 使用 while 循环创建类的 x 个实例 - python
- java - 简单地返回比抛出异常更好吗