我在开发对象检测应用程序时使用了以下函数
detection_graph = tf.Graph()with detection_graph.as_default(): od_graph_def = tf.GraphDef() with tf.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='')
当我运行这段代码时,出现了以下错误:
AttributeError Traceback (most recent call last)<ipython-input-6-d55b98fd5a78> in <module> 1 detection_graph = tf.Graph() 2 with detection_graph.as_default():----> 3 od_graph_def = tf.GraphDef() 4 with tf.gfile.GFile(PATH_TO_FROZEN_GRAPH, 'rb') as fid: 5 serialized_graph = fid.read()AttributeError: module 'tensorflow' has no attribute 'GraphDef'
我使用的是TensorFlow 2.0.0版本。这是否与版本不匹配有关?
这段代码来自以下链接。
回答:
请确保你按照链接中给出的说明正确安装了库,
https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md