Object_detection example error
I am in the midst of doing the example on object_detection at https://github.com/tensorflow/models/blob/master/object_detection/g3doc/running_pets.md, and when i run the script for create_pet_tf_record.py, i get this error.
python3 create_pet_tf_record.py --label_map_path=data/pet_label_map.pbtxt --data_dir=`pwd` --output_dir=`pwd`
/home/cressy/Desktop/Code/models/object_detection/utils/dataset_util.py:75: FutureWarning: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.
if not xml:
Traceback (most recent call last):
File "create_pet_tf_record.py", line 211, in <module>
tf.app.run()
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "create_pet_tf_record.py", line 206, in main
image_dir, train_examples)
File "create_pet_tf_record.py", line 175, in create_tf_record
tf_example = dict_to_tf_example(data, label_map_dict, image_dir)
File "create_pet_tf_record.py", line 90, in dict_to_tf_example
encoded_jpg = fid.read()
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/lib/io/file_io.py", line 125, in read
pywrap_tensorflow.ReadFromStream(self._read_buf, length, status))
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/lib/io/file_io.py", line 93, in _prepare_value
return compat.as_str_any(val)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/util/compat.py", line 106, in as_str_any
return as_str(value)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/util/compat.py", line 84, in as_text
return bytes_or_text.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
I ran into this same problem. It appears the object detection library was written in python 2.7, and there are several compatibility issues if you try to run it with python 3. Looks like the last commit fixed a compatibility issues, so this may be something they address soon. for you specific problem .encode() the string will fix it.
I have the same problem. How can i fix it?
You can either install tensorflow in a 2.7 environment, or wait for an compatibility update. It looks like there are pull requests already being submitted addressing the issues.
Does this PR address the python3 issues in running the pets script? https://github.com/tensorflow/models/pull/1614
Yes, I had this problem as well. Python string encoding is different in Python 2.7 vs 3.6 and it break Tensorflow.
@bryancresswell @danzelmo @peciato @c0nn3r Can one of you try PR #1614 that @derekjchow mentioned, to see whether it fixes the issue for you? Thanks!
@tatatodd PR #1614 generates the two pet training files for in both python 3.5 and 2.7. I have not run the full example with files from both versions of python. the file sizes for are slightly different(a few kb) for 3.5 and 2.7 this may not be important though.
Has this issue been addressed?
i am having this same problem any advances?
Same problem here. Did anyone find a solution?
.encode()
I ran into this same problem. It appears the object detection library was written in python 2.7, and there are several compatibility issues if you try to run it with python 3. Looks like the last commit fixed a compatibility issues, so this may be something they address soon. for you specific problem .encode() the string will fix it.
Hi, where i use encode() ?
Hi There, We are checking to see if you still need help on this, as this seems to be considerably old issue. Please update this issue with the latest information, code snippet to reproduce your issue and error you are seeing. If we don't hear from you in the next 7 days, this issue will be closed automatically. If you don't need help on this issue any more, please consider closing this.