tf.py_func
in my networks, and it works fine in training and test mode. Then I run
bazel-bin/tensorflow/python/tools/freeze_graph
to freeze the graph and generate xxx.pb file.
I try to restore the xxx.pb and run the model again, error happens.
2017-08-11 21:43:15.990085: W tensorflow/core/framework/op_kernel.cc:1158] Unknown: exceptions.KeyError: 'pyfunc_0'
Traceback (most recent call last):
File "/home/huang/PycharmProjects/tf-elec-h/tools/elec_det_test_savepb.py", line 259, in <module>
demo_pb(sess, im_path,output_cls_score,output_cls_prob,output_bbox_pred,output_rois,input_x,input_x_info)
File "/home/huang/PycharmProjects/tf-elec-h/tools/elec_det_test_savepb.py", line 135, in demo_pb
scores, boxes = im_detect_pb(sess, im, output_cls_score, output_cls_prob, output_bbox_pred, output_rois,input_x,input_x_info)
File "/home/huang/PycharmProjects/tf-elec-h/tools/../lib/model/test.py", line 133, in im_detect_pb
feed_dict=feed_dict)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 789, in run
run_metadata_ptr)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 997, in _run
feed_dict_string, options, run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1132, in _do_run
target_list, options, run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1152, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.UnknownError: exceptions.KeyError: 'pyfunc_0'
[[Node: vgg_16/ANCHOR_default/generate_anchors = PyFunc[Tin=[DT_INT32, DT_INT32, DT_INT32, DT_INT32, DT_FLOAT], Tout=[DT_FLOAT, DT_INT32], token="pyfunc_0", _device="/job:localhost/replica:0/task:0/cpu:0"](vgg_16/ANCHOR_default/ToInt32, vgg_16/ANCHOR_default/ToInt32_1, vgg_16/ANCHOR_default/generate_anchors/input_2, vgg_16/ANCHOR_default/generate_anchors/input_3, vgg_16/ANCHOR_default/generate_anchors/input_4)]]
Caused by op u'vgg_16/ANCHOR_default/generate_anchors', defined at:
File "/home/huang/PycharmProjects/tf-elec-h/tools/elec_det_test_savepb.py", line 225, in <module>
_ = tf.import_graph_def(output_graph_def, name="")
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/importer.py", line 311, in import_graph_def
op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2506, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1269, in __init__
self._traceback = _extract_stack()
UnknownError (see above for traceback): exceptions.KeyError: 'pyfunc_0'
[[Node: vgg_16/ANCHOR_default/generate_anchors = PyFunc[Tin=[DT_INT32, DT_INT32, DT_INT32, DT_INT32, DT_FLOAT], Tout=[DT_FLOAT, DT_INT32], token="pyfunc_0", _device="/job:localhost/replica:0/task:0/cpu:0"](vgg_16/ANCHOR_default/ToInt32, vgg_16/ANCHOR_default/ToInt32_1, vgg_16/ANCHOR_default/generate_anchors/input_2, vgg_16/ANCHOR_default/generate_anchors/input_3, vgg_16/ANCHOR_default/generate_anchors/input_4)]]
Process finished with exit code 1
I found the tf.py_func
is not in the graph. How can I define and use the tf.py_func
in freezed graph?