tensorflow/models · error · ValueError
Scores should have rank 1 or have shape consistent with [Non
Error message
Scores should have rank 1 or have shape consistent with [None, 1]
What it means
Error "Scores should have rank 1 or have shape consistent with [None, 1]" thrown in tensorflow/models.
Source
Thrown at official/vision/utils/object_detection/box_list_ops.py:722
scope: name scope.
Returns:
a BoxList holding M boxes where M <= N
Raises:
ValueError: if boxlist not a BoxList object or if it does not
have a scores field
"""
with tf.name_scope(scope or 'FilterGreaterThan'):
if not isinstance(boxlist, box_list.BoxList):
raise ValueError('boxlist must be a BoxList')
if not boxlist.has_field('scores'):
raise ValueError('input boxlist must have \'scores\' field')
scores = boxlist.get_field('scores')
if len(scores.shape.as_list()) > 2:
raise ValueError('Scores should have rank 1 or 2')
if len(scores.shape.as_list()) == 2 and scores.shape.as_list()[1] != 1:
raise ValueError('Scores should have rank 1 or have shape '
'consistent with [None, 1]')
high_score_indices = tf.cast(
tf.reshape(tf.where(tf.greater(scores, thresh)), [-1]), tf.int32)
return gather(boxlist, high_score_indices)
def non_max_suppression(boxlist, thresh, max_output_size, scope=None):
"""Non maximum suppression.
This op greedily selects a subset of detection bounding boxes, pruning
away boxes that have high IOU (intersection over union) overlap (> thresh)
with already selected boxes. Note that this only works for a single class ---
to apply NMS to multi-class predictions, use MultiClassNonMaxSuppression.
Args:
boxlist: BoxList holding N boxes. Must contain a 'scores' field
representing detection scores.
thresh: scalar thresholdView on GitHub (pinned to e006f5f0d5)
Solutions
- Pass scores with rank 1 or shape [N, 1].
- Squeeze extra dimensions from the scores tensor.
When it happens
Trigger: Thrown at official/vision/utils/object_detection/box_list_ops.py:722 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/d6b17acada8bb177.
Report an issue: GitHub.