{"record":{"id":"f907ea33d07ee3bf","repo":"tensorflow/models","slug":"entity-id-overflow-entity-id-currently-only-en","errorCode":null,"errorMessage":"Entity ID overflow: {entity_id}. Currently only entity_id<65536 are supported.","messagePattern":"Entity ID overflow: (.+?)\\. Currently only entity_id<65536 are supported\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/unified_detector/data_conversion/utils.py","lineNumber":112,"sourceCode":"      `annotation_to_entities`.\n    image_shape: The shape of the input image.\n  Returns:\n    A (H, W, 3) entity id mask of the same height/width as the image. Each pixel\n    (i, j, :) encodes the entity id of one pixel. Only word entities are\n    rendered. 0 for non-text pixels; word entity ids start from 1.\n  \"\"\"\n  instance_mask = np.zeros(image_shape, dtype=np.uint8)\n  for i, entity in enumerate(entities):\n    # only draw word masks\n    if entity['type'] != 1:\n      continue\n    vertices = np.array(entity['vertices'])\n    # the pixel value is actually 1 + position in entities\n    entity_id = i + 1\n    if entity_id >= 65536:\n      # As entity_id is encoded in the last two channels, it should be less than\n      # 256**2=65536.\n      raise ValueError(\n          (f'Entity ID overflow: {entity_id}. Currently only entity_id<65536 '\n           'are supported.'))\n\n    # use the last two channels to encode the entity id.\n    color = [0, entity_id // 256, entity_id % 256]\n    instance_mask = cv2.fillPoly(instance_mask,\n                                 [np.round(vertices).astype('int32')], color)\n  return instance_mask\n\n\ndef convert_to_tfe(img_file_name: str,\n                   annotation: Dict[str, Any]) -> tf.train.Example:\n  \"\"\"Convert the annotation dict into a TFExample.\"\"\"\n\n  img = cv2.imread(img_file_name)\n  img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\n  h, w, c = img.shape\n  encoded_img = encode_image(img)","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/unified_detector/data_conversion/utils.py#L94-L130","documentation":"Error \"Entity ID overflow: {entity_id}. Currently only entity_id<65536 are supported.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/unified_detector/data_conversion/utils.py:112 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"}