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

Python 3.x support

Open awilliamson opened this issue 8 years ago • 9 comments

I recently tried to make cython modules, yet the python scripts for setup are based on Python 2.7. Please could this added to the ReadMe.

Additionally, will this be moved over to Python 3 soon? For something which is using TensorFlow, a cutting edge framework, I believe we should be attempting to use the latest Python which at the moment is 3.6 ( Where TensorFlow has binaries for 3.6 ).

awilliamson avatar Feb 05 '17 19:02 awilliamson

Note: I used Python 2to3 on setup.py and make then completes successfully. Whether this is accurate and correct, I'm not sure. I will test further, and maybe PR back.

awilliamson avatar Feb 05 '17 19:02 awilliamson

I've used 2to3 on the whole project (setup.py was not enough), it does compile properly, but then I get an error in the demo:


Loaded network models/VGGnet_fast_rcnn_iter_70000.ckpt
DRM_IOCTL_I915_GEM_APERTURE failed: Invalid argument
Assuming 131072kB available aperture size.
May lead to reduced performance or incorrect rendering.
get chip id failed: -1 [22]
param: 4, val: 0
DRM_IOCTL_I915_GEM_APERTURE failed: Invalid argument
Assuming 131072kB available aperture size.
May lead to reduced performance or incorrect rendering.
get chip id failed: -1 [22]
param: 4, val: 0
beignet-opencl-icd: no supported GPU found, this is probably the wrong opencl-icd package for this hardware
(If you have multiple ICDs installed and OpenCL works, you can ignore this message)
Traceback (most recent call last):
  File "/home/gdelaboulaye/pypano/venv/lib/python3.4/site-packages/tensorflow/python/ops/script_ops.py", line 82, in __call__
    ret = func(*args)
  File "/home/gdelaboulaye/faster-rcnn/Faster-RCNN_TF/tools/../lib/rpn_msr/proposal_layer_tf.py", line 48, in proposal_layer
    pre_nms_topN  = cfg[cfg_key].RPN_PRE_NMS_TOP_N
KeyError: b'TEST'
W tensorflow/core/framework/op_kernel.cc:993] Internal: Failed to run py callback pyfunc_0: see error log.
Traceback (most recent call last):
  File "/home/gdelaboulaye/pypano/venv/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1022, in _do_call
    return fn(*args)
  File "/home/gdelaboulaye/pypano/venv/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1004, in _run_fn
    status, run_metadata)
  File "/usr/lib/python3.4/contextlib.py", line 66, in __exit__
    next(self.gen)
  File "/home/gdelaboulaye/pypano/venv/lib/python3.4/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.InternalError: Failed to run py callback pyfunc_0: see error log.
	 [[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/cpu:0"](rpn_cls_prob_reshape/_99, rpn_bbox_pred/rpn_bbox_pred/_101, _recv_Placeholder_1_0, PyFunc/input_3, PyFunc/input_4, PyFunc/input_5)]]
	 [[Node: PyFunc/_103 = _Recv[client_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_228_PyFunc", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"]()]]

which seems to be related to python 2.7 / python 3...

Have yo got the same problem, or how did you solve it ?

gdelab avatar Jun 01 '17 14:06 gdelab

Yes, same problem.

DerekChan65535 avatar Jun 09 '17 04:06 DerekChan65535

I've solved it with cfg_key = cfg_key.decode('utf-8') just before pre_nms_topN = cfg[cfg_key].RPN_PRE_NMS_TOP_N in lib/rpn_msr/proposal_layer_tf

I also had a few others thingd to change, like bg_rois_per_this_image = int(min(bg_rois_per_this_image, bg_inds.size)) in proposal_target_layer_tf (otherwise bg_rois_per_this_image is a float, typically 127.0, and the next line fails).

I also had a problem while testing, in voc_eval.py/voc_eval: both recs = pickle.load(f) and pickle.dump(recs, f) fail. You actually need to open files in byte mode before using pickle in python 3.x:

    with open(cachefile, 'wb') as f:  #  'w' replaced by 'wb' to avoid crashing
        pickle.dump(recs, f)
    ...
    with open(cachefile, 'rb') as f:
        recs = pickle.load(f)

gdelab avatar Jun 13 '17 08:06 gdelab

@gdelab while testing,I have a problem about 'pickle'. so ,i change it to open files in byte as you put it,however, another question occured"Ran out of input": File "./faster_rcnn/../lib/datasets/voc_eval.py", line 123, in voc_eval with open(cachefile, 'rb') as f: recs = pickle.load(f,encoding='bytes') EOFError: Ran out of input

Have you meet this question?Thankyou very much!

sheirving avatar Jul 29 '17 08:07 sheirving

No I've never seen that, sorry !

gdelab avatar Jul 31 '17 07:07 gdelab

Additionally, I've just come back to this project. If 2to3 works on the entire project, why is it simply not in Python3.x as default. I believe 2.x is obsolete and most things should be 3.x moving forwards. Is this something worth putting in a PR for?

awilliamson avatar Nov 07 '17 12:11 awilliamson

@sheirving Just delete your cache files and run it again like #163 (hope you won't encounter another error :)

YCIrving avatar Jun 22 '18 03:06 YCIrving

@sheirving I have a same problem. Did you solve it?

DonghoonPark12 avatar Sep 23 '19 07:09 DonghoonPark12