Using model lm_1b
When I run with python3 I get the following errors:
$ python lm_1b/lm_1b_eval.py --mode sample --prefix "I love that I" --pbtxt data/graph-2016-09-10.pbtxt --vocab_file data/vocab-2016-09-10.txt --ckpt 'data/ckpt-*'
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so locally
Recovering graph.
Traceback (most recent call last):
File "/home/napsternxg/Codes/tensorflow_models/bazel-bin/lm_1b/lm_1b_eval.runfiles/__main__/lm_1b/lm_1b_eval.py", line 307, in <module>
tf.app.run()
File "/home/napsternxg/anaconda3/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 43, in run
sys.exit(main(sys.argv[:1] + flags_passthrough))
File "/home/napsternxg/Codes/tensorflow_models/bazel-bin/lm_1b/lm_1b_eval.runfiles/__main__/lm_1b/lm_1b_eval.py", line 297, in main
_SampleModel(FLAGS.prefix, vocab)
File "/home/napsternxg/Codes/tensorflow_models/bazel-bin/lm_1b/lm_1b_eval.runfiles/__main__/lm_1b/lm_1b_eval.py", line 173, in _SampleModel
sess, t = _LoadModel(FLAGS.pbtxt, FLAGS.ckpt)
File "/home/napsternxg/Codes/tensorflow_models/bazel-bin/lm_1b/lm_1b_eval.runfiles/__main__/lm_1b/lm_1b_eval.py", line 88, in _LoadModel
text_format.Merge(s, gd)
File "/home/napsternxg/anaconda3/lib/python3.5/site-packages/google/protobuf/text_format.py", line 472, in Merge
text.split('\n'),
TypeError: a bytes-like object is required, not 'str'
I have also tried running the same using the bazel commands as mentioned in the model README, and I get the same error. Then after referring to #583 I tried using python3 but am still getting the same error.
Here are some additional details:
Python version: 3.5.2 |Anaconda custom (64-bit)| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
Tensorflow version: 0.12.1
Can you try this will more recent TensorFlow? I'm curious if it's fixed at 1.0 or HEAD.
Automatically closing due to lack of recent activity. Please update the issue when new information becomes available, and we will reopen the issue. Thanks!
I'm using tensorflow 1.0 on python 3.5 and I have the same issues.
$ bazel-bin/lm_1b/lm_1b_eval --mode sample
--prefix "I love that I"
--pbtxt data/graph-2016-09-10.pbtxt
--vocab_file data/vocab-2016-09-10.txt
--ckpt 'data/ckpt-*'
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.7.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.4 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.7.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.7.5 locally
Recovering graph.
Traceback (most recent call last):
File "/home/hqy/Code/models/bazel-bin/lm_1b/lm_1b_eval.runfiles/__main__/lm_1b/lm_1b_eval.py", line 307, in
tf.app.run()
File "/home/hqy/.local/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 44, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "/home/hqy/Code/models/bazel-bin/lm_1b/lm_1b_eval.runfiles/__main__/lm_1b/lm_1b_eval.py", line 297, in main
_SampleModel(FLAGS.prefix, vocab)
File "/home/hqy/Code/models/bazel-bin/lm_1b/lm_1b_eval.runfiles/__main__/lm_1b/lm_1b_eval.py", line 173, in _SampleModel
sess, t = _LoadModel(FLAGS.pbtxt, FLAGS.ckpt)
File "/home/hqy/Code/models/bazel-bin/lm_1b/lm_1b_eval.runfiles/__main__/lm_1b/lm_1b_eval.py", line 88, in _LoadModel
text_format.Merge(s, gd)
File "/home/hqy/.local/lib/python3.5/site-packages/google/protobuf/text_format.py", line 472, in Merge
text.split('n'),
TypeError: a bytes-like object is required, not 'str'
please consider reopen this issue @aselle
I ran into the exact same error. I patched it up adding a simple type check in text_format.py, then ran into some python2to3 issues:
lm_1b_eval.py uses xrange, should be range for python3
I had the same error. I am working with Python 3.5 and Tensorflow '0.12.1'
I replaced s = f.read() at line 86 in lm_1b_eval.py by s = f.read().decode()
Then I replaced the xrange occurences at line 180 and 272 in lm_1b_eval.py by range
Now it works like a charm !
Would you be up for submitting a pull request?
Sure, this is done :)
锛﹉ad the same error, I run the example of object detection example with Python 3.5 and Tensorflow '1.1'
python create_pascal_tf_record.py --data_dir=/home/user/object_detection_test/VOCdevkit --year=VOC2012 --set=train --output_path=pascal_train.record
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally
Traceback (most recent call last):
File "create_pascal_tf_record.py", line 183, in
tf.app.run()
File "/root/anaconda3/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 44, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "create_pascal_tf_record.py", line 158, in main
label_map_dict = label_map_util.get_label_map_dict(FLAGS.label_map_path)
File "/home/user/models/object_detection/utils/label_map_util.py", line 122, in get_label_map_dict
label_map = load_labelmap(label_map_path)
File "/home/user/models/object_detection/utils/label_map_util.py", line 107, in load_labelmap
text_format.Merge(label_map_string, label_map)
File "/root/anaconda3/lib/python3.5/site-packages/google/protobuf/text_format.py", line 472, in Merge
text.split('n'),
TypeError: a bytes-like object is required, not 'str'
Does it work if you change label_map_string = fid.read() at line 104 in label_map_util.py to label_map_string = fid.read().decode() ?
It works! thank you!
adding .decode() is the trick. Thanks @edouardfouche
Adding .decode() works if you are using TF 1.0. No need for this if you are running TF 1.2.x.
I tried to run the object model detection and I run into the same issue. tried changing label_map_string = fid.read().decode(), but still no luck. Note: The line number is not 104 for me, but I made the change in "load_labelmap(path)" method in label_map_util.py
Am using python 3.6, Tensor flow - version 1.0.0, and running on OSX. am running via Anaconda 1.6.3.
so anyone could salve the problem?
i solve with label_map_string = bytearray(fid.read(), 'utf-8') on line 132
Most helpful comment
Does it work if you change
label_map_string = fid.read()at line 104 inlabel_map_util.pytolabel_map_string = fid.read().decode()?