Tensorflow问题中的对象检测代码-AttributeError:模块'tensorflow'没有属性'gfile'

问题描述 投票:0回答:1

我正在Linux上使用tensorflow 2.0,python 3.7。我正在尝试从以下存储库中运行对象检测教程代码:https://github.com/tensorflow/models/tree/master/research/object_detection

下面提供引发错误的代码块。

detection_graph = tf.Graph()
with detection_graph.as_default():
  od_graph_def = tf.compat.v1.GraphDef() 
  with tf.compat.v2.io.gfile.GFile(PATH_TO_FROZEN_GRAPH, 'rb') as fid:
    serialized_graph = fid.read()
    od_graph_def.ParseFromString(serialized_graph)
    tf.import_graph_def(od_graph_def, name='')

category_index = label_map_util.create_category_index_from_labelmap(PATH_TO_LABELS, use_display_name=True)

如果我运行最后一行,则显示标题中提到的错误。请提供解决方案

编辑:添加了问题的屏幕截图enter image description here

tensorflow object-detection object-detection-api tensorflow2.0 python-3.7
1个回答
0
投票

我也面临着相同的问题,如果您已解决,请共享

© www.soinside.com 2019 - 2024. All rights reserved.