tf.py_func errors in freeze_graph

I use 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?


评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值