Solved: Tensorflow’s bug: label_image.py returns error during classification

 

If following the codelabs for Retrain an Image Classifier for New Categories (CNN network) – retrein.py (https://github.com/tensorflow/hub/raw/master/examples/image_retraining/retrain.py) training worked fine but when you runned the script label_image.py (https://github.com/tensorflow/tensorflow/raw/master/tensorflow/examples/label_image/label_image.py) to evaluate a image:

python -m scripts.label_image \
    --graph=tf_files/retrained_graph.pb  \
    --image=tf_files/flower_photos/daisy/21652746_cc379e0eea_m.jpg

and You’ve got the following error:

The name 'import/input' refers to an Operation not in the graph.

that means that You can solve it on two possible way:
1. According to me the Best Option relying on add two parameters to label_image.py: 

–input_layer=Mul
–input_height=299 –input_width=299

python3 -m scripts.label_image \
--graph=tf_files/retrained_graph.pb \
--image=tf_files/flower_photos/daisy/21652746_cc379e0eea_m.jpg \
--input_layer=Mul \
--input_height=299 --input_width=299

OR

2. change ~/scripts/label_image.py line 77 and it works:

from

input_layer = "input"

to

input_layer = "Mul"

 

Below presented working script with returned result of classification – problem solved by added 2 mentioned parameters: