Faster-RCNN_TF icon indicating copy to clipboard operation
Faster-RCNN_TF copied to clipboard

op_kernel.cc:1158 NameError: name 'xrange' is not defined

Open chansekar opened this issue 7 years ago • 5 comments

Hi Guys,

When i am loading the VGGnet_fast_rcnn_iter_70000.ckpt model i get the below error.

Need some assistance on the below error

Loaded network ./VGGnet_fast_rcnn_iter_70000.ckpt 2017-07-12 05:31:58.415534: W tensorflow/core/framework/op_kernel.cc:1158] Unkno wn: NameError: name 'xrange' is not defined Traceback (most recent call last): File "/home/naveen/srcnn/lib/python3.5/site-packages/tensorflow/python/client/ session.py", line 1139, in _do_call return fn(*args) File "/home/naveen/srcnn/lib/python3.5/site-packages/tensorflow/python/client/ session.py", line 1121, in _run_fn status, run_metadata) File "/anaconda/envs/py35/lib/python3.5/contextlib.py", line 66, in exit next(self.gen) File "/home/naveen/srcnn/lib/python3.5/site-packages/tensorflow/python/framewo rk/errors_impl.py", line 466, in raise_exception_on_not_ok_status pywrap_tensorflow.TF_GetCode(status)) tensorflow.python.framework.errors_impl.UnknownError: NameError: name 'xrange' i s not defined [[Node: PyFunc = PyFunc[Tin=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_STRING, D T_INT32, DT_INT32], Tout=[DT_FLOAT], token="pyfunc_0", _device="/job:localhost/r eplica:0/task:0/cpu:0"](rpn_cls_prob_reshape, rpn_bbox_pred/rpn_bbox_pred, arg Placeholder_1_0_1, PyFunc/input_3, PyFunc/input_4, PyFunc/input_5)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "./tools/demo.py", line 128, in _, _= im_detect(sess, net, im) File "/home/naveen/srcnn/Faster-RCNN_TF/tools/../lib/fast_rcnn/test.py", line 180, in im_detect run_metadata=run_metadata) File "/home/naveen/srcnn/lib/python3.5/site-packages/tensorflow/python/client/ session.py", line 789, in run run_metadata_ptr) File "/home/naveen/srcnn/lib/python3.5/site-packages/tensorflow/python/client/ session.py", line 997, in _run feed_dict_string, options, run_metadata) File "/home/naveen/srcnn/lib/python3.5/site-packages/tensorflow/python/client/ session.py", line 1132, in _do_run target_list, options, run_metadata) File "/home/naveen/srcnn/lib/python3.5/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: NameError: name 'xrange' i s not defined [[Node: PyFunc = PyFunc[Tin=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_STRING, D T_INT32, DT_INT32], Tout=[DT_FLOAT], token="pyfunc_0", _device="/job:localhost/r eplica:0/task:0/cpu:0"](rpn_cls_prob_reshape, rpn_bbox_pred/rpn_bbox_pred, arg Placeholder_1_0_1, PyFunc/input_3, PyFunc/input_4, PyFunc/input_5)]]

Caused by op 'PyFunc', defined at: File "./tools/demo.py", line 116, in net = get_network(args.demo_net) File "/home/naveen/srcnn/Faster-RCNN_TF/tools/../lib/networks/factory.py", lin e 28, in get_network return networks.VGGnet_test() File "/home/naveen/srcnn/Faster-RCNN_TF/tools/../lib/networks/VGGnet_test.py", line 16, in init self.setup() File "/home/naveen/srcnn/Faster-RCNN_TF/tools/../lib/networks/VGGnet_test.py", line 53, in setup .proposal_layer(_feat_stride, anchor_scales, 'TEST', name = 'rois')) File "/home/naveen/srcnn/Faster-RCNN_TF/tools/../lib/networks/network.py", lin e 25, in layer_decorated layer_output = op(self, layer_input, *args, **kwargs) File "/home/naveen/srcnn/Faster-RCNN_TF/tools/../lib/networks/network.py", lin e 166, in proposal_layer return tf.reshape(tf.py_func(proposal_layer_py,[input[0],input[1],input[2], cfg_key, _feat_stride, anchor_scales], [tf.float32]),[-1,5],name =name) File "/home/naveen/srcnn/lib/python3.5/site-packages/tensorflow/python/ops/scr ipt_ops.py", line 198, in py_func input=inp, token=token, Tout=Tout, name=name) File "/home/naveen/srcnn/lib/python3.5/site-packages/tensorflow/python/ops/gen _script_ops.py", line 38, in _py_func name=name) File "/home/naveen/srcnn/lib/python3.5/site-packages/tensorflow/python/framewo rk/op_def_library.py", line 767, in apply_op op_def=op_def) File "/home/naveen/srcnn/lib/python3.5/site-packages/tensorflow/python/framewo rk/ops.py", line 2506, in create_op original_op=self._default_original_op, op_def=op_def) File "/home/naveen/srcnn/lib/python3.5/site-packages/tensorflow/python/framewo rk/ops.py", line 1269, in init self._traceback = _extract_stack()

UnknownError (see above for traceback): NameError: name 'xrange' is not defined [[Node: PyFunc = PyFunc[Tin=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_STRING, D T_INT32, DT_INT32], Tout=[DT_FLOAT], token="pyfunc_0", _device="/job:localhost/r eplica:0/task:0/cpu:0"](rpn_cls_prob_reshape, rpn_bbox_pred/rpn_bbox_pred, arg Placeholder_1_0_1, PyFunc/input_3, PyFunc/input_4, PyFunc/input_5)]]

regards sekar

chansekar avatar Jul 12 '17 05:07 chansekar

I tried finding if xrange has to be replaced as range in the python files, but had limited success. Note i am using python 3.4 not 2.7.

chansekar avatar Jul 13 '17 05:07 chansekar

I have the same question and have you solved this problem? And i use python 3.6.

Lostwayzxc avatar Dec 06 '17 08:12 Lostwayzxc

I have same problem, do you kown what cases this issue?

ziyeshanwai avatar Dec 12 '17 10:12 ziyeshanwai

You need to change xrange to range if you are using python3.x

surajitsaikia27 avatar Jun 12 '18 08:06 surajitsaikia27

grep -Ril "xrange",find it and change it for "range".It is caused by the difference of python2.x and python3.x.

tankertyp avatar Aug 14 '18 10:08 tankertyp