诗人的张量流:"名称'导入/输入'是指不在图中的操作."

Cel*_*lio 22 python machine-learning tensorflow

我正在关注诗人的codelabs tensorflow并且训练工作正常但是当我运行脚本来评估图像时:

python -m scripts.label_image \
    --graph=tf_files/retrained_graph.pb  \
    --image=tf_files/flower_photos/daisy/21652746_cc379e0eea_m.jpg
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

The name 'import/input' refers to an Operation not in the graph.
Run Code Online (Sandbox Code Playgroud)

我环顾四周,它与选择输入和输出层有关,脚本label_image.py将'input'和'output'设置为默认值.我正在使用的架构是'inception_v3'.

Mim*_*eng 15

我更改了〜/ scripts/label_image.py第77行,它的工作原理如下:

input_layer = "input"
Run Code Online (Sandbox Code Playgroud)

input_layer = "Mul"
Run Code Online (Sandbox Code Playgroud)

  • 我工作了,但我不得不将"input_height = 224"和"input_width = 224"都更改为299.你是怎么想出来的?使用"Mul" (6认同)

小智 8

使用--input_layer名称作为占位符.它将起作用,因为retrain.py脚本已将input_layer的默认值设置为"占位符".

    python label_image.py 
          --graph=retrained_graph.pb 
          --labels=retrained_labels.txt 
          --output_layer=final_result 
          --image=testimage654165.jpg 
          --input_layer=Placeholder
Run Code Online (Sandbox Code Playgroud)


Uma*_*try 7

不是每个人都会收到此错误.我猜你是否使用了除MobileNet之外的任何其他架构,这个错误就出现了.在label_image.py文件中,将值更改为:

input_height = 299
input_width = 299
input_layer = "Mul"
Run Code Online (Sandbox Code Playgroud)

这应该解决它.


小智 0

您应该添加--output_layer=final_result:0作为参数。

Final call is : python -m scripts.label_image \
--graph=tf_files/retrained_graph.pb  \
--output_layer=final_result:0 \
--image=tf_files/flower_photos/daisy/21652746_cc379e0eea_m.jpg
Run Code Online (Sandbox Code Playgroud)