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

Bug: if input_config.WhichOneof('input_reader') == 'tf_record_input_reader': AttributeError: 'list' object has no attribute 'WhichOneof' #5924

Open
yaceben opened this issue Dec 18, 2018 · 14 comments
Assignees
Labels

Comments

@yaceben
Copy link

yaceben commented Dec 18, 2018

System information

  • What is the top-level directory of the model you are using: tensorflow/models/research/object_detection
  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No, using stock from git
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux 4.19.8-arch1-1-ARCH Antergos
  • Python version: Python 3.6.7 |Anaconda, Inc.| (default, Oct 23 2018, 19:16:44)
  • TensorFlow installed from (source or binary): N/A
  • TensorFlow version (use command below): 1.12
  • Bazel version (if compiling from source): N/A
  • CUDA/cuDNN version: 10.0/7.4
  • GPU model and memory: Nvidia Quadro K2100M 2GB
  • Exact command to reproduce:
python object_detection/metrics/offline_eval_map_corloc.py metrics/offline_eval_map_corloc.py --eval_dir=/home/user/PycharmProjects/SomeProject/eval_metrics --eval_config_path=/home/user/PycharmProjects/SomeProject/config/test_eval_config.pbtxt --input_config_path=/home/user/PycharmProjects/SomeProject/config/test_input_config.pbtxt

Describe the problem

Getting error if input_config.WhichOneof('input_reader') == 'tf_record_input_reader': AttributeError: 'list' object has no attribute 'WhichOneof' while trying to run the Computing evaluation measures example from https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/oid_inference_and_evaluation.md

also fixed a typo line 162 offline_eval_map_corloc.py input_config = configs['eval_input_configs'] (eval_input_configs), at least for coco_metrics

Source code / logs

Traceback

/home/user/anaconda3/envs/tensorflow_gpuenv/bin/python /opt/JetBrains/apps/PyCharm-P/ch-0/183.4284.139/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 35603 --file /home/user/anaconda3/envs/tensorflow_gpuenv/lib/python3.6/site-packages/tensorflow/models/research/object_detection/metrics/offline_eval_map_corloc.py --eval_dir=/home/user/PycharmProjects/SomeProject/eval_metrics --eval_config_path=/home/user/PycharmProjects/SomeProject/config/test_eval_config.pbtxt --input_config_path=/home/user/PycharmProjects/SomeProject/config/test_input_config.pbtxt
pydev debugger: process 6999 is connecting

Connected to pydev debugger (build 183.4284.139)
/home/user/anaconda3/envs/tensorflow_gpuenv/lib/python3.6/site-packages/tensorflow/models/research/object_detection/utils/visualization_utils.py:26: UserWarning: matplotlib.pyplot as already been imported, this call will have no effect.
  import matplotlib; matplotlib.use('Agg')  # pylint: disable=multiple-statements
Traceback (most recent call last):
  File "/opt/JetBrains/apps/PyCharm-P/ch-0/183.4284.139/helpers/pydev/pydevd.py", line 1689, in <module>
    main()
  File "/opt/JetBrains/apps/PyCharm-P/ch-0/183.4284.139/helpers/pydev/pydevd.py", line 1683, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/opt/JetBrains/apps/PyCharm-P/ch-0/183.4284.139/helpers/pydev/pydevd.py", line 1083, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/opt/JetBrains/apps/PyCharm-P/ch-0/183.4284.139/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/home/user/anaconda3/envs/tensorflow_gpuenv/lib/python3.6/site-packages/tensorflow/models/research/object_detection/metrics/offline_eval_map_corloc.py", line 171, in <module>
    tf.app.run(main)
  File "/home/user/anaconda3/envs/tensorflow_gpuenv/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "/home/user/anaconda3/envs/tensorflow_gpuenv/lib/python3.6/site-packages/tensorflow/models/research/object_detection/metrics/offline_eval_map_corloc.py", line 164, in main
    metrics = read_data_and_evaluate(input_config, eval_config)
  File "/home/user/anaconda3/envs/tensorflow_gpuenv/lib/python3.6/site-packages/tensorflow/models/research/object_detection/metrics/offline_eval_map_corloc.py", line 91, in read_data_and_evaluate
    if input_config.WhichOneof('input_reader') == 'tf_record_input_reader':
AttributeError: 'list' object has no attribute 'WhichOneof'

Process finished with exit code 1

Contents of test_eval_config.pbtxt

metrics_set: 'coco_detection_metrics'

Contents of test_input_config.pbtxt

label_map_path: "/home/user/PycharmProjects/SomeProject/config/mscoco_label_map.pbtxt"

tf_record_input_reader: {
    input_path: "/home/user/PycharmProjects/SomeProject/eval/detections.tfrecord"
}

If more info is needed please don't hesitate,
Thanks

@yaceben
Copy link
Author

yaceben commented Dec 18, 2018

Realized that input_config = configs['eval_input_configs'] returns a list instead of maybe an InputReader ? not sure, will play around a bit and update if I manage something

@yaceben
Copy link
Author

yaceben commented Dec 18, 2018

Tried hacking my way around by modifying def main(...)

  from google.protobuf import text_format
  from object_detection.protos import input_reader_pb2

  input_config = input_reader_pb2.InputReader()
  with tf.gfile.GFile(FLAGS.input_config_path, "r") as f:
    text_format.Merge(f.read(), input_config)
    configs["eval_input_config"] = input_config

  eval_config = configs['eval_config']
  #input_config = input_reader_pb2.InputReader(configs['eval_input_configs'])

  metrics = read_data_and_evaluate(input_config, eval_config)

