{
  "id": 355342,
  "title": "How did people get local validation dice score of 0.75+ while I'm only getting 0.6?",
  "url": "/competitions/hubmap-organ-segmentation/discussion/355342",
  "author_name": "",
  "post_date": "2022-09-26T11:07:42.366386200Z",
  "votes": 1,
  "comment_count": 12,
  "views": 0,
  "content": "<p>I tried both the tiled (256x256) and also simple resize to 1024 and the model I used is the segmentation-models-pytorch unet with different backbones (e.g. efficientnet, segformer e.t.c) also with albumentations but i'm only getting 0.6 at local cv. </p>\n<p>I get similar results like this notebook. <a href=\"https://www.kaggle.com/code/bibhabasumohapatra/train-hubmap-resized-images\" target=\"_blank\">https://www.kaggle.com/code/bibhabasumohapatra/train-hubmap-resized-images</a></p>\n<p>In the end  I just gave up…. Can anyone help me and tell me what I was missing please?</p>",
  "messages": [
    {
      "id": "1956258",
      "postDate": "09/26/2022 11:07:42",
      "content": "<p>I tried both the tiled (256x256) and also simple resize to 1024 and the model I used is the segmentation-models-pytorch unet with different backbones (e.g. efficientnet, segformer e.t.c) also with albumentations but i'm only getting 0.6 at local cv. </p>\n<p>I get similar results like this notebook. <a href=\"https://www.kaggle.com/code/bibhabasumohapatra/train-hubmap-resized-images\" target=\"_blank\">https://www.kaggle.com/code/bibhabasumohapatra/train-hubmap-resized-images</a></p>\n<p>In the end  I just gave up…. Can anyone help me and tell me what I was missing please?</p>",
      "rawMarkdown": "I tried both the tiled (256x256) and also simple resize to 1024 and the model I used is the segmentation-models-pytorch unet with different backbones (e.g. efficientnet, segformer e.t.c) also with albumentations but i'm only getting 0.6 at local cv. \n\nI get similar results like this notebook. https://www.kaggle.com/code/bibhabasumohapatra/train-hubmap-resized-images\n\nIn the end  I just gave up.... Can anyone help me and tell me what I was missing please?",
      "votes": null
    },
    {
      "id": "1956353",
      "postDate": "09/26/2022 12:04:48",
      "content": "<p>Did you submit your code and check what score you've got? If your LB score is higher than 0.6, then your dice score computation function could be wrong. What was your LB score?</p>",
      "rawMarkdown": "Did you submit your code and check what score you've got? If your LB score is higher than 0.6, then your dice score computation function could be wrong. What was your LB score?",
      "votes": null
    },
    {
      "id": "1956373",
      "postDate": "09/26/2022 12:19:34",
      "content": "<p>I did not submit my code to lb, I was too sad because I was only getting 0.6 while I saw others was getting 0.75+. </p>\n<p>I dont think there is anything wrong with the dice score computation as I tested it.<br>\nI used the below to compute the dice score, which returns 0.25 correctly, the average of dice scores of the two example (0.5 and 0).</p>\n<pre><code>def DICE_COEFF(mask1, mask2):\n    intersect = torch.sum(torch.sum(mask1*mask2,axis=2),axis=2)\n    sum1 = torch.sum(torch.sum(mask1,axis=2),axis=2)\n    sum2 = torch.sum(torch.sum(mask2,axis=2),axis=2)\n    dice = 2*intersect/(sum1+sum2)\n    return torch.mean(dice).item()\n\nm1=np.array([[[0,0,1],[0,0,1],[1,0,0]],[[0,0,1],[0,0,1],[1,0,0]]]).reshape((2,1,3,3))\nm2=np.array([[[0,0,0],[0,0,0],[1,0,0]],[[0,0,0],[0,0,0],[0,0,0]]]).reshape((2,1,3,3))\n\nDICE_COEFF(torch.tensor(m1),torch.tensor(m2))\n</code></pre>",
      "rawMarkdown": "I did not submit my code to lb, I was too sad because I was only getting 0.6 while I saw others was getting 0.75+. \n\nI dont think there is anything wrong with the dice score computation as I tested it.\nI used the below to compute the dice score, which returns 0.25 correctly, the average of dice scores of the two example (0.5 and 0).\n\n```\ndef DICE_COEFF(mask1, mask2):\n    intersect = torch.sum(torch.sum(mask1*mask2,axis=2),axis=2)\n    sum1 = torch.sum(torch.sum(mask1,axis=2),axis=2)\n    sum2 = torch.sum(torch.sum(mask2,axis=2),axis=2)\n    dice = 2*intersect/(sum1+sum2)\n    return torch.mean(dice).item()\n\nm1=np.array([[[0,0,1],[0,0,1],[1,0,0]],[[0,0,1],[0,0,1],[1,0,0]]]).reshape((2,1,3,3))\nm2=np.array([[[0,0,0],[0,0,0],[1,0,0]],[[0,0,0],[0,0,0],[0,0,0]]]).reshape((2,1,3,3))\n\nDICE_COEFF(torch.tensor(m1),torch.tensor(m2))\n\n```",
      "votes": null
    },
    {
      "id": "1956386",
      "postDate": "09/26/2022 12:26:29",
      "content": "<p>What steps did u take to get local CV score of 0.75+? Did you do anything special during the preprocessing of the images? </p>\n<p>Also to add I was using an auxiliary head to predict the class of organ as well.</p>",
      "rawMarkdown": "What steps did u take to get local CV score of 0.75+? Did you do anything special during the preprocessing of the images? \n\nAlso to add I was using an auxiliary head to predict the class of organ as well.",
      "votes": null
    },
    {
      "id": "1956536",
      "postDate": "09/26/2022 13:52:13",
      "content": "<p>IMHO, you have to submit your code first in order to compare your lb score to validation score, regardless if your model converges at 0.6. It'd be a lot easier to debug your code with lb score than without it. <br>\nYou said you've tried Segformer so I think your \"basic Segformer\" model should have hit higher than 0.65 local cv, with resized images (3000-&gt;512). If it didn't, then you have to debug your code to find out what's wrong. </p>",
      "rawMarkdown": "IMHO, you have to submit your code first in order to compare your lb score to validation score, regardless if your model converges at 0.6. It'd be a lot easier to debug your code with lb score than without it. \nYou said you've tried Segformer so I think your \"basic Segformer\" model should have hit higher than 0.65 local cv, with resized images (3000->512). If it didn't, then you have to debug your code to find out what's wrong.",
      "votes": null
    },
    {
      "id": "1956599",
      "postDate": "09/26/2022 14:23:51",
      "content": "<p>Thank you! I will try again and I may be wrong with the Segformer. I used the SMP library with mit_b2 as the encoder. Which library did you use for the segformer? Also, if I may ask what was your local CV value, and if u have any tips on how to boost it up to 0.75+? That seems still like a big jump</p>",
      "rawMarkdown": "Thank you! I will try again and I may be wrong with the Segformer. I used the SMP library with mit_b2 as the encoder. Which library did you use for the segformer? Also, if I may ask what was your local CV value, and if u have any tips on how to boost it up to 0.75+? That seems still like a big jump",
      "votes": null
    },
    {
      "id": "1956656",
      "postDate": "09/26/2022 14:46:11",
      "content": "<p>Maybe you can try load the pretrained model of segformer. Loading pretrained model is very helpful for me.</p>",
      "rawMarkdown": "Maybe you can try load the pretrained model of segformer. Loading pretrained model is very helpful for me.",
      "votes": null
    },
    {
      "id": "1956717",
      "postDate": "09/26/2022 15:16:32",
      "content": "<p>Thank you, what is your local dice cv score with segformer with a simple dataset?</p>",
      "rawMarkdown": "Thank you, what is your local dice cv score with segformer with a simple dataset?",
      "votes": null
    },
    {
      "id": "1956768",
      "postDate": "09/26/2022 15:34:40",
      "content": "<p>cv 0.80+ <br>\nI forget some details. I will check them tomorrow</p>",
      "rawMarkdown": "cv 0.80+ \nI forget some details. I will check them tomorrow",
      "votes": null
    },
    {
      "id": "1957384",
      "postDate": "09/26/2022 23:48:18",
      "content": "<p>I used mmsegmentation to implement Segformer but it won't be different from segformer in the SMP library. My local cv was \"initially\" 0.77~.79 so my main focus was to reduce the gap between cv and lb, not to increase cv. By the way, have you submitted your model? What score you got?</p>",
      "rawMarkdown": "I used mmsegmentation to implement Segformer but it won't be different from segformer in the SMP library. My local cv was \"initially\" 0.77~.79 so my main focus was to reduce the gap between cv and lb, not to increase cv. By the way, have you submitted your model? What score you got?",
      "votes": null
    },
    {
      "id": "1957395",
      "postDate": "09/27/2022 00:09:19",
      "content": "<p>Thank you! One other reason I did not submit to LB is also because of the pixel issue, I did not understand why the different pixel sizes will cause an issue. Did you do any pixel adjustments when submitting to LB?</p>\n<p>I will create a simple pipeline later and submit to leaderboard</p>\n<p>Train 3000-&gt;512 with SMP Segformer encoder and albumentations.</p>\n<p>Test -&gt; Resize to 512 and predict.</p>\n<p>I will be expecting 0.6+ here probably</p>",
      "rawMarkdown": "Thank you! One other reason I did not submit to LB is also because of the pixel issue, I did not understand why the different pixel sizes will cause an issue. Did you do any pixel adjustments when submitting to LB?\n\nI will create a simple pipeline later and submit to leaderboard\n\nTrain 3000->512 with SMP Segformer encoder and albumentations.\n\nTest -> Resize to 512 and predict.\n\nI will be expecting 0.6+ here probably",
      "votes": null
    },
    {
      "id": "1957403",
      "postDate": "09/27/2022 00:34:09",
      "content": "<p>I think handling the pixel issue is not the priority. Without it, you can hit +.65. In my case, I didn't do anything for the pixel adjustments when submitting. Let me know when you submit your program and its score (including cv too).</p>",
      "rawMarkdown": "I think handling the pixel issue is not the priority. Without it, you can hit +.65. In my case, I didn't do anything for the pixel adjustments when submitting. Let me know when you submit your program and its score (including cv too).",
      "votes": null
    },
    {
      "id": "1957409",
      "postDate": "09/27/2022 00:43:57",
      "content": "<p>Ok! I will post it in 24+hours as I have work now, thanks for helping BTW!!</p>",
      "rawMarkdown": "Ok! I will post it in 24+hours as I have work now, thanks for helping BTW!!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1956353,
      "author_name": "cheulkay",
      "author_url": "",
      "post_date": "09/26/2022 12:04:48",
      "content": "<p>Did you submit your code and check what score you've got? If your LB score is higher than 0.6, then your dice score computation function could be wrong. What was your LB score?</p>",
      "votes": null,
      "replies": [
        {
          "id": 1956373,
          "author_name": "kagglerz",
          "author_url": "",
          "post_date": "09/26/2022 12:19:34",
          "content": "<p>I did not submit my code to lb, I was too sad because I was only getting 0.6 while I saw others was getting 0.75+. </p>\n<p>I dont think there is anything wrong with the dice score computation as I tested it.<br>\nI used the below to compute the dice score, which returns 0.25 correctly, the average of dice scores of the two example (0.5 and 0).</p>\n<pre><code>def DICE_COEFF(mask1, mask2):\n    intersect = torch.sum(torch.sum(mask1*mask2,axis=2),axis=2)\n    sum1 = torch.sum(torch.sum(mask1,axis=2),axis=2)\n    sum2 = torch.sum(torch.sum(mask2,axis=2),axis=2)\n    dice = 2*intersect/(sum1+sum2)\n    return torch.mean(dice).item()\n\nm1=np.array([[[0,0,1],[0,0,1],[1,0,0]],[[0,0,1],[0,0,1],[1,0,0]]]).reshape((2,1,3,3))\nm2=np.array([[[0,0,0],[0,0,0],[1,0,0]],[[0,0,0],[0,0,0],[0,0,0]]]).reshape((2,1,3,3))\n\nDICE_COEFF(torch.tensor(m1),torch.tensor(m2))\n</code></pre>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1956386,
          "author_name": "kagglerz",
          "author_url": "",
          "post_date": "09/26/2022 12:26:29",
          "content": "<p>What steps did u take to get local CV score of 0.75+? Did you do anything special during the preprocessing of the images? </p>\n<p>Also to add I was using an auxiliary head to predict the class of organ as well.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1956536,
          "author_name": "cheulkay",
          "author_url": "",
          "post_date": "09/26/2022 13:52:13",
          "content": "<p>IMHO, you have to submit your code first in order to compare your lb score to validation score, regardless if your model converges at 0.6. It'd be a lot easier to debug your code with lb score than without it. <br>\nYou said you've tried Segformer so I think your \"basic Segformer\" model should have hit higher than 0.65 local cv, with resized images (3000-&gt;512). If it didn't, then you have to debug your code to find out what's wrong. </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1956599,
          "author_name": "kagglerz",
          "author_url": "",
          "post_date": "09/26/2022 14:23:51",
          "content": "<p>Thank you! I will try again and I may be wrong with the Segformer. I used the SMP library with mit_b2 as the encoder. Which library did you use for the segformer? Also, if I may ask what was your local CV value, and if u have any tips on how to boost it up to 0.75+? That seems still like a big jump</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1957384,
          "author_name": "cheulkay",
          "author_url": "",
          "post_date": "09/26/2022 23:48:18",
          "content": "<p>I used mmsegmentation to implement Segformer but it won't be different from segformer in the SMP library. My local cv was \"initially\" 0.77~.79 so my main focus was to reduce the gap between cv and lb, not to increase cv. By the way, have you submitted your model? What score you got?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1957395,
          "author_name": "kagglerz",
          "author_url": "",
          "post_date": "09/27/2022 00:09:19",
          "content": "<p>Thank you! One other reason I did not submit to LB is also because of the pixel issue, I did not understand why the different pixel sizes will cause an issue. Did you do any pixel adjustments when submitting to LB?</p>\n<p>I will create a simple pipeline later and submit to leaderboard</p>\n<p>Train 3000-&gt;512 with SMP Segformer encoder and albumentations.</p>\n<p>Test -&gt; Resize to 512 and predict.</p>\n<p>I will be expecting 0.6+ here probably</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1957403,
          "author_name": "cheulkay",
          "author_url": "",
          "post_date": "09/27/2022 00:34:09",
          "content": "<p>I think handling the pixel issue is not the priority. Without it, you can hit +.65. In my case, I didn't do anything for the pixel adjustments when submitting. Let me know when you submit your program and its score (including cv too).</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1957409,
          "author_name": "kagglerz",
          "author_url": "",
          "post_date": "09/27/2022 00:43:57",
          "content": "<p>Ok! I will post it in 24+hours as I have work now, thanks for helping BTW!!</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1956656,
      "author_name": "gray98",
      "author_url": "",
      "post_date": "09/26/2022 14:46:11",
      "content": "<p>Maybe you can try load the pretrained model of segformer. Loading pretrained model is very helpful for me.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1956717,
          "author_name": "kagglerz",
          "author_url": "",
          "post_date": "09/26/2022 15:16:32",
          "content": "<p>Thank you, what is your local dice cv score with segformer with a simple dataset?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1956768,
          "author_name": "gray98",
          "author_url": "",
          "post_date": "09/26/2022 15:34:40",
          "content": "<p>cv 0.80+ <br>\nI forget some details. I will check them tomorrow</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1956258": "I tried both the tiled (256x256) and also simple resize to 1024 and the model I used is the segmentation-models-pytorch unet with different backbones (e.g. efficientnet, segformer e.t.c) also with albumentations but i'm only getting 0.6 at local cv. \n\nI get similar results like this notebook. https://www.kaggle.com/code/bibhabasumohapatra/train-hubmap-resized-images\n\nIn the end  I just gave up.... Can anyone help me and tell me what I was missing please?",
    "1956353": "Did you submit your code and check what score you've got? If your LB score is higher than 0.6, then your dice score computation function could be wrong. What was your LB score?",
    "1956373": "I did not submit my code to lb, I was too sad because I was only getting 0.6 while I saw others was getting 0.75+. \n\nI dont think there is anything wrong with the dice score computation as I tested it.\nI used the below to compute the dice score, which returns 0.25 correctly, the average of dice scores of the two example (0.5 and 0).\n\n```\ndef DICE_COEFF(mask1, mask2):\n    intersect = torch.sum(torch.sum(mask1*mask2,axis=2),axis=2)\n    sum1 = torch.sum(torch.sum(mask1,axis=2),axis=2)\n    sum2 = torch.sum(torch.sum(mask2,axis=2),axis=2)\n    dice = 2*intersect/(sum1+sum2)\n    return torch.mean(dice).item()\n\nm1=np.array([[[0,0,1],[0,0,1],[1,0,0]],[[0,0,1],[0,0,1],[1,0,0]]]).reshape((2,1,3,3))\nm2=np.array([[[0,0,0],[0,0,0],[1,0,0]],[[0,0,0],[0,0,0],[0,0,0]]]).reshape((2,1,3,3))\n\nDICE_COEFF(torch.tensor(m1),torch.tensor(m2))\n\n```",
    "1956386": "What steps did u take to get local CV score of 0.75+? Did you do anything special during the preprocessing of the images? \n\nAlso to add I was using an auxiliary head to predict the class of organ as well.",
    "1956536": "IMHO, you have to submit your code first in order to compare your lb score to validation score, regardless if your model converges at 0.6. It'd be a lot easier to debug your code with lb score than without it. \nYou said you've tried Segformer so I think your \"basic Segformer\" model should have hit higher than 0.65 local cv, with resized images (3000->512). If it didn't, then you have to debug your code to find out what's wrong.",
    "1956599": "Thank you! I will try again and I may be wrong with the Segformer. I used the SMP library with mit_b2 as the encoder. Which library did you use for the segformer? Also, if I may ask what was your local CV value, and if u have any tips on how to boost it up to 0.75+? That seems still like a big jump",
    "1956656": "Maybe you can try load the pretrained model of segformer. Loading pretrained model is very helpful for me.",
    "1956717": "Thank you, what is your local dice cv score with segformer with a simple dataset?",
    "1956768": "cv 0.80+ \nI forget some details. I will check them tomorrow",
    "1957384": "I used mmsegmentation to implement Segformer but it won't be different from segformer in the SMP library. My local cv was \"initially\" 0.77~.79 so my main focus was to reduce the gap between cv and lb, not to increase cv. By the way, have you submitted your model? What score you got?",
    "1957395": "Thank you! One other reason I did not submit to LB is also because of the pixel issue, I did not understand why the different pixel sizes will cause an issue. Did you do any pixel adjustments when submitting to LB?\n\nI will create a simple pipeline later and submit to leaderboard\n\nTrain 3000->512 with SMP Segformer encoder and albumentations.\n\nTest -> Resize to 512 and predict.\n\nI will be expecting 0.6+ here probably",
    "1957403": "I think handling the pixel issue is not the priority. Without it, you can hit +.65. In my case, I didn't do anything for the pixel adjustments when submitting. Let me know when you submit your program and its score (including cv too).",
    "1957409": "Ok! I will post it in 24+hours as I have work now, thanks for helping BTW!!"
  },
  "source": "meta"
}