When you retrain with a sample (https://github.com/eldor4do/Tensorflow-Examples/blob/master/retraining-example.py), you might encounter the following error:
$ python retraining.py
E tensorflow/core/common_runtime/executor.cc:334] Executor failed to create kernel. Invalid argument: NodeDef mentions attr 'dct_method' not in Op<name=DecodeJpeg; signature=contents:string -> image:uint8; attr=channels:int,default=0; attr=ratio:int,default=1; attr=fancy_upscaling:bool,default=true; attr=try_recover_truncated:bool,default=false; attr=acceptable_fraction:float,default=1>; NodeDef: DecodeJpeg = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_DecodeJpeg/contents_0)
[[Node: DecodeJpeg = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_DecodeJpeg/contents_0)]]
Traceback (most recent call last):
File "retraining.py", line 48, in <module>
answer = run_inference_on_image()
File "retraining.py", line 26, in run_inference_on_image
predictions = session.run(softmax_tensor, {'DecodeJpeg/contents:0': image_data})
File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 717, in run
run_metadata_ptr)
File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 915, in _run
feed_dict_string, options, run_metadata)
File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 965, in _do_run
target_list, options, run_metadata)
File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 985, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors.InvalidArgumentError: NodeDef mentions attr 'dct_method' not in Op<name=DecodeJpeg; signature=contents:string -> image:uint8; attr=channels:int,default=0; attr=ratio:int,default=1; attr=fancy_upscaling:bool,default=true; attr=try_recover_truncated:bool,default=false; attr=acceptable_fraction:float,default=1>; NodeDef: DecodeJpeg = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_DecodeJpeg/contents_0)
[[Node: DecodeJpeg = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_DecodeJpeg/contents_0)]]
Caused by op u'DecodeJpeg', defined at:
File "retraining.py", line 48, in <module>
answer = run_inference_on_image()
File "retraining.py", line 22, in run_inference_on_image
create_graph()
File "retraining.py", line 13, in create_graph
tf.import_graph_def(graph_def, name='')
File "/Library/Python/2.7/site-packages/tensorflow/python/framework/importer.py", line 279, in import_graph_def
op_def=op_def)
File "/Library/Python/2.7/site-packages/tensorflow/python/framework/ops.py", line 2380, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/Library/Python/2.7/site-packages/tensorflow/python/framework/ops.py", line 1298, in __init__
self._traceback = _extract_stack()
Deleting the attribute as follows solves the problem:
graph_def.ParseFromString(f.read())
del(graph_def.node[1].attr["dct_method"])
tf.import_graph_def(graph_def, name='')
Reference:
http://stackoverflow.com/questions/41258012/tensorflow-inception-v3-image-retrain-unable-to-test-on-new-jpg-image
No comments:
Post a Comment