tensorflow/models · error · ValueError

iou_thresh must be between 0 and 1

Error message

iou_thresh must be between 0 and 1

What it means

Error "iou_thresh must be between 0 and 1" thrown in tensorflow/models.

Source

Thrown at official/vision/utils/object_detection/box_list_ops.py:975

  Args:
    selected_boxes: BoxList containing a subset of boxes in pool_boxes. These
      boxes are usually selected from pool_boxes using non max suppression.
    pool_boxes: BoxList containing a set of (possibly redundant) boxes.
    iou_thresh: (float scalar) iou threshold for matching boxes in
      selected_boxes and pool_boxes.

  Returns:
    BoxList containing averaged locations and scores for each box in
    selected_boxes.

  Raises:
    ValueError: if
      a) selected_boxes or pool_boxes is not a BoxList.
      b) if iou_thresh is not in [0, 1].
      c) pool_boxes does not have a scores field.
  """
  if not 0.0 <= iou_thresh <= 1.0:
    raise ValueError('iou_thresh must be between 0 and 1')
  if not isinstance(selected_boxes, box_list.BoxList):
    raise ValueError('selected_boxes must be a BoxList')
  if not isinstance(pool_boxes, box_list.BoxList):
    raise ValueError('pool_boxes must be a BoxList')
  if not pool_boxes.has_field('scores'):
    raise ValueError('pool_boxes must have a \'scores\' field')

  iou_ = iou(selected_boxes, pool_boxes)
  match_indicator = tf.cast(tf.greater(iou_, iou_thresh), dtype=tf.float32)
  num_matches = tf.reduce_sum(match_indicator, 1)
  # TODO(kbanoop): Handle the case where some boxes in selected_boxes do not
  # match to any boxes in pool_boxes. For such boxes without any matches, we
  # should return the original boxes without voting.
  match_assert = tf.Assert(
      tf.reduce_all(tf.greater(num_matches, 0)),
      'Each box in selected_boxes must match with at least one box '
      'in pool_boxes.')

View on GitHub (pinned to e006f5f0d5)

Solutions

  1. Set iou_thresh to a value between 0 and 1.
  2. Clip the IoU threshold into [0, 1] in the config.

When it happens

Trigger: Thrown at official/vision/utils/object_detection/box_list_ops.py:975 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/3cb6cd2b96a78a54. Report an issue: GitHub.