Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

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

Closed
aseelam opened this issue Aug 10, 2018 · 31 comments
Assignees
Labels
models:research models that come under research directory stale stat:awaiting response Waiting on input from the contributor type:support

Comments

@aseelam
Copy link

aseelam commented Aug 10, 2018

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'

@dcyoung
Copy link

dcyoung commented Aug 10, 2018

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.

@SenhorCastor
Copy link

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')

@Manish-rai21bit
Copy link

Manish-rai21bit commented Aug 14, 2018

Hi,

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

@pkulzc pkulzc self-assigned this Aug 14, 2018
@pkulzc
Copy link
Contributor

pkulzc commented Aug 14, 2018

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!

@arijun
Copy link

arijun commented Aug 16, 2018

@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.

wentaoxu415 added a commit to wentaoxu415/models that referenced this issue Aug 23, 2018
The bash script to submit training job for pets detection has runtime-version of 1.8. This will trigger `TypeError: non_max_suppression() got an unexpected keyword argument 'score_threshold'` on the Google Cloud since 1.8 and older does not support this keyword argument. Therefore, update this runtime version to 1.9, which is the most recent runtime version that is published on June 27, 2018. 

See 
tensorflow#5056
https://cloud.google.com/ml-engine/docs/tensorflow/runtime-version-list
tfboyd pushed a commit to tfboyd/models that referenced this issue Aug 23, 2018
The bash script to submit training job for pets detection has runtime-version of 1.8. This will trigger `TypeError: non_max_suppression() got an unexpected keyword argument 'score_threshold'` on the Google Cloud since 1.8 and older does not support this keyword argument. Therefore, update this runtime version to 1.9, which is the most recent runtime version that is published on June 27, 2018. 

See 
tensorflow#5056
https://cloud.google.com/ml-engine/docs/tensorflow/runtime-version-list
@Swaarup
Copy link

Swaarup commented Aug 29, 2018

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

@pkulzc
Copy link
Contributor

pkulzc commented Aug 29, 2018

What's the error message @Swaarup ?

@Swaarup
Copy link

Swaarup commented Aug 29, 2018 via email

@mawanda-jun
Copy link

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

@Swaarup
Copy link

Swaarup commented Sep 9, 2018 via email

@dennywangtenk
Copy link

dennywangtenk commented Oct 12, 2018

Tried TF 1.11 today, got the same error message.

It works after downgrade to TF 1.9.

@Amanpradhan
Copy link

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?

@pkulzc
Copy link
Contributor

pkulzc commented Feb 21, 2019

@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.

@MWaseemMatto
Copy link

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
Copy link

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

@Swaarup
Copy link

Swaarup commented Mar 20, 2019

@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?

@Amanpradhan
Copy link

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

@MWaseemMatto
Copy link

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

@itssp98
Copy link

itssp98 commented May 28, 2019

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?

@Amanpradhan
Copy link

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.

@lycx94
Copy link

lycx94 commented Jun 5, 2019

@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.

Can you please tell me specifically where needs to be replaced? I replaced the blocked lines but it seems not making sense and it is not working.

@pkulzc
Copy link
Contributor

pkulzc commented Jun 5, 2019

Object detection API now requires tf 1.12 so it's definitely recommended to move to 1.12 if possible.

To those who have to use 1.X version TF (X<12) :
An easier workaround would be reset your models/ repo to an earlier commit that only requires tf 1.X, and run object_detection/export_inference_graph.py to reexport the models provided/trained.

@MWaseemMatto
Copy link

MWaseemMatto commented Jun 6, 2019 via email

@liu09114
Copy link

liu09114 commented Jul 4, 2019

Below method solved perfectly(tf1.8):
In core/post_processing.py 224-246 lines, replace them with follow code:
boxlist_filtered = box_list_ops.filter_greater_than( boxlist_and_class_scores, score_thresh) if clip_window is not None: boxlist_filtered = box_list_ops.clip_to_window( boxlist_filtered, clip_window) if change_coordinate_frame: boxlist_filtered = box_list_ops.change_coordinate_frame( boxlist_filtered, clip_window) max_selection_size = tf.minimum(max_size_per_class, boxlist_filtered.num_boxes()) selected_indices = tf.image.non_max_suppression( boxlist_filtered.get(), boxlist_filtered.get_field(fields.BoxListFields.scores), max_selection_size, iou_threshold=iou_thresh) num_valid_nms_boxes = tf.shape(selected_indices)[0] selected_indices = tf.concat( [selected_indices, tf.zeros(max_selection_size-num_valid_nms_boxes, tf.int32)], 0)

@ChenSi521
Copy link

@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.

I found my nms is lost when implement 'pb'?

@rash1994
Copy link

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.

Could you load the file to unity later ?

@123Mrxiao
Copy link

我用的是1.5.0的版本,也遇到了这个问题,请问怎么办?

@ravikyram ravikyram added models:research models that come under research directory type:support labels Jul 15, 2020
@kumariko
Copy link

kumariko commented Jan 5, 2022

@aseelam We are checking to see if you still need help on this issue? We recommend that you upgrade to 2.7 which is latest stable version of TF and let us know if the issue still persists in newer versions. Also please have a look on the link . Thanks!

@kumariko kumariko added the stat:awaiting response Waiting on input from the contributor label Jan 5, 2022
@google-ml-butler
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.

@google-ml-butler
Copy link

Closing as stale. Please reopen if you'd like to work on this further.

@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
models:research models that come under research directory stale stat:awaiting response Waiting on input from the contributor type:support
Projects
None yet
Development

No branches or pull requests