{
  "id": 414974,
  "title": "Clarification on the usage of character_to_prediction_index.json",
  "url": "/competitions/asl-fingerspelling/discussion/414974",
  "author_name": "Vipul Badge",
  "post_date": "2023-06-04T11:28:00.706000",
  "votes": 2,
  "comment_count": 7,
  "views": 0,
  "content": "<p>Hi, can someone clarify the exact usage of this character_to_prediction_index.json provided as a data?</p>",
  "messages": [
    {
      "id": 2287995,
      "postDate": "2023-06-05T05:35:26.483Z",
      "content": "<p>If you look at some of the notebooks and the Evaluation page details on how inference is performed - loading the json provides a character and an integer, the character_map and reverse: <br>\n<code>with open (\"/kaggle/input/asl-fingerspelling/character_to_prediction_index.json\", \"r\") as f:</code><br>\n    <code>character_map = json.load(f)</code><br>\n<code>rev_character_map = {j:i for i,j in character_map.items()}</code></p>\n<p>There are 59 (0-58) entries that will be what model is trained on and predicts and returns in REQUIRED_OUTPUT = \"outputs\".  <br>\nWhen testing your tflite model or when it is submitted REQUIRED_SIGNATURE = \"serving_default\" is checked and used. The prediction string is created using a reverse character map to go from integer back to character: <br>\n<code>interpreter = tflite.Interpreter(\"/kaggle/working/model.tflite\")</code> <br>\n<code>found_signatures = list(interpreter.get_signature_list().keys())</code><br>\n<code>if REQUIRED_SIGNATURE not in found_signatures:</code><br>\n    <code>raise KernelEvalException('Required input signature not found.')</code><br>\n<code>prediction_fn = interpreter.get_signature_runner(\"serving_default\")</code><br>\n<code>output = prediction_fn(inputs=inputs)</code><br>\n<code>prediction_str = \"\".join([rev_character_map.get(s, \"\") for s in np.argmax(output[REQUIRED_OUTPUT], axis=1)])</code></p>\n<p>e.g., if the np.argmax for the ''outputs'' in output is 32, 33, 34 it becomes \"abc\".  </p>",
      "rawMarkdown": "If you look at some of the notebooks and the Evaluation page details on how inference is performed - loading the json provides a character and an integer, the character_map and reverse: \n`with open (\"/kaggle/input/asl-fingerspelling/character_to_prediction_index.json\", \"r\") as f:`\n    `character_map = json.load(f)`\n`rev_character_map = {j:i for i,j in character_map.items()}`\n\nThere are 59 (0-58) entries that will be what model is trained on and predicts and returns in REQUIRED_OUTPUT = \"outputs\".  \nWhen testing your tflite model or when it is submitted REQUIRED_SIGNATURE = \"serving_default\" is checked and used. The prediction string is created using a reverse character map to go from integer back to character: \n`interpreter = tflite.Interpreter(\"/kaggle/working/model.tflite\")` \n`found_signatures = list(interpreter.get_signature_list().keys())`\n`if REQUIRED_SIGNATURE not in found_signatures:`\n    `    raise KernelEvalException('Required input signature not found.')`\n`prediction_fn = interpreter.get_signature_runner(\"serving_default\")`\n`output = prediction_fn(inputs=inputs)`\n`prediction_str = \"\".join([rev_character_map.get(s, \"\") for s in np.argmax(output[REQUIRED_OUTPUT], axis=1)])`\n\ne.g., if the np.argmax for the ''outputs'' in output is 32, 33, 34 it becomes \"abc\".  ",
      "votes": 2,
      "replies": [
        {
          "id": 2288007,
          "postDate": "2023-06-05T05:49:52.383Z",
          "content": "<p>So it is a map to convert our labels/ phrases- while training as well as while prediction, this map should be used to encode characters in the phrases to it's respective integers and decode them back. </p>\n<p>Please correct me if I'm wrong and thanks a lot for your inputs.</p>",
          "rawMarkdown": "So it is a map to convert our labels/ phrases- while training as well as while prediction, this map should be used to encode characters in the phrases to it's respective integers and decode them back. \n\nPlease correct me if I'm wrong and thanks a lot for your inputs.",
          "replies": [
            {
              "id": 2288017,
              "postDate": "2023-06-05T06:00:55.233Z",
              "content": "<p>Yes that is correct.  The map is probably provided so everyone does it in the same way.  </p>",
              "rawMarkdown": "Yes that is correct.  The map is probably provided so everyone does it in the same way.  ",
              "votes": 1
            },
            {
              "id": 2288053,
              "postDate": "2023-06-05T06:25:28.847Z",
              "content": "<p>Perfect! Thanks again :)</p>",
              "rawMarkdown": "Perfect! Thanks again :)"
            },
            {
              "id": 2290373,
              "postDate": "2023-06-06T18:14:07.387Z",
              "content": "<p><a href=\"https://www.kaggle.com/something4kag\" target=\"_blank\">@something4kag</a> is correct.</p>",
              "rawMarkdown": "@something4kag is correct."
            },
            {
              "id": 2302159,
              "postDate": "2023-06-14T11:31:43.323Z",
              "rawMarkdown": "",
              "isDeleted": true
            },
            {
              "id": 2302165,
              "postDate": "2023-06-14T11:33:46.367Z",
              "rawMarkdown": "",
              "isDeleted": true
            }
          ]
        }
      ]
    },
    {
      "id": 2287358,
      "postDate": "2023-06-04T11:28:00.707Z",
      "content": "<p>Hi, can someone clarify the exact usage of this character_to_prediction_index.json provided as a data?</p>",
      "rawMarkdown": "Hi, can someone clarify the exact usage of this character_to_prediction_index.json provided as a data?",
      "votes": 2
    }
  ],
  "comments": [
    {
      "id": 2287995,
      "author_name": "something4kag",
      "author_url": "",
      "post_date": "2023-06-05T05:35:26.483000",
      "content": "<p>If you look at some of the notebooks and the Evaluation page details on how inference is performed - loading the json provides a character and an integer, the character_map and reverse: <br>\n<code>with open (\"/kaggle/input/asl-fingerspelling/character_to_prediction_index.json\", \"r\") as f:</code><br>\n    <code>character_map = json.load(f)</code><br>\n<code>rev_character_map = {j:i for i,j in character_map.items()}</code></p>\n<p>There are 59 (0-58) entries that will be what model is trained on and predicts and returns in REQUIRED_OUTPUT = \"outputs\".  <br>\nWhen testing your tflite model or when it is submitted REQUIRED_SIGNATURE = \"serving_default\" is checked and used. The prediction string is created using a reverse character map to go from integer back to character: <br>\n<code>interpreter = tflite.Interpreter(\"/kaggle/working/model.tflite\")</code> <br>\n<code>found_signatures = list(interpreter.get_signature_list().keys())</code><br>\n<code>if REQUIRED_SIGNATURE not in found_signatures:</code><br>\n    <code>raise KernelEvalException('Required input signature not found.')</code><br>\n<code>prediction_fn = interpreter.get_signature_runner(\"serving_default\")</code><br>\n<code>output = prediction_fn(inputs=inputs)</code><br>\n<code>prediction_str = \"\".join([rev_character_map.get(s, \"\") for s in np.argmax(output[REQUIRED_OUTPUT], axis=1)])</code></p>\n<p>e.g., if the np.argmax for the ''outputs'' in output is 32, 33, 34 it becomes \"abc\".  </p>",
      "votes": 2,
      "replies": [
        {
          "id": 2288007,
          "author_name": "Vipul Badge",
          "author_url": "",
          "post_date": "2023-06-05T05:49:52.383000",
          "content": "<p>So it is a map to convert our labels/ phrases- while training as well as while prediction, this map should be used to encode characters in the phrases to it's respective integers and decode them back. </p>\n<p>Please correct me if I'm wrong and thanks a lot for your inputs.</p>",
          "votes": 0,
          "replies": [
            {
              "id": 2288017,
              "author_name": "something4kag",
              "author_url": "",
              "post_date": "2023-06-05T06:00:55.233000",
              "content": "<p>Yes that is correct.  The map is probably provided so everyone does it in the same way.  </p>",
              "votes": 1,
              "replies": []
            },
            {
              "id": 2288053,
              "author_name": "Vipul Badge",
              "author_url": "",
              "post_date": "2023-06-05T06:25:28.847000",
              "content": "<p>Perfect! Thanks again :)</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2290373,
              "author_name": "Sohier Dane",
              "author_url": "",
              "post_date": "2023-06-06T18:14:07.387000",
              "content": "<p><a href=\"https://www.kaggle.com/something4kag\" target=\"_blank\">@something4kag</a> is correct.</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2302159,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-06-14T11:31:43.323000",
              "content": "",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2302165,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-06-14T11:33:46.367000",
              "content": "",
              "votes": 0,
              "replies": []
            }
          ]
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2287995": "If you look at some of the notebooks and the Evaluation page details on how inference is performed - loading the json provides a character and an integer, the character_map and reverse: \n`with open (\"/kaggle/input/asl-fingerspelling/character_to_prediction_index.json\", \"r\") as f:`\n    `character_map = json.load(f)`\n`rev_character_map = {j:i for i,j in character_map.items()}`\n\nThere are 59 (0-58) entries that will be what model is trained on and predicts and returns in REQUIRED_OUTPUT = \"outputs\".  \nWhen testing your tflite model or when it is submitted REQUIRED_SIGNATURE = \"serving_default\" is checked and used. The prediction string is created using a reverse character map to go from integer back to character: \n`interpreter = tflite.Interpreter(\"/kaggle/working/model.tflite\")` \n`found_signatures = list(interpreter.get_signature_list().keys())`\n`if REQUIRED_SIGNATURE not in found_signatures:`\n    `    raise KernelEvalException('Required input signature not found.')`\n`prediction_fn = interpreter.get_signature_runner(\"serving_default\")`\n`output = prediction_fn(inputs=inputs)`\n`prediction_str = \"\".join([rev_character_map.get(s, \"\") for s in np.argmax(output[REQUIRED_OUTPUT], axis=1)])`\n\ne.g., if the np.argmax for the ''outputs'' in output is 32, 33, 34 it becomes \"abc\".  ",
    "2287358": "Hi, can someone clarify the exact usage of this character_to_prediction_index.json provided as a data?"
  }
}