models icon indicating copy to clipboard operation
models copied to clipboard

TypeError: non_max_suppression() got an unexpected keyword argument 'score_threshold'

Open aseelam opened this issue 8 years ago • 31 comments

System information

  • What is the top-level directory of the model you are using: /models/research/
  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 16.04
  • TensorFlow installed from (source or binary): Binary
  • TensorFlow version (use command below): 1.10.0,1.8.0
  • Bazel version (if compiling from source): NA
  • CUDA/cuDNN version:9.0,7.0
  • GPU model and memory:Nvidia Quadro P3000
  • Exact command to reproduce: python object_detection/model_main.py --pipeline_config_path=${PIPELINE_CONFIG_PATH} --model_dir=${MODEL_DIR} --num_train_steps=${NUM_TRAIN_STEPS} --num_eval_steps=${NUM_EVAL_STEPS} --alsologtostderr

Describe the problem

Describe the problem clearly here. Be sure to convey here why it's a bug in TensorFlow or a feature request.

TypeError: non_max_suppression() got an unexpected keyword argument 'score_threshold' when running TF object detection API. Looks like the recent commit by @pkulzc 59f7e80 has some bug.

Source code / logs

Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Try to provide a reproducible test case that is the bare minimum necessary to generate the problem.

Traceback (most recent call last): File "object_detection/model_main.py", line 101, in tf.app.run() File "/home/anikethseelam/anaconda2/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 126, in run _sys.exit(main(argv)) File "object_detection/model_main.py", line 97, in main tf.estimator.train_and_evaluate(estimator, train_spec, eval_specs[0]) File "/home/anikethseelam/anaconda2/lib/python2.7/site-packages/tensorflow/python/estimator/training.py", line 439, in train_and_evaluate executor.run() File "/home/anikethseelam/anaconda2/lib/python2.7/site-packages/tensorflow/python/estimator/training.py", line 518, in run self.run_local() File "/home/anikethseelam/anaconda2/lib/python2.7/site-packages/tensorflow/python/estimator/training.py", line 650, in run_local hooks=train_hooks) File "/home/anikethseelam/anaconda2/lib/python2.7/site-packages/tensorflow/python/estimator/estimator.py", line 363, in train loss = self._train_model(input_fn, hooks, saving_listeners) File "/home/anikethseelam/anaconda2/lib/python2.7/site-packages/tensorflow/python/estimator/estimator.py", line 843, in _train_model return self._train_model_default(input_fn, hooks, saving_listeners) File "/home/anikethseelam/anaconda2/lib/python2.7/site-packages/tensorflow/python/estimator/estimator.py", line 856, in _train_model_default features, labels, model_fn_lib.ModeKeys.TRAIN, self.config) File "/home/anikethseelam/anaconda2/lib/python2.7/site-packages/tensorflow/python/estimator/estimator.py", line 831, in _call_model_fn model_fn_results = self._model_fn(features=features, **kwargs) File "/home/anikethseelam/HAVAL/Summer2018/repos/models/research/object_detection/model_lib.py", line 252, in model_fn preprocessed_images, features[fields.InputDataFields.true_image_shape]) File "/home/anikethseelam/HAVAL/Summer2018/repos/models/research/object_detection/meta_architectures/faster_rcnn_meta_arch.py", line 680, in predict self._anchors.get(), image_shape, true_image_shapes)) File "/home/anikethseelam/HAVAL/Summer2018/repos/models/research/object_detection/meta_architectures/faster_rcnn_meta_arch.py", line 767, in _predict_second_stage anchors, image_shape_2d, true_image_shapes) File "/home/anikethseelam/HAVAL/Summer2018/repos/models/research/object_detection/meta_architectures/faster_rcnn_meta_arch.py", line 1234, in _postprocess_rpn clip_window=clip_window) File "/home/anikethseelam/HAVAL/Summer2018/repos/models/research/object_detection/core/post_processing.py", line 402, in batch_multiclass_non_max_suppression parallel_iterations=parallel_iterations) File "/home/anikethseelam/HAVAL/Summer2018/repos/models/research/object_detection/utils/shape_utils.py", line 228, in static_or_dynamic_map_fn return tf.map_fn(fn, elems, dtype, parallel_iterations, back_prop) File "/home/anikethseelam/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/functional_ops.py", line 423, in map_fn swap_memory=swap_memory) File "/home/anikethseelam/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/control_flow_ops.py", line 3224, in while_loop result = loop_context.BuildLoop(cond, body, loop_vars, shape_invariants) File "/home/anikethseelam/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2956, in BuildLoop pred, body, original_loop_vars, loop_vars, shape_invariants) File "/home/anikethseelam/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2893, in _BuildLoop body_result = body(*packed_vars_for_body) File "/home/anikethseelam/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/functional_ops.py", line 413, in compute packed_fn_values = fn(packed_values) File "/home/anikethseelam/HAVAL/Summer2018/repos/models/research/object_detection/core/post_processing.py", line 378, in _single_image_nms_fn additional_fields=per_image_additional_fields) File "/home/anikethseelam/HAVAL/Summer2018/repos/models/research/object_detection/core/post_processing.py", line 150, in multiclass_non_max_suppression score_threshold=score_thresh) TypeError: non_max_suppression() got an unexpected keyword argument 'score_threshold'

aseelam avatar Aug 10 '18 15:08 aseelam

I hit the same issue using tf 1.8. Tensorflow versions < 1.9 did not support the score_threshold param. You'll have to be sure you're using version 1.9 or newer. Unfortunately I've also encountered issues with estimator based training on v1.10, In my case, v1.9 is the only working version for object detection.

dcyoung avatar Aug 10 '18 16:08 dcyoung

I have this issue on:

^CFernandos-MacBook-Pro:research fernandomartin$ python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"
('v1.10.0-rc1-0-ge5e9a8f4e9', '1.10.0-rc1')

SenhorCastor avatar Aug 12 '18 18:08 SenhorCastor

Hi,

I have the same issue. I'm using tensorflow 1.5 and python 2.7. What is the workaround for that?

Manish-rai21bit avatar Aug 14 '18 00:08 Manish-rai21bit

Please use tf 1.9+ as mentioned here.

I'm surprised that tf 1.10 doesn't work with this. I'll look into it. Thanks!

pkulzc avatar Aug 14 '18 00:08 pkulzc

@pkulzc The object detection tutorial should be updated to use 1.9 as a runtime (as opposed to 1.8 that it currently uses, giving this error). I imagine object_detection/samples/cloud/cloud.yml should also be updated.

arijun avatar Aug 16 '18 15:08 arijun

I upgraded to 1.9 now I have Illegal instruction (core dumped), when I try to train.

swaarup avatar Aug 29 '18 13:08 swaarup

What's the error message @Swaarup ?

pkulzc avatar Aug 29 '18 16:08 pkulzc

The error I get is

Illegal instruction (core dumped).

*I tried with all the available versions of TensorFlow. It runs only with 1.5.0 and I get the error non_max_suppression() got an unexpected keyword argument 'score_threshold'. For other versions I get the error Illegal instruction. *

On Wed, Aug 29, 2018, 18:22 pkulzc [email protected] wrote:

What's the error message @Swaarup https://github.com/Swaarup ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/models/issues/5056#issuecomment-417012261, or mute the thread https://github.com/notifications/unsubscribe-auth/AhYm3zEz3AccjBvz4s7RCZDhq8WY32sQks5uVr-qgaJpZM4V4Zbe .

swaarup avatar Aug 29 '18 17:08 swaarup

@Swaarup when you upgraded to 1.9 did you also compile protos again?

mawanda-jun avatar Sep 08 '18 16:09 mawanda-jun

No, I couldn't figure out the solution myself. So i tried it in another PC and was able to train it without any problem when upgraded to 1.9

On Sat, Sep 8, 2018, 22:10 mawanda-jun [email protected] wrote:

@Swaarup https://github.com/Swaarup when you upgraded to 1.9 did you also compile protos again?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/models/issues/5056#issuecomment-419655300, or mute the thread https://github.com/notifications/unsubscribe-auth/AhYm387JFF9waX7s1WRFQxYu8k911d5fks5uY--WgaJpZM4V4Zbe .

swaarup avatar Sep 09 '18 03:09 swaarup

Tried TF 1.11 today, got the same error message.

It works after downgrade to TF 1.9.

dennywangtenk avatar Oct 12 '18 18:10 dennywangtenk

Please use tf 1.9+ as mentioned here.

I'm surprised that tf 1.10 doesn't work with this. I'll look into it. Thanks!

Hi @pkulzc , I have trained an object detector model in mobilenet ssd using tensorflow 1.7.1. I am suffering from the same problem as mentioned in this thread and the reason I cannot upgrade to tensorflow 1.9 is that ultimately I'll be needing to use my weights in unity and it only supports tensorflow 1.7.1. Is there any workaround with this issue?

Amanpradhan avatar Feb 18 '19 07:02 Amanpradhan

@Amanpradhan Your case is a bit tricky. I think you can replace this block with an older version that use nms op without score_th and do it separately.

pkulzc avatar Feb 21 '19 06:02 pkulzc

i have faced same issue with tf.v1.5 and tf.v1.9 but not solve my issue please guide me in that issue

MWaseemMatto avatar Mar 20 '19 06:03 MWaseemMatto

TypeError: non_max_suppression() got an unexpected keyword argument 'score_threshold' i got this error with tf.v.1.5 and with tf.v.1.9 illegal instructions i could't find any solution please help me

MWaseemMatto avatar Mar 20 '19 06:03 MWaseemMatto

@MWaseemMatto sometimes its just because of the computational limitations. I had exact same error I tried all the different version and approaches but didn't succeeded, later I tried the same task in another PC and it worked. I know it's not the proper solution but just a way around?

swaarup avatar Mar 20 '19 06:03 swaarup

I converted the model using tensorflow 1.7 since the non_max_suppression() was introduced in 1.9 and above.

Amanpradhan avatar Mar 20 '19 06:03 Amanpradhan

@Amanpradhan thanks your comment but i still stuck in that case. if someone has solution then tell me please

MWaseemMatto avatar Mar 25 '19 20:03 MWaseemMatto

Please use tf 1.9+ as mentioned here.

I'm surprised that tf 1.10 doesn't work with this. I'll look into it. Thanks!

I have updated tensorflow using this command pip install --ignore-installed --upgrade tensorflow==1.9.0

But on printing tf.version it is showing 1.8.0

So is there any way to update tensorflow to specific version?

itssp98 avatar May 28 '19 09:05 itssp98

I was having a tough time finding the correct tensorflow version as well. Do one thing, install tensorflow 1.7 in another environment and clone the object detection part from here:https://github.com/stevenobadja/math_object_detection This is how I was able to run the object detection in my environment.

Amanpradhan avatar May 28 '19 09:05 Amanpradhan