{"record":{"id":"d3069988575f3685","repo":"tensorflow/models","slug":"no-such-detection-unit-self-detection-unit","errorCode":null,"errorMessage":"No such detection unit: {self._detection_unit}","messagePattern":"No such detection unit: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/unified_detector/data_loaders/universal_detection_parser.py","lineNumber":429,"sourceCode":"        [tf.constant([-1]),\n         tf.cast(data['groundtruth_parent'], tf.int32)], 0)\n    if self._detection_unit == DetectionClass.WORD:\n      entity_id_mask = data['resized_masks']\n    elif self._detection_unit == DetectionClass.LINE:\n      # The pixel value is entity_id + 1, shape = [H, W]; 0 for background.\n      # correctness:\n      # 0s in data['resized_masks'] --> padded_parent[0] == -1\n      # i-th entity in plp.entities --> i+1 in data['resized_masks']\n      #                             --> padded_parent[i+1]\n      #                             --> data['groundtruth_parent'][i]\n      #                             --> the parent of i-th entity\n      entity_id_mask = tf.gather(padded_parent, data['resized_masks']) + 1\n    elif self._detection_unit == DetectionClass.PARAGRAPH:\n      # directly segmenting paragraphs; two hops here.\n      entity_id_mask = tf.gather(padded_parent, data['resized_masks']) + 1\n      entity_id_mask = tf.gather(padded_parent, entity_id_mask) + 1\n    else:\n      raise ValueError(f'No such detection unit: {self._detection_unit}')\n    data['entity_id_mask'] = entity_id_mask\n\n    # (2) Get individual masks for entities.\n    entity_selection_mask = tf.equal(data['groundtruth_classes'],\n                                     self._detection_unit)\n    num_all_entity = utilities.resolve_shape(data['groundtruth_classes'])[0]\n    # entity_ids is a 1-D tensor for IDs of all entities of a certain type.\n    entity_ids = tf.boolean_mask(\n        tf.range(num_all_entity, dtype=tf.int32), entity_selection_mask)  # (N,)\n    # +1 to match the entity ids in entity_id_mask\n    entity_ids = tf.reshape(entity_ids, (-1, 1, 1)) + 1\n    individual_masks = tf.expand_dims(entity_id_mask, 0)\n    individual_masks = tf.equal(entity_ids, individual_masks)  # (N, H, W), bool\n    # TODO(longshangbang): replace with real mask sizes computing.\n    # Currently, we use full-resolution masks for individual_masks. In order to\n    # compute mask sizes, we need to convert individual_masks to int/float type.\n    # This will cause OOM because the mask is too large.\n    masks_sizes = tf.cast(","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/unified_detector/data_loaders/universal_detection_parser.py#L411-L447","documentation":"Error \"No such detection unit: {self._detection_unit}\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/unified_detector/data_loaders/universal_detection_parser.py:429 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"}