Running detection_inference.py in python 3
System information
- What is the top-level directory of the model you are using: models\research\object_detection
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10
- TensorFlow installed from (source or binary): Binary
- TensorFlow version (use command below): 1.10.0
- CUDA/cuDNN version: 9.0/64_7
- Exact command to reproduce: any call to
build_inference_graphfrom detection_inference.py
Describe the problem
In the method build_inference_graph from detection_inference.py there is a line opening a file:
with tf.gfile.Open(inference_graph_path, 'r') as graph_def_file:
Python 3 introduces a distinction between 'r' and 'rb', so this fails as shown below. As pointed out here the fix (in python 3) is to use 'rb'.
Not sure what is level of compatibility exists between python 2 and 3, but I'd be happy to either move it to 'rb' or fix it in such a way that works in python 2.
Source code / logs
The error produced in the mentioned line is:
tf.gfile.FastGFile(filename, 'r').read() error: 'utf-8' codec can't decode byte
Could I ask you why you have closed it? Because I have encountered exactly the same error and it would be nice if this is fixed or at least documented in the object detection tutorial
Sorry I see now someone already wants to merge it and waits for a review https://github.com/tensorflow/models/pull/6071