but I'm afraid that this is going to turn into a real goose chase...

Traceback (most recent call last):
  File "/home/user/anaconda3/envs/tensorflow_gpuenv/lib/python3.6/site-packages/tensorflow/models/research/object_detection/metrics/offline_eval_map_corloc.py", line 181, in <module>
    tf.app.run(main)
  File "/home/user/anaconda3/envs/tensorflow_gpuenv/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "/home/user/anaconda3/envs/tensorflow_gpuenv/lib/python3.6/site-packages/tensorflow/models/research/object_detection/metrics/offline_eval_map_corloc.py", line 174, in main
    metrics = read_data_and_evaluate(input_config, eval_config)
  File "/home/user/anaconda3/envs/tensorflow_gpuenv/lib/python3.6/site-packages/tensorflow/models/research/object_detection/metrics/offline_eval_map_corloc.py", line 117, in read_data_and_evaluate
    decoded_dict = data_parser.parse(example)
  File "/home/user/anaconda3/envs/tensorflow_gpuenv/lib/python3.6/site-packages/tensorflow/models/research/object_detection/metrics/tf_example_parser.py", line 153, in parse
    results_dict[key] = parser.parse(tf_example)
  File "/home/user/anaconda3/envs/tensorflow_gpuenv/lib/python3.6/site-packages/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

Process finished with exit code 1

I should also add that I can use these similarly formatted tfrecords for training through model_main.py, so I dont think that they are the problem

@yaceben
Copy link
Author

yaceben commented Dec 18, 2018

also added the following changes to lines 212 and 355 of object_detection_evaluation.py

            import sys
            if sys.version_info < (3, 0):
                category_name = unicode(category_name, 'utf-8')
            else:
                category_name = str(category_name, 'utf-8')

and changed line 47 of tf_example_parser.py
from

return "".join(tf_example.features.feature[

to

return b"".join(tf_example.features.feature[

it now works, if I can figure out how to properly setup pycharm to make a pull request I'll be glad to help

@msymp msymp self-assigned this Dec 28, 2018
@msymp msymp added the type:bug Bug in the code label Dec 28, 2018
@yaceben
Copy link
Author

yaceben commented Jan 1, 2019

@msymp thanks for checking this issue out. I have a PR #5931 regarding this issue, just waiting for a review for merge.
Cheers

@ShouyangDong
Copy link

In utils/config_util.py , there is a function called get_configs_from_mutilple_files. Then delete 's' in the end of 'eval_input_config' and delete the square bracket of eval_input_config. It will ke OK

@leccyril
Copy link

leccyril commented Feb 3, 2019

hi, i don't find thoses line and i have this error when i launch the train

File "/home/tensorflow/models/research/object_detection/utils/config_util.py", line 99, in get_configs_from_pipeline_file
return create_configs_from_pipeline_proto(pipeline_config)
File "/home/tensorflow/models/research/object_detection/utils/config_util.py", line 123, in create_configs_from_pipeline_proto
configs["eval_input_config"] = configs["eval_input_configs"][0]
TypeError: 'InputReader' object does not support indexing

any idea ? it is from the new pull today of tensorflow

@leccyril
Copy link

leccyril commented Feb 3, 2019

@SYangDong what line ? i think in new version there is not what you talking about.

No one faces this issue too ?

@ShouyangDong
Copy link

@leccyril in line 236. I check the code of its new version. I think the bug still exists.

@leccyril
Copy link

for me i change configs["eval_input_config"] = configs["eval_input_configs"][0]

to

configs["eval_input_config"] = configs["eval_input_configs"]

but i don't know if it make the trick

@SYangDong

i am not a python or tensorflow expert, could you explain with detail what file to change what lines and for example what replace with what , indeed no confusion

@NPetsky
Copy link

NPetsky commented Feb 14, 2019

@leccyril As @SYangDong mentioned, in file utils/config_util.py in function get_configs_from_multiple_files change line 236 from
configs["eval_input_configs"] = [eval_input_config]
to
configs["eval_input_config"] = eval_input_config
This worked for me!

@leccyril
Copy link

ok it is more clear, i make the revert on my modification and tried this one , i launched my train to see if it was better...

wuile launching eval i had an error with unicode utf8 ...

@gfjiyue
Copy link

gfjiyue commented Mar 5, 2019

In utils/config_util.py , there is a function called get_configs_from_mutilple_files. Then delete 's' in the end of 'eval_input_config' and delete the square bracket of eval_input_config. It will ke OK

Thanks @SYangDong . It works for me. But the AP for all results is -1.0.
All the images are skipped.

@ShouyangDong
Copy link

@gfjiyue maybe something wrong with your evaluating metrics. Because COCO evaluation is not supported in the code. if you still want to use coco evaluation, you should change the format of your tfrecord due to the keys' limitation in the codes.

@gyshi
Copy link

gyshi commented Jan 9, 2020

@gfjiyue maybe something wrong with your evaluating metrics. Because COCO evaluation is not supported in the code. if you still want to use coco evaluation, you should change the format of your tfrecord due to the keys' limitation in the codes.

i also meet this error All the images are skipped , Do you have solve this problem?

@ravikyram ravikyram added the models:research models that come under research directory label Jul 1, 2020
@jaeyounkim jaeyounkim added models:research:odapi ODAPI and removed models:research models that come under research directory labels Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests