tensorflow/models · error · ValueError

No such detection unit: {self._detection_unit}. Note that th

Error message

No such detection unit: {self._detection_unit}. Note that this error should have been raised in previous lines, not here!

What it means

Error "No such detection unit: {self._detection_unit}. Note that this error should have been raised in previous lines, not here!" thrown in tensorflow/models.

Source

Thrown at official/projects/unified_detector/data_loaders/universal_detection_parser.py:549

    gt_weights = tf.concat([tf.constant(1., shape=(1,)), gt_weights], 0)  # bkg
    if self._max_num_instance >= 0:
      gt_weights = utilities.truncate_or_pad(
          gt_weights, self._max_num_instance, 0)
    labels['instance_labels']['gt_weights'] = gt_weights

    # (8) get paragraph label
    # In this step, an array `{p_i}` is generated. `p_i` is an integer that
    # indicates the group of paragraph which i-th text belongs to. `p_i` == -1
    # if this instance is non-text or it has no paragraph labels.
    # word -> line -> paragraph
    if self._detection_unit == DetectionClass.WORD:
      num_hop = 2
    elif self._detection_unit == DetectionClass.LINE:
      num_hop = 1
    elif self._detection_unit == DetectionClass.PARAGRAPH:
      num_hop = 0
    else:
      raise ValueError(f'No such detection unit: {self._detection_unit}. '
                       'Note that this error should have been raised in '
                       'previous lines, not here!')
    para_ids = tf.identity(selected_ids)  # == id in plp + 1
    for _ in range(num_hop):
      para_ids = tf.gather(padded_parent, para_ids) + 1

    text_types = tf.concat(
        [
            tf.constant([8]),
            tf.cast(data['groundtruth_content_type'], tf.int32),
            # TODO(longshangbang): tricks for tfes that have not para labels
            tf.constant(8, shape=(1000,)),
        ],
        0)
    para_types = tf.gather(text_types, para_ids)

    para_ids = para_ids - 1  # revert to id in plp.entities; -1 for no labels
    valid_para = tf.cast(tf.not_equal(para_types, NOT_ANNOTATED_ID), tf.int32)

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/projects/unified_detector/data_loaders/universal_detection_parser.py:549 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/ee8cd53a42511c1a. Report an issue: GitHub.