{"record":{"id":"ca61c9d1394de675","repo":"tensorflow/models","slug":"the-label-map-file-is-in-incorrect-format","errorCode":null,"errorMessage":"The label map file is in incorrect format.","messagePattern":"The label map file is in incorrect format\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/dataloaders/tf_example_label_map_decoder.py","lineNumber":48,"sourceCode":"               mask_binarize_threshold=None):\n    super(TfExampleDecoderLabelMap, self).__init__(\n        include_mask=include_mask, regenerate_source_id=regenerate_source_id,\n        mask_binarize_threshold=mask_binarize_threshold)\n    self._keys_to_features.update({\n        'image/object/class/text': tf.io.VarLenFeature(tf.string),\n    })\n    name_to_id = self._process_label_map(label_map)\n    self._name_to_id_table = tf.lookup.StaticHashTable(\n        tf.lookup.KeyValueTensorInitializer(\n            keys=tf.constant(list(name_to_id.keys()), dtype=tf.string),\n            values=tf.constant(list(name_to_id.values()), dtype=tf.int64)),\n        default_value=-1)\n\n  def _process_label_map(self, label_map):\n    if label_map.endswith('.csv'):\n      name_to_id = self._process_csv(label_map)\n    else:\n      raise ValueError('The label map file is in incorrect format.')\n    return name_to_id\n\n  def _process_csv(self, label_map):\n    name_to_id = {}\n    with tf.io.gfile.GFile(label_map, 'r') as f:\n      reader = csv.reader(f, delimiter=',')\n      for row in reader:\n        if len(row) != 2:\n          raise ValueError('Each row of the csv label map file must be in '\n                           '`id,name` format. length = {}'.format(len(row)))\n        id_index = int(row[0])\n        name = row[1]\n        name_to_id[name] = id_index\n    return name_to_id\n\n  def _decode_classes(self, parsed_tensors):\n    return self._name_to_id_table.lookup(\n        parsed_tensors['image/object/class/text'])","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/dataloaders/tf_example_label_map_decoder.py#L30-L66","documentation":"Error \"The label map file is in incorrect format.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/dataloaders/tf_example_label_map_decoder.py:48 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"}