tensorflow/models · error · ValueError

No such detection unit: {self._detection_unit}

Error message

No such detection unit: {self._detection_unit}

What it means

Error "No such detection unit: {self._detection_unit}" thrown in tensorflow/models.

Source

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

        [tf.constant([-1]),
         tf.cast(data['groundtruth_parent'], tf.int32)], 0)
    if self._detection_unit == DetectionClass.WORD:
      entity_id_mask = data['resized_masks']
    elif self._detection_unit == DetectionClass.LINE:
      # The pixel value is entity_id + 1, shape = [H, W]; 0 for background.
      # correctness:
      # 0s in data['resized_masks'] --> padded_parent[0] == -1
      # i-th entity in plp.entities --> i+1 in data['resized_masks']
      #                             --> padded_parent[i+1]
      #                             --> data['groundtruth_parent'][i]
      #                             --> the parent of i-th entity
      entity_id_mask = tf.gather(padded_parent, data['resized_masks']) + 1
    elif self._detection_unit == DetectionClass.PARAGRAPH:
      # directly segmenting paragraphs; two hops here.
      entity_id_mask = tf.gather(padded_parent, data['resized_masks']) + 1
      entity_id_mask = tf.gather(padded_parent, entity_id_mask) + 1
    else:
      raise ValueError(f'No such detection unit: {self._detection_unit}')
    data['entity_id_mask'] = entity_id_mask

    # (2) Get individual masks for entities.
    entity_selection_mask = tf.equal(data['groundtruth_classes'],
                                     self._detection_unit)
    num_all_entity = utilities.resolve_shape(data['groundtruth_classes'])[0]
    # entity_ids is a 1-D tensor for IDs of all entities of a certain type.
    entity_ids = tf.boolean_mask(
        tf.range(num_all_entity, dtype=tf.int32), entity_selection_mask)  # (N,)
    # +1 to match the entity ids in entity_id_mask
    entity_ids = tf.reshape(entity_ids, (-1, 1, 1)) + 1
    individual_masks = tf.expand_dims(entity_id_mask, 0)
    individual_masks = tf.equal(entity_ids, individual_masks)  # (N, H, W), bool
    # TODO(longshangbang): replace with real mask sizes computing.
    # Currently, we use full-resolution masks for individual_masks. In order to
    # compute mask sizes, we need to convert individual_masks to int/float type.
    # This will cause OOM because the mask is too large.
    masks_sizes = tf.cast(

View on GitHub (pinned to e006f5f0d5)

When it happens

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