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_imag
Or you can run by command lines with the options without changing codes:
python -m scripts.label_image2 --graph=tf_files/retrained_graph.pb --
folder_images=../updated_images/testing --
labels=tf_files/retrained_labels.txt --input_layer=Mul --
input_height=299 --input_width=299
You should add --output_layer=final_result:0
as parameter.
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
I changed ~/scripts/label_image.py line 77 and it works:
from
input_layer = "input"
to
input_layer = "Mul"
As @Mimii and @Celio mentioned: change ~/scripts/label_image.py, at the line input_layer = "input"
to input_layer = "Mul"
AND change the input dimensions: input_height = 299
and input_width= 299
Setting input layer to Mul works for me. However, it seems to be ignoring my input size settings and doesn't do any magic to resize the image to 299x299 which I guess Mul is expecting. I did this:
set INPUT_WIDTH=194
set INPUT_HEIGHT=141
set INPUT_LAYER=Mul
python -m scripts.label_image --image=%IMAGE% --input_height=%INPUT_HEIGHT% \
--input_width=%INPUT_WIDTH% --graph=%GRAPH% \
--input_layer=%INPUT_LAYER% --output_layer=final_result
and got this:
ValueError: Cannot feed value of shape (1, 141, 194, 3)
for Tensor 'import/Mul:0', which has shape '(1, 299, 299, 3)'
And ohhh, looking at the code, input_width and input_height are what to normalize to, not to normalize from. So it's all good. Also I needed to add my labels.