I was following the codelabs tensorflow for poets and the training worked fine but when I runned the script 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
I got the following error:
The name 'import/input' refers to an Operation not in the graph.
I looked around and it has something to do with chosing the input and output layer, the script label_image.py has 'input' and 'output' set as default. The architecture I'm using is 'inception_v3'.
I changed ~/scripts/label_image.py line 77 and it works:
from
to
Or you can run by command lines with the options without changing codes:
Sorry for late answer. I run python script below with a retrained model. Can you try this one?
Requirements: labels.txt and output.pb(retrained model) should be at same directory with my python scipt. Save code below as test.py And call it as: python test.py xxx.jpg
Inside the "retrain.py" code you'll see an argument called '--final_tensor_name'. If you don't pass that argument it will keep 'final_result' or 'Mul' (depending on the version your using) as the default.
The only way to view the input and output names without the actual training output files is to view the graph in TensorBoard of the 'frozen_graph.pb' or in your case the 'retrained_graph.pb' file.
This is a nice way of outputting the required files to view it in TensorBoard. https://gist.github.com/jubjamie/2eec49ca1e4f58c5310d72918d991ef6
Once you run that code and have the output going to your chosen directory, you can start up TensorBoard and view it in Chrome. Viewing the graph helps me alot since I'm a noob in this area.
Not everyone is getting this error. I'm guessing if you used any other architecture apart from MobileNet this error turns up. In your label_image.py file change the values to:
This should solve it.
You have to make some changes in
label_image.py
in the scripts folderinput_height = 299
Change input_height to 299 from 224input_width = 299
Change input_width to 299 from 224input_mean = 128
input_std = 128
input_layer = "Mul"
Change input_layer to Mul from inputoutput_layer = "final_result"
Output:
Evaluation time (1-image): 1.901s
daisy (score=0.98584)
sunflowers (score=0.01136)
dandelion (score=0.00210)
tulips (score=0.00066)
roses (score=0.00004)
For more info, refer this page