{
  "id": 455008,
  "title": "[Updated] Competition Scoring Problem ? [Investigation]",
  "url": "/competitions/blood-vessel-segmentation/discussion/455008",
  "author_name": "",
  "post_date": "2023-11-13T01:52:10.081155100Z",
  "votes": 8,
  "comment_count": 2,
  "views": 0,
  "content": "<h3><strong>Updates:</strong></h3>\n<p>11/13/23 : As a temporary solution to the Kaggle submission issue, <strong><em>you can use \"1 1\" instead of \"1 0\" for represent an empty mask</em></strong>. This approach will allow the scoring process to work, but be aware that it may negatively impact your score. This is just a workaround until the Kaggle team resolves the issue.</p>\n<hr>\n<p>Hello everyone,</p>\n<p>I've been encountering a persistent issue when trying to submit my results to Kaggle. No matter what I tried, including using \"1 0\" as the run-length encoding (RLE), I was faced with an error. The error can be seen in this screenshot:<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1576499%2F539cdabc1993168a2f32cdb091ccec9a%2Fscreenshot-www.kaggle.com-2023.11.12-21_32_18.png?generation=1699839162159551&amp;alt=media\" alt=\"\"></p>\n<p>Initially, I thought the issue might be with using \"1 0\" as the RLE. To test this, I trained a neural network for one epoch and submitted its results, which surprisingly worked. However, when I increased the training to 200 epochs, submissions failed again.</p>\n<p>Upon examining the test data results, I noticed that the model trained for one epoch produced random output, leading to a varied RLE. In contrast, the model trained for 200 epochs often resulted in \"1 0\" as the RLE. To address this, I modified my inference script to replace any \"0 1\" RLE with a random RLE, using this code snippet ( <a href=\"url\" target=\"_blank\">https://www.kaggle.com/code/clemchris/test-submission</a>): </p>\n<pre><code> ():\n    img = plt.imread(image_path)\n\n    \n    mask = np.zeros(img.shape[:])\n    i, j = (img.shape[] / ), (img.shape[] / )\n    mask[i:i+, j:j+] = \n\n     binary_mask_to_rle(mask)\n</code></pre>\n<p>My <code>binary_mask_to_rle</code> function is defined as follows:</p>\n<pre><code> ():\n    \n\n    \n    pixels = binary_mask.flatten()\n\n    \n    pixels = np.concatenate([[], pixels, []])\n\n    \n    runs = np.where(pixels[:] != pixels[:-])[] + \n\n    \n    runs[::] -= runs[::]\n\n    rle = .join((x)  x  runs)\n\n     (rle) == :\n         \n\n    :\n         rle\n</code></pre>\n<p>After applying this change, my submission was accepted again 🫠 (although it scored 0).</p>\n<p>So, it seems that avoiding \"1 0\" for empty masks might be necessary for the scoring process to work correctly. Has anyone else observed this issue or have any insights on it?</p>",
  "messages": [
    {
      "id": "2522727",
      "postDate": "11/13/2023 01:52:10",
      "content": "<h3><strong>Updates:</strong></h3>\n<p>11/13/23 : As a temporary solution to the Kaggle submission issue, <strong><em>you can use \"1 1\" instead of \"1 0\" for represent an empty mask</em></strong>. This approach will allow the scoring process to work, but be aware that it may negatively impact your score. This is just a workaround until the Kaggle team resolves the issue.</p>\n<hr>\n<p>Hello everyone,</p>\n<p>I've been encountering a persistent issue when trying to submit my results to Kaggle. No matter what I tried, including using \"1 0\" as the run-length encoding (RLE), I was faced with an error. The error can be seen in this screenshot:<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1576499%2F539cdabc1993168a2f32cdb091ccec9a%2Fscreenshot-www.kaggle.com-2023.11.12-21_32_18.png?generation=1699839162159551&amp;alt=media\" alt=\"\"></p>\n<p>Initially, I thought the issue might be with using \"1 0\" as the RLE. To test this, I trained a neural network for one epoch and submitted its results, which surprisingly worked. However, when I increased the training to 200 epochs, submissions failed again.</p>\n<p>Upon examining the test data results, I noticed that the model trained for one epoch produced random output, leading to a varied RLE. In contrast, the model trained for 200 epochs often resulted in \"1 0\" as the RLE. To address this, I modified my inference script to replace any \"0 1\" RLE with a random RLE, using this code snippet ( <a href=\"url\" target=\"_blank\">https://www.kaggle.com/code/clemchris/test-submission</a>): </p>\n<pre><code> ():\n    img = plt.imread(image_path)\n\n    \n    mask = np.zeros(img.shape[:])\n    i, j = (img.shape[] / ), (img.shape[] / )\n    mask[i:i+, j:j+] = \n\n     binary_mask_to_rle(mask)\n</code></pre>\n<p>My <code>binary_mask_to_rle</code> function is defined as follows:</p>\n<pre><code> ():\n    \n\n    \n    pixels = binary_mask.flatten()\n\n    \n    pixels = np.concatenate([[], pixels, []])\n\n    \n    runs = np.where(pixels[:] != pixels[:-])[] + \n\n    \n    runs[::] -= runs[::]\n\n    rle = .join((x)  x  runs)\n\n     (rle) == :\n         \n\n    :\n         rle\n</code></pre>\n<p>After applying this change, my submission was accepted again 🫠 (although it scored 0).</p>\n<p>So, it seems that avoiding \"1 0\" for empty masks might be necessary for the scoring process to work correctly. Has anyone else observed this issue or have any insights on it?</p>",
      "rawMarkdown": "### **Updates:**\n\n11/13/23 : As a temporary solution to the Kaggle submission issue, ***you can use \"1 1\" instead of \"1 0\" for represent an empty mask***. This approach will allow the scoring process to work, but be aware that it may negatively impact your score. This is just a workaround until the Kaggle team resolves the issue.\n\n--------------------------------------------------------------------------------------------------------------------------------------------------\n\nHello everyone,\n\nI've been encountering a persistent issue when trying to submit my results to Kaggle. No matter what I tried, including using \"1 0\" as the run-length encoding (RLE), I was faced with an error. The error can be seen in this screenshot:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1576499%2F539cdabc1993168a2f32cdb091ccec9a%2Fscreenshot-www.kaggle.com-2023.11.12-21_32_18.png?generation=1699839162159551&alt=media)\n\nInitially, I thought the issue might be with using \"1 0\" as the RLE. To test this, I trained a neural network for one epoch and submitted its results, which surprisingly worked. However, when I increased the training to 200 epochs, submissions failed again.\n\nUpon examining the test data results, I noticed that the model trained for one epoch produced random output, leading to a varied RLE. In contrast, the model trained for 200 epochs often resulted in \"1 0\" as the RLE. To address this, I modified my inference script to replace any \"0 1\" RLE with a random RLE, using this code snippet ( [https://www.kaggle.com/code/clemchris/test-submission](url)): \n```python\ndef dummy_result(image_path):\n    img = plt.imread(image_path)\n\n    # sample mask with rectangle\n    mask = np.zeros(img.shape[:2])\n    i, j = int(img.shape[0] / 3), int(img.shape[1] / 4)\n    mask[i:i+50, j:j+100] = 1\n    \n    return binary_mask_to_rle(mask)\n```\n\nMy `binary_mask_to_rle` function is defined as follows:\n\n```python\ndef binary_mask_to_rle(binary_mask):\n    \"\"\"\n    Convert a binary mask to Run Length Encoding (RLE).\n    Args:\n        binary_mask (ndarray): binary mask of shape [width, height]\n    Returns:\n        rle (str): run-length as string formated\n    \"\"\"\n\n    # Flatten the mask\n    pixels = binary_mask.flatten()\n\n    # Pad the start and end with zero to capture runs that might start or end at the edges\n    pixels = np.concatenate([[0], pixels, [0]])\n\n    # Find where the pixels change\n    runs = np.where(pixels[1:] != pixels[:-1])[0] + 1\n\n    # Ensure that every second element subtracts the one before it\n    runs[1::2] -= runs[::2]\n\n    rle = \" \".join(str(x) for x in runs)\n\n    if len(rle) == 0:\n        return \"1 0\"\n\n    else:\n        return rle\n```\nAfter applying this change, my submission was accepted again 🫠 (although it scored 0).\n\nSo, it seems that avoiding \"1 0\" for empty masks might be necessary for the scoring process to work correctly. Has anyone else observed this issue or have any insights on it?",
      "votes": null
    },
    {
      "id": "2522866",
      "postDate": "11/13/2023 05:57:06",
      "content": "<p>OMG! Now I want to see the code that passes with 0 1 used in sample_submission but fails when passed to test submission.<br>\nIt is clear that this is a bug and should be corrected. The test code should either allow 0 1 or empty as a valid answer as anything else introduces non-zero mask and thus is penalized by the metric.</p>",
      "rawMarkdown": "OMG! Now I want to see the code that passes with 0 1 used in sample_submission but fails when passed to test submission.\nIt is clear that this is a bug and should be corrected. The test code should either allow 0 1 or empty as a valid answer as anything else introduces non-zero mask and thus is penalized by the metric.",
      "votes": null
    },
    {
      "id": "2523505",
      "postDate": "11/13/2023 14:37:35",
      "content": "<p>True, I think that everybody is using the \"1 1\" trick now before it gets fixed.</p>",
      "rawMarkdown": "True, I think that everybody is using the \"1 1\" trick now before it gets fixed.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2522866,
      "author_name": "sakvaua",
      "author_url": "",
      "post_date": "11/13/2023 05:57:06",
      "content": "<p>OMG! Now I want to see the code that passes with 0 1 used in sample_submission but fails when passed to test submission.<br>\nIt is clear that this is a bug and should be corrected. The test code should either allow 0 1 or empty as a valid answer as anything else introduces non-zero mask and thus is penalized by the metric.</p>",
      "votes": null,
      "replies": [
        {
          "id": 2523505,
          "author_name": "abdrah",
          "author_url": "",
          "post_date": "11/13/2023 14:37:35",
          "content": "<p>True, I think that everybody is using the \"1 1\" trick now before it gets fixed.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2522727": "### **Updates:**\n\n11/13/23 : As a temporary solution to the Kaggle submission issue, ***you can use \"1 1\" instead of \"1 0\" for represent an empty mask***. This approach will allow the scoring process to work, but be aware that it may negatively impact your score. This is just a workaround until the Kaggle team resolves the issue.\n\n--------------------------------------------------------------------------------------------------------------------------------------------------\n\nHello everyone,\n\nI've been encountering a persistent issue when trying to submit my results to Kaggle. No matter what I tried, including using \"1 0\" as the run-length encoding (RLE), I was faced with an error. The error can be seen in this screenshot:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1576499%2F539cdabc1993168a2f32cdb091ccec9a%2Fscreenshot-www.kaggle.com-2023.11.12-21_32_18.png?generation=1699839162159551&alt=media)\n\nInitially, I thought the issue might be with using \"1 0\" as the RLE. To test this, I trained a neural network for one epoch and submitted its results, which surprisingly worked. However, when I increased the training to 200 epochs, submissions failed again.\n\nUpon examining the test data results, I noticed that the model trained for one epoch produced random output, leading to a varied RLE. In contrast, the model trained for 200 epochs often resulted in \"1 0\" as the RLE. To address this, I modified my inference script to replace any \"0 1\" RLE with a random RLE, using this code snippet ( [https://www.kaggle.com/code/clemchris/test-submission](url)): \n```python\ndef dummy_result(image_path):\n    img = plt.imread(image_path)\n\n    # sample mask with rectangle\n    mask = np.zeros(img.shape[:2])\n    i, j = int(img.shape[0] / 3), int(img.shape[1] / 4)\n    mask[i:i+50, j:j+100] = 1\n    \n    return binary_mask_to_rle(mask)\n```\n\nMy `binary_mask_to_rle` function is defined as follows:\n\n```python\ndef binary_mask_to_rle(binary_mask):\n    \"\"\"\n    Convert a binary mask to Run Length Encoding (RLE).\n    Args:\n        binary_mask (ndarray): binary mask of shape [width, height]\n    Returns:\n        rle (str): run-length as string formated\n    \"\"\"\n\n    # Flatten the mask\n    pixels = binary_mask.flatten()\n\n    # Pad the start and end with zero to capture runs that might start or end at the edges\n    pixels = np.concatenate([[0], pixels, [0]])\n\n    # Find where the pixels change\n    runs = np.where(pixels[1:] != pixels[:-1])[0] + 1\n\n    # Ensure that every second element subtracts the one before it\n    runs[1::2] -= runs[::2]\n\n    rle = \" \".join(str(x) for x in runs)\n\n    if len(rle) == 0:\n        return \"1 0\"\n\n    else:\n        return rle\n```\nAfter applying this change, my submission was accepted again 🫠 (although it scored 0).\n\nSo, it seems that avoiding \"1 0\" for empty masks might be necessary for the scoring process to work correctly. Has anyone else observed this issue or have any insights on it?",
    "2522866": "OMG! Now I want to see the code that passes with 0 1 used in sample_submission but fails when passed to test submission.\nIt is clear that this is a bug and should be corrected. The test code should either allow 0 1 or empty as a valid answer as anything else introduces non-zero mask and thus is penalized by the metric.",
    "2523505": "True, I think that everybody is using the \"1 1\" trick now before it gets fixed."
  },
  "source": "meta"
}