Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails with runtime error: Failing to parse input data #1

Closed
nekulkarni opened this issue Oct 21, 2018 · 3 comments
Closed

Fails with runtime error: Failing to parse input data #1

nekulkarni opened this issue Oct 21, 2018 · 3 comments

Comments

@nekulkarni
Copy link

nekulkarni commented Oct 21, 2018

I followed the following example given in the README file, while using the correct paths to detection.record and label_map.pbtxt files:

python confusion_matrix.py --detections_record=testing_detections.record --label_map=label_map.pbtxt

However I run into an error:

Traceback (most recent call last):
  File "neeraj_confusion_matrix.py", line 133, in <module>
    tf.app.run(main)
  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "neeraj_confusion_matrix.py", line 128, in main
    confusion_matrix = process_detections(FLAGS.detections_record, categories)
  File "neeraj_confusion_matrix.py", line 45, in process_detections
    decoded_dict = data_parser.parse(example)
  File "/home/ubuntu/tensorflow/models/research/object_detection/metrics/tf_example_parser.py", line 153, in parse
    results_dict[key] = parser.parse(tf_example)
  File "/home/ubuntu/tensorflow/models/research/object_detection/metrics/tf_example_parser.py", line 49, in parse
    self.field_name].HasField("bytes_list") else None
TypeError: sequence item 0: expected str instance, bytes found

I'm using python3.6 and tensorflow r1.10.

Why doesn't it work?

@svpino
Copy link
Owner

svpino commented Oct 21, 2018

Hi Nkulkarni,

I found this issue as well. The problem is with the TensorFlow library and the solution is explained here: tensorflow/models#3252. Unfortunately, you’ll have to patch your local copy of TensorFlow.

Here is the relevant section of the link that explains what you need to do (quote below):

I had same error with Python3.5 and TF1.5. This causes tf_example.features.feature[self.field_name].bytes_list.value returns byte type instead of string type in metrics/tf_example_parser.StringParser.

So I changed tf_example_parser.StringParser below

class StringParser(data_parser.DataToNumpyParser):
  """Tensorflow Example string parser."""
  def __init__(self, field_name):
    self.field_name = field_name
  def parse(self, tf_example):
    if tf_example.features.feature[self.field_name].HasField("bytes_list"):
        result = tf_example.features.feature[self.field_name].bytes_list.value
        result = "".join([x if type(x)=='str' else x.decode('utf-8') for x in result])
    else:
        result = None
    return result

@svpino svpino closed this as completed Oct 21, 2018
@nekulkarni
Copy link
Author

That worked. Thanks so much @svpino!

@frankdeepl
Copy link

The problem has been resolved. Thanks so much @svpino .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants