0

I want to use tensorflow tf.image.non_max_suppression function.

I tried both snippets below:

indices = tf.image.non_max_suppression(
    boxes=anchors_fit, 
    scores=rpn_cls_prob,
    max_output_size=self.max_outputs_num, 
)
indices,scores = tf.image.non_max_suppression_with_scores(
    boxes=anchors_fit, 
    scores=rpn_cls_prob,
    max_output_size=self.max_outputs_num, 
)

where anchors_fit.shape is [36864,4] and rpn_cls_prob.shape is [36864]

Both calls raise:

ValueError: Shape must be rank 0 but is rank 1 for 'non_max_suppression_with_scores/NonMaxSuppressionV5' (op: 'NonMaxSuppressionV5') with input shapes: [36864,4], [36864], [1], [], [], [].

What should i do?

AlexisBRENON
  • 2,921
  • 2
  • 18
  • 30
YoM
  • 5
  • 1

1 Answers1

0

What is the shape of self.max_outputs_num?

From the documentation:

max_output_size: A scalar integer Tensor representing the maximum number of boxes to be selected by non max suppression.

Here, it seems to be an 1-D array, as the error message report it between brackets. Moreover, it would match the error message, as a scalar has a rank 0 and a 1-D array as a rank 1.

Thus, you should probably convert your self.max_outputs_num from an array to a scalar.

AlexisBRENON
  • 2,921
  • 2
  • 18
  • 30