Toybrick

tensorflow .ckpt模型转.pb模型出问题

hhhjjjwww

中级会员

积分
231
楼主
发表于 2020-6-1 19:41:07    查看: 17510|回复: 1 | [复制链接]    打印 | 只看该作者
使用tensorflow 的freeze_graph将.ckpt模型转到.pb模型,但是调用.pb文件的时候出现了这样的错误:
2020-06-01 19:28:59.621776: W T:\src\github\tensorflow\tensorflow\core\framework\op_kernel.cc:1261] Unknown: KeyError: 'pyfunc_0'
Traceback (most recent call last):

  File "D:\Anaconda3\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\ops\script_ops.py", line 141, in __call__
    func = self._funcs[token]

KeyError: 'pyfunc_0'


2020-06-01 19:29:01.297090: W T:\src\github\tensorflow\tensorflow\core\common_runtime\bfc_allocator.cc:219] Allocator (GPU_0_bfc) ran out of memory trying to allocate 3.09GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
Traceback (most recent call last):
  File "D:\Anaconda3\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\client\session.py", line 1327, in _do_call
    return fn(*args)
  File "D:\Anaconda3\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\client\session.py", line 1312, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "D:\Anaconda3\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\client\session.py", line 1420, in _call_tf_sessionrun
    status, run_metadata)
  File "D:\Anaconda3\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 516, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.UnknownError: KeyError: 'pyfunc_0'
Traceback (most recent call last):

  File "D:\Anaconda3\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\ops\script_ops.py", line 141, in __call__
    func = self._funcs[token]

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/device:CPU:0"](vgg_16/ANCHOR_default/ToInt32/_23, vgg_16/ANCHOR_default/ToInt32_1/_25, vgg_16/rois/PyFunc/input_3, vgg_16/ANCHOR_default/generate_anchors/input_3, vgg_16/ANCHOR_default/generate_anchors/input_4)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:/testprogram/Faster-RCNN/demo_pb.py", line 190, in <module>
    demo(im_name,out_file,sess)
  File "D:/testprogram/Faster-RCNN/demo_pb.py", line 94, in demo
    scores, boxes = freeze_graph_test(sess, blobs)
  File "D:/testprogram/Faster-RCNN/demo_pb.py", line 155, in freeze_graph_test
    feed_dict={input_image_tensor: blobs['data'], tensor_info: blobs['im_info']})
  File "D:\Anaconda3\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\client\session.py", line 905, in run
    run_metadata_ptr)
  File "D:\Anaconda3\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\client\session.py", line 1140, in _run
    feed_dict_tensor, options, run_metadata)
  File "D:\Anaconda3\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\client\session.py", line 1321, in _do_run
    run_metadata)
  File "D:\Anaconda3\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\client\session.py", line 1340, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.UnknownError: KeyError: 'pyfunc_0'
Traceback (most recent call last):

  File "D:\Anaconda3\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\ops\script_ops.py", line 141, in __call__
    func = self._funcs[token]

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/device:CPU:0"](vgg_16/ANCHOR_default/ToInt32/_23, vgg_16/ANCHOR_default/ToInt32_1/_25, vgg_16/rois/PyFunc/input_3, vgg_16/ANCHOR_default/generate_anchors/input_3, vgg_16/ANCHOR_default/generate_anchors/input_4)]]

Caused by op 'vgg_16/ANCHOR_default/generate_anchors', defined at:
  File "D:/testprogram/Faster-RCNN/demo_pb.py", line 180, in <module>
    tf.import_graph_def(output_graph_def, name="")
  File "D:\Anaconda3\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\util\deprecation.py", line 432, in new_func
    return func(*args, **kwargs)
  File "D:\Anaconda3\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\framework\importer.py", line 577, in import_graph_def
    op_def=op_def)
  File "D:\Anaconda3\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\framework\ops.py", line 3290, in create_op
    op_def=op_def)
  File "D:\Anaconda3\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\framework\ops.py", line 1654, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

UnknownError (see above for traceback): KeyError: 'pyfunc_0'
Traceback (most recent call last):

  File "D:\Anaconda3\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\ops\script_ops.py", line 141, in __call__
    func = self._funcs[token]

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/device:CPU:0"](vgg_16/ANCHOR_default/ToInt32/_23, vgg_16/ANCHOR_default/ToInt32_1/_25, vgg_16/rois/PyFunc/input_3, vgg_16/ANCHOR_default/generate_anchors/input_3, vgg_16/ANCHOR_default/generate_anchors/input_4)]]


请问大家有遇到过吗?

回复

使用道具 举报

zx123

新手上路

积分
23
沙发
发表于 2021-8-11 18:08:05 | 只看该作者
请问下代码里的.pb数据模型在哪里可以获取
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

产品中心 购买渠道 开源社区 Wiki教程 资料下载 关于Toybrick


快速回复 返回顶部 返回列表