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

Created on 10 Aug 2018  ·  27Comments  ·  Source: tensorflow/models

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'

research support

Most helpful comment

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!

All 27 comments

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.

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

Hi,

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

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

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

What's the error message @Swaarup ?

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 notifications@github.com 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 when you upgraded to 1.9 did you also compile protos again?

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 notifications@github.com 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
.

Tried TF 1.11 today, got the same error message.

It works after downgrade to TF 1.9.

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 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 have faced same issue with tf.v1.5 and tf.v1.9 but not solve my issue please guide me in that issue

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

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

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

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?

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

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.

Latest version of the tf 1.13 worked for me.

On Wed, 5 Jun 2019, 12:59 PM pkulzc, notifications@github.com wrote:

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.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/tensorflow/models/issues/5056?email_source=notifications&email_token=AKQKM3IUXDZQCVIP5RVG5NLPY5W63A5CNFSM4FPBS3PKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODW65DLI#issuecomment-498979245,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AKQKM3J3EA36TSTSD3AANLTPY5W63ANCNFSM4FPBS3PA
.

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)

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

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 ?

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ddurgaprasad picture ddurgaprasad  ·  48Comments

yuanzhuohao picture yuanzhuohao  ·  81Comments

wrkgm picture wrkgm  ·  78Comments

jhovell picture jhovell  ·  53Comments

10183308 picture 10183308  ·  50Comments