googlecodelabs / tensorflow-for-poets-2

Apache License 2.0
508 stars 464 forks source link

Tensorflow Error While Classifying the image #3

Open AnujInCode opened 7 years ago

AnujInCode commented 7 years ago

Anujs-iMac:tensorflow-for-poets-2 anujchampjain$ python scripts/label_image.py --graph=tf_files/retrained_graph.pb --image=tf_files/flower_photos/daisy/21652746_cc379e0eea_m.jpg 2017-09-05 12:36:52.419514: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. 2017-09-05 12:36:52.419532: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. 2017-09-05 12:36:52.419558: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. 2017-09-05 12:36:52.419561: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. Traceback (most recent call last): File "scripts/label_image.py", line 120, in input_operation = graph.get_operation_by_name(input_name); File "/Users/anujchampjain/anaconda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2836, in get_operation_by_name return self.as_graph_element(name, allow_tensor=False, allow_operation=True) File "/Users/anujchampjain/anaconda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2708, in as_graph_element return self._as_graph_element_locked(obj, allow_tensor, allow_operation) File "/Users/anujchampjain/anaconda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2768, in _as_graph_element_locked "graph." % repr(name)) KeyError: "The name 'import/input' refers to an Operation not in the graph."

iXYYL commented 7 years ago

I got the same error..

Alzheimancer commented 7 years ago

same as me. It seem like a new bug.

epreble commented 7 years ago

I edited label_image.py as follows, and got mine working again:

Changed:

input_height = 224
input_width = 224
input_mean = 128
input_std = 128
input_layer = "input"

To:

input_height = 299
input_width = 299
input_mean = 0
input_std = 255
input_layer = "Mul"
MauryaRitesh commented 6 years ago

@epreble you are right and now that worked for me! Thanks a lot!

SagarSharma4244 commented 6 years ago

Thanks, it worked for me. If it is not working someone that means you need to update your Tensorflow, mine is version 1.4 and do the above changes. Also, the new command for the new version uses argument "python label_image.py --image.py Images.png". I think we can close it now.

priyanshAgarwal commented 6 years ago

@epreble Thanks for the info, Can you tell me what thus this change mean?

Starscream9559 commented 4 years ago

I edited label_image.py as follows, and got mine working again:

Changed:

input_height = 224
input_width = 224
input_mean = 128
input_std = 128
input_layer = "input"

To:

input_height = 299
input_width = 299
input_mean = 0
input_std = 255
input_layer = "Mul"
* The change of "input" to "Mul" was suggested here:
  [tensorflow/tensorflow#12736](https://github.com/tensorflow/tensorflow/issues/12736)

* The change of the 4 numbers was made in commit [45767a9](https://github.com/googlecodelabs/tensorflow-for-poets-2/commit/45767a9d62b3b52dae97bf45838fa5701879fe31), on Aug 24, so I changed those back to the original values.

I'm confused. Why change the input from 224 to 299, when the input before the training is also 224. And why 229 and not the other number? My question also applies to input_mean, std, and layer.