首页 > 解决方案 > 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'

标签: pythontensorflow

解决方案


推荐阅读