NameError:未定义名称“路径”

时间:2021-03-12 07:42:36

标签: python

我尝试通过编写以下代码来解决问题,但没有成功。

with detection_graph.as_default():
    od_graph_def = tf.GraphDef()
with tf.gfile.GFile(path, 'r') as fid:
    serialized_graph = fid.read()

然后我看到了这样的错误

NameError: name 'path' is not defined

我该如何解决?

3 个答案:

答案 0 :(得分:0)

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

我只是猜测是因为您提供的信息还不够。如果您的 tensorflow 有版本问题,请尝试一下。

答案 1 :(得分:0)

试试:

detection_graph = tf.Graph()
with detection_graph.as_default():
    od_graph_def = tf.compat.v1.GraphDef()

答案 2 :(得分:0)

转到环境变量并将其添加到 PATH。

相关问题