Description
I try to change code from python2 to python3,but when I finish all the mistake,and run the code,it caused error below,i do not know where it come from and how to carry out it,how can i do?Thank you so much
2017-10-26 14:07:03.163176: W tensorflow/core/framework/op_kernel.cc:1158] Unknown: KeyError: b'TEST'
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1139, in _do_call
return fn(*args)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1121, in _run_fn
status, run_metadata)
File "/usr/local/lib/python3.6/contextlib.py", line 88, in exit
next(self.gen)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.UnknownError: KeyError: b'TEST'
[[Node: rois/PyFunc = PyFunc[Tin=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_STRING, DT_INT32, DT_INT32], Tout=[DT_FLOAT, DT_FLOAT], token="pyfunc_0", _device="/job:localhost/replica:0/task:0/cpu:0"](Reshape_5/_75, rpn_bbox_pred/Reshape/_77, _arg_Placeholder_1_0_1, rois/PyFunc/input_3, rois/PyFunc/input_4, rois/PyFunc/input_5)]]
[[Node: rois/PyFunc/_79 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_290_rois/PyFunc", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "ctpn/demo.py", line 95, in
_, _ = test_ctpn(sess, net, im)
File "/root/chengjuntao/text-detection-ctpn/lib/fast_rcnn/test.py", line 171, in test_ctpn
rois = sess.run([net.get_output('rois')[0]],feed_dict=feed_dict)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 789, in run
run_metadata_ptr)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 997, in _run
feed_dict_string, options, run_metadata)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1132, in _do_run
target_list, options, run_metadata)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1152, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.UnknownError: KeyError: b'TEST'
[[Node: rois/PyFunc = PyFunc[Tin=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_STRING, DT_INT32, DT_INT32], Tout=[DT_FLOAT, DT_FLOAT], token="pyfunc_0", _device="/job:localhost/replica:0/task:0/cpu:0"](Reshape_5/_75, rpn_bbox_pred/Reshape/_77, _arg_Placeholder_1_0_1, rois/PyFunc/input_3, rois/PyFunc/input_4, rois/PyFunc/input_5)]]
[[Node: rois/PyFunc/_79 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_290_rois/PyFunc", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"]]
Caused by op 'rois/PyFunc', defined at:
File "ctpn/demo.py", line 85, in
net = get_network("VGGnet_test")
File "/root/chengjuntao/text-detection-ctpn/lib/networks/factory.py", line 20, in get_network
return VGGnet_test()
File "/root/chengjuntao/text-detection-ctpn/lib/networks/VGGnet_test.py", line 14, in init
self.setup()
File "/root/chengjuntao/text-detection-ctpn/lib/networks/VGGnet_test.py", line 68, in setup
.proposal_layer(_feat_stride, anchor_scales, 'TEST', name='rois'))
File "/root/chengjuntao/text-detection-ctpn/lib/networks/network.py", line 28, in layer_decorated
layer_output = op(self, layer_input, *args, **kwargs)
File "/root/chengjuntao/text-detection-ctpn/lib/networks/network.py", line 241, in proposal_layer
[tf.float32,tf.float32])
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/script_ops.py", line 198, in py_func
input=inp, token=token, Tout=Tout, name=name)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/gen_script_ops.py", line 38, in _py_func
name=name)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op
op_def=op_def)
File "/usr/local/lib/python3.6/site-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/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1269, in init
self._traceback = _extract_stack()
UnknownError (see above for traceback): KeyError: b'TEST'
[[Node: rois/PyFunc = PyFunc[Tin=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_STRING, DT_INT32, DT_INT32], Tout=[DT_FLOAT, DT_FLOAT], token="pyfunc_0", _device="/job:localhost/replica:0/task:0/cpu:0"](Reshape_5/_75, rpn_bbox_pred/Reshape/_77, _arg_Placeholder_1_0_1, rois/PyFunc/input_3, rois/PyFunc/input_4, rois/PyFunc/input_5)]]
[[Node: rois/PyFunc/_79 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_290_rois/PyFunc", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"]]
Activity
cjt222 commentedon Oct 26, 2017
@eragonruan
eragonruan commentedon Oct 26, 2017
try add
# -*- coding:utf-8 -*-
in lib/networks/VGG_test.pycjt222 commentedon Oct 26, 2017
i try it ,maybe it can change nothing........... @eragonruan
eragonruan commentedon Oct 26, 2017
@cjt222 python2/python3 compatblity have been done, you can check the latest code
the bug your met was caused by different decode format between python2 and python3.
cjt222 commentedon Oct 27, 2017
thank you so much!!! it test well!!!
awilliamson commentedon Nov 8, 2017
This may be useful information for those who are trying to convert smallcorgi/Faster-RCNN_TF from 2 to 3. @eragonruan Could you be more specific as to what the cause was, and how your proposed fix corrects this. I've looked at the latest networks/VGG_test, and only the config include is different from what I can see there's not utf-8 mention in there.
eragonruan commentedon Nov 9, 2017
@awilliamson First, I use 2to3 tool to convert the whole project from python2 to python3. This can fix bugs about print function and xrange/range and etc.Then fix some bug. like
lib/datasets/pascal_voc.py#L5 to fix pickle and cPickle
lib/networks/network.py#L43 decode format about loading the pretrain model
lib/rpn_msr/proposal_layer_tf.py#L46 decode format about the config key
just run the training script and fix bugs one by one, most of bug are caused by different encode and decode format.
awilliamson commentedon Nov 9, 2017
@eragonruan Thanks :) I found information regarding the cfg_key encoding fix from some other location. Hopefully your response will help others like me attempting to get the Faster-RCNN working, as this is the basis for your text detection.
Just to get to that stage to fix that, several tweaks to the build process under /lib had to be taken.
arsalan993 commentedon Feb 15, 2018
I am using python3.5 and tensorflow GPU. so its a GPU execution. OS is ubuntu 17.04 and its running successfully using using python 2 but not using python3.5
i am encountering this error
test@dc-isb-ds-001:~/Desktop/text-detection-ctpn$ python3 ./ctpn/demo.py
/usr/lib/python3/dist-packages/h5py/init.py:34: FutureWarning: Conversion of the second argument of issubdtype from
float
tonp.floating
is deprecated. In future, it will be treated asnp.float64 == np.dtype(float).type
.from ._conv import register_converters as _register_converters
Traceback (most recent call last):
File "./ctpn/demo.py", line 8, in
from lib.networks.factory import get_network
File "/home/test/Desktop/text-detection-ctpn/lib/init.py", line 1, in
from . import fast_rcnn
File "/home/test/Desktop/text-detection-ctpn/lib/fast_rcnn/init.py", line 2, in
from . import train
File "/home/test/Desktop/text-detection-ctpn/lib/fast_rcnn/train.py", line 5, in
from ..roi_data_layer.layer import RoIDataLayer
File "/home/test/Desktop/text-detection-ctpn/lib/roi_data_layer/init.py", line 1, in
from . import roidb
File "/home/test/Desktop/text-detection-ctpn/lib/roi_data_layer/roidb.py", line 5, in
from lib.utils.bbox import bbox_overlaps
File "/home/test/Desktop/text-detection-ctpn/lib/utils/init.py", line 4, in
from . import bbox
ImportError: /home/test/Desktop/text-detection-ctpn/lib/utils/bbox.so: undefined symbol: _Py_ZeroStruct
Tony1Q84 commentedon Jul 4, 2018
@cjt222 I also meet this problem, so how did you fix it, could you please tell me, thank you!
kiruthiga-A commentedon Jul 31, 2018
@eragonruan, I have tried all the post you have provided earlier. But still am getting b'TEST error
I am using windows 10, python 3.6 and CPU. Most of the post here covers for GPU.
Could you please help me to solve the following issue?
Keyerror: b'TEST
2018-07-31 09:19:40.768405: W C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\36\tensorflow\core\framework\op_kernel.cc:1192] Unknown: KeyError: b'TEST'
Traceback (most recent call last):
File "C:\Python 3.6\lib\site-packages\tensorflow\python\client\session.py", line 1327, in _do_call
return fn(*args)
File "C:\Python 3.6\lib\site-packages\tensorflow\python\client\session.py", line 1306, in _run_fn
status, run_metadata)
File "C:\Python 3.6\lib\contextlib.py", line 88, in exit
next(self.gen)
File "C:\Python 3.6\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.UnknownError: KeyError: b'TEST'
[[Node: rois/PyFunc = PyFunc[Tin=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_STRING, DT_INT32, DT_INT32], Tout=[DT_FLOAT, DT_FLOAT], token="pyfunc_0", _device="/job:localhost/replica:0/task:0/cpu:0"](Reshape_2, rpn_bbox_pred/Reshape_1, _arg_Placeholder_1_0_1, rois/PyFunc/input_3, rois/PyFunc/input_4, rois/PyFunc/input_5)]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./ctpn/demo.py", line 106, in
_, _ = test_ctpn(sess, net, im)
File "D:\text-detection-ctpn-master\text-detection-ctpn-master\lib\fast_rcnn\test.py", line 51, in test_ctpn
rois = sess.run([net.get_output('rois')[0]],feed_dict=feed_dict)
File "C:\Python 3.6\lib\site-packages\tensorflow\python\client\session.py", line 895, in run
run_metadata_ptr)
File "C:\Python 3.6\lib\site-packages\tensorflow\python\client\session.py", line 1124, in _run
feed_dict_tensor, options, run_metadata)
File "C:\Python 3.6\lib\site-packages\tensorflow\python\client\session.py", line 1321, in _do_run
options, run_metadata)
File "C:\Python 3.6\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: b'TEST'
[[Node: rois/PyFunc = PyFunc[Tin=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_STRING, DT_INT32, DT_INT32], Tout=[DT_FLOAT, DT_FLOAT], token="pyfunc_0", _device="/job:localhost/replica:0/task:0/cpu:0"](Reshape_2, rpn_bbox_pred/Reshape_1, _arg_Placeholder_1_0_1, rois/PyFunc/input_3, rois/PyFunc/input_4, rois/PyFunc/input_5)]]
Caused by op 'rois/PyFunc', defined at:
File "./ctpn/demo.py", line 85, in
net = get_network("VGGnet_test")
File "D:\text-detection-ctpn-master\text-detection-ctpn-master\lib\networks\factory.py", line 8, in get_network
return VGGnet_test()
File "D:\text-detection-ctpn-master\text-detection-ctpn-master\lib\networks\VGGnet_test.py", line 14, in init
self.setup()
File "D:\text-detection-ctpn-master\text-detection-ctpn-master\lib\networks\VGGnet_test.py", line 55, in setup
.proposal_layer(_feat_stride, anchor_scales, 'TEST', name='rois'))
File "D:\text-detection-ctpn-master\text-detection-ctpn-master\lib\networks\network.py", line 21, in layer_decorated
layer_output = op(self, layer_input, *args, **kwargs)
File "D:\text-detection-ctpn-master\text-detection-ctpn-master\lib\networks\network.py", line 215, in proposal_layer
[tf.float32,tf.float32])
File "C:\Python 3.6\lib\site-packages\tensorflow\python\ops\script_ops.py", line 203, in py_func
input=inp, token=token, Tout=Tout, name=name)
File "C:\Python 3.6\lib\site-packages\tensorflow\python\ops\gen_script_ops.py", line 36, in _py_func
name=name)
File "C:\Python 3.6\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 767, in apply_op
op_def=op_def)
File "C:\Python 3.6\lib\site-packages\tensorflow\python\framework\ops.py", line 2630, in create_op
original_op=self._default_original_op, op_def=op_def)
File "C:\Python 3.6\lib\site-packages\tensorflow\python\framework\ops.py", line 1204, in init
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access
UnknownError (see above for traceback): KeyError: b'TEST'
[[Node: rois/PyFunc = PyFunc[Tin=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_STRING, DT_INT32, DT_INT32], Tout=[DT_FLOAT, DT_FLOAT], token="pyfunc_0", _device="/job:localhost/replica:0/task:0/cpu:0"](Reshape_2, rpn_bbox_pred/Reshape_1, _arg_Placeholder_1_0_1, rois/PyFunc/input_3, rois/PyFunc/input_4, rois/PyFunc/input_5)]]
3 remaining items