{"record":{"id":"ee8cd53a42511c1a","repo":"tensorflow/models","slug":"no-such-detection-unit-self-detection-unit-no","errorCode":null,"errorMessage":"No such detection unit: {self._detection_unit}. Note that this error should have been raised in previous lines, not here!","messagePattern":"No such detection unit: (.+?)\\. Note that this error should have been raised in previous lines, not here!","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/unified_detector/data_loaders/universal_detection_parser.py","lineNumber":549,"sourceCode":"    gt_weights = tf.concat([tf.constant(1., shape=(1,)), gt_weights], 0)  # bkg\n    if self._max_num_instance >= 0:\n      gt_weights = utilities.truncate_or_pad(\n          gt_weights, self._max_num_instance, 0)\n    labels['instance_labels']['gt_weights'] = gt_weights\n\n    # (8) get paragraph label\n    # In this step, an array `{p_i}` is generated. `p_i` is an integer that\n    # indicates the group of paragraph which i-th text belongs to. `p_i` == -1\n    # if this instance is non-text or it has no paragraph labels.\n    # word -> line -> paragraph\n    if self._detection_unit == DetectionClass.WORD:\n      num_hop = 2\n    elif self._detection_unit == DetectionClass.LINE:\n      num_hop = 1\n    elif self._detection_unit == DetectionClass.PARAGRAPH:\n      num_hop = 0\n    else:\n      raise ValueError(f'No such detection unit: {self._detection_unit}. '\n                       'Note that this error should have been raised in '\n                       'previous lines, not here!')\n    para_ids = tf.identity(selected_ids)  # == id in plp + 1\n    for _ in range(num_hop):\n      para_ids = tf.gather(padded_parent, para_ids) + 1\n\n    text_types = tf.concat(\n        [\n            tf.constant([8]),\n            tf.cast(data['groundtruth_content_type'], tf.int32),\n            # TODO(longshangbang): tricks for tfes that have not para labels\n            tf.constant(8, shape=(1000,)),\n        ],\n        0)\n    para_types = tf.gather(text_types, para_ids)\n\n    para_ids = para_ids - 1  # revert to id in plp.entities; -1 for no labels\n    valid_para = tf.cast(tf.not_equal(para_types, NOT_ANNOTATED_ID), tf.int32)","sourceCodeStart":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/unified_detector/data_loaders/universal_detection_parser.py#L531-L567","documentation":"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.","triggerScenarios":"Thrown at official/projects/unified_detector/data_loaders/universal_detection_parser.py:549 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}