KeyError: b ‘TEST’ problem in python3 conversion from csn-rcnn code

One of the faster RCNN codes that

has been using is python2, and we decided to change it to python3.

many errors are print function, xrange function, easy to solve.

solution to the last error was reported, the card for a day, can not find a solution on the Internet, record:

error as follows:

Caused by op ‘PyFunc’, defined at:
File “/home/q/yd/Faster -rcnn-21 /tools/demo.py”, line 118, in < module>
net = get_network(args.demo_net)
File “/home/q/yd/ swift-rcnn-21 /tools/.. /lib/networks/factory.py”, line 29, in get_network
return network.vggnet_test ()
File “/home/q/yd/ quickly-rcnn-21 /tools/.. /lib/networks/ vggnet_test.py “, line 18, in init__,> self. Setup ()
File “/home/q/yd/Faster -rcnn-21 /tools/.. (proposal_layer(__feat_stride, anchor_scales, STR (‘TEST’), name=’rois’))
File “/home/q/yd/ quickly-rcnn-21 /tools/. Floatal_layer [proposal_layer]), [-1, 5], proposal_layer [proposal_layer], [proposal_layer] Name = name)
the File “/ home/q/anaconda3 envs/py35/lib/python3.5/site – packages/tensorflow/python/ops/script_ops py”, line 212, in py_func
input = inp, token = token, Tout = Tout, Name = name)
the File “/ home/q/anaconda3 envs/py35/lib/python3.5/site – packages/tensorflow/python/ops/gen_script_ops py”, line, 50 in _py_func
“PyFunc”, input = input, token = token, Tout = Tout, Name = name)
the File “/ home/q/anaconda3 envs/py35/lib/python3.5/site – packages/tensorflow/python/framework/op_def_library py”, line 787, In _apply_op_helper
op_def = op_def)
the File “/ home/q/anaconda3/envs/py35/lib/python3.5/site – packages/tensorflow/python/framework/ops. Py”, line 2956, In create_op
op_def = op_def)
the File “/ home/q/anaconda3/envs/py35/lib/python3.5/site – packages/tensorflow/python/framework/ops. Py”, line 1470,
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

UnknownError (see above for traceback): KeyError: b’TEST’
[[Node:] PyFunc = PyFunc[Tin=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_STRING, DT_INT32, DT_INT32], Tout=[DT_FLOAT], token=”pyfunc_0″, _device=”/job:localhost/replica:0/task:0/device:CPU:0″](rpn_cls_prob_reshape/_95, Rpn_bbox_pred /rpn_bbox_pred/_97, _arg_Placeholder_1_0_1, PyFunc/input_3, PyFunc/input_4, PyFunc/input_5)]]
[[Node: PyFunc/_99 = _Recv[client_terminated=false, recv_device=”/job:localhost/replica:0/task:0/device:GPU:0″, send_device=”/job:localhost/replica:0/task:0/device:CPU:0″, send_device_incarnation=1, tensor_name=”edge_218_PyFunc”, tensor_type=DT_FLOAT, _device=”/job:localhost/replica:0/task:0/device:GPU:0″]()]]


KeyError: b’TEST’,

after analysis, the final locating reason is that a ‘TEST’ string entered in tf initialization cannot be parsed.

error in the vgg_test.py file

(self.feed('rpn_cls_prob_reshape', 'rpn_bbox_pred', 'im_info')
 .proposal_layer(_feat_stride, anchor_scales, str('TEST'), name='rois'))

there is a ‘TEST’ that will be entered into the tb.py_func () function

cannot resolve reason unknown

the final solution is to assign a value of

directly to ‘TEST’ in the proposal_layer_tf.py file

cfg_key = 'TEST'
pre_nms_topN  = cfg[cfg_key].RPN_PRE_NMS_TOP_N
post_nms_topN = cfg[cfg_key].RPN_POST_NMS_TOP_N
nms_thresh    = cfg[cfg_key].RPN_NMS_THRESH
min_size      = cfg[cfg_key].RPN_MIN_SIZE

with this in red, it works.

original code, syntax check is not wrong, only manually assign ‘TEST’ to cfg_key first to solve this problem.

many on the web say that python2 and python3 are coded differently, plus utf-8, and the test doesn’t work.

Read More: