{
  "id": 285422,
  "title": "Train Attention based Residual Unet with watershed algorithm for instance segmentation",
  "url": "/competitions/sartorius-cell-instance-segmentation/discussion/285422",
  "author_name": "",
  "post_date": "2021-11-04T16:57:39.087727100Z",
  "votes": 16,
  "comment_count": 8,
  "views": 0,
  "content": "<p>\n<img src=\"https://i.imgur.com/m8PkdLl.jpg\">\n</p>\n<p>I have created a notebook for <a href=\"https://www.kaggle.com/soumya9977/attention-based-residual-unet-eda-on-cell-imgs\" target=\"_blank\"><strong>Attention-based Residual Unet</strong></a> with some EDA on the three cell types,  </p>\n<blockquote>\n  <ol>\n  <li>In this notebook I have tried to do a thorough analysis of different cell types given in the dataset.</li>\n  <li>Did some visualizations for different types of augmentations.</li>\n  <li>And mainly I tried to Implement Attention based Residual Unet. It is a scratch implementation.</li>\n  <li>Used tf.data for data pipeline. Tried to make this end to end, from EDA to submission.<br>\n  But there is a way to perform Instance Segmentation, which is using <code>watershed algorithm</code> with Unet. You can check out this <a href=\"https://github.com/THULiusj/Cell-segmentation-microscope-image-Unet-Watershed-AzureMachineLearningService/tree/master/unet%2Bwatershed_research_code\" target=\"_blank\">repo</a> which can help you implement that. </li>\n  </ol>\n</blockquote>",
  "messages": [
    {
      "id": "1571190",
      "postDate": "11/04/2021 16:57:39",
      "content": "<p>\n<img src=\"https://i.imgur.com/m8PkdLl.jpg\">\n</p>\n<p>I have created a notebook for <a href=\"https://www.kaggle.com/soumya9977/attention-based-residual-unet-eda-on-cell-imgs\" target=\"_blank\"><strong>Attention-based Residual Unet</strong></a> with some EDA on the three cell types,  </p>\n<blockquote>\n  <ol>\n  <li>In this notebook I have tried to do a thorough analysis of different cell types given in the dataset.</li>\n  <li>Did some visualizations for different types of augmentations.</li>\n  <li>And mainly I tried to Implement Attention based Residual Unet. It is a scratch implementation.</li>\n  <li>Used tf.data for data pipeline. Tried to make this end to end, from EDA to submission.<br>\n  But there is a way to perform Instance Segmentation, which is using <code>watershed algorithm</code> with Unet. You can check out this <a href=\"https://github.com/THULiusj/Cell-segmentation-microscope-image-Unet-Watershed-AzureMachineLearningService/tree/master/unet%2Bwatershed_research_code\" target=\"_blank\">repo</a> which can help you implement that. </li>\n  </ol>\n</blockquote>",
      "rawMarkdown": "<p align=\"center\">\n<img width = \"400\" src=\"https://i.imgur.com/m8PkdLl.jpg\">\n</p>\n \n\nI have created a notebook for [**Attention-based Residual Unet**](https://www.kaggle.com/soumya9977/attention-based-residual-unet-eda-on-cell-imgs) with some EDA on the three cell types,  \n\n> 1. In this notebook I have tried to do a thorough analysis of different cell types given in the dataset.\n2. Did some visualizations for different types of augmentations.\n3. And mainly I tried to Implement Attention based Residual Unet. It is a scratch implementation.\n4. Used tf.data for data pipeline. Tried to make this end to end, from EDA to submission.\n\nBut there is a way to perform Instance Segmentation, which is using `watershed algorithm` with Unet. You can check out this [repo](https://github.com/THULiusj/Cell-segmentation-microscope-image-Unet-Watershed-AzureMachineLearningService/tree/master/unet%2Bwatershed_research_code) which can help you implement that.",
      "votes": null
    },
    {
      "id": "1574663",
      "postDate": "11/07/2021 19:09:53",
      "content": "<p>I also believe that it is possible to reach a good score using semantic segmentation models like U-Net. In fact, at the moment, my submission is based on that idea.</p>\n<p>However, my experiments showed that applying a median filter before dividing a mask into separate masks helps. That's due to a noisy output of a U-Net model.</p>",
      "rawMarkdown": "I also believe that it is possible to reach a good score using semantic segmentation models like U-Net. In fact, at the moment, my submission is based on that idea.\n\nHowever, my experiments showed that applying a median filter before dividing a mask into separate masks helps. That's due to a noisy output of a U-Net model.",
      "votes": null
    },
    {
      "id": "1577484",
      "postDate": "11/10/2021 06:08:36",
      "content": "<p>Hi <a href=\"https://www.kaggle.com/danieliusk\" target=\"_blank\">@danieliusk</a> have you seen this <code>topic</code></p>\n<ul>\n<li><a href=\"https://www.kaggle.com/c/sartorius-cell-instance-segmentation/discussion/286553\" target=\"_blank\">UNet Strikes Back 🔥 | LB: 0.155+</a></li>\n</ul>\n<p>I was thinking that using Unet models wont work, and people were giving me the advice to use MRCNN and stuff, but I guess we can really do some improvements on it.</p>",
      "rawMarkdown": "Hi @danieliusk have you seen this `topic`\n- [UNet Strikes Back 🔥 | LB: 0.155+](https://www.kaggle.com/c/sartorius-cell-instance-segmentation/discussion/286553)\n\nI was thinking that using Unet models wont work, and people were giving me the advice to use MRCNN and stuff, but I guess we can really do some improvements on it.",
      "votes": null
    },
    {
      "id": "1577489",
      "postDate": "11/10/2021 06:13:44",
      "content": "<p>Sorry for responding late, I started doing other new competitions😅,</p>\n<p>You have seen my NB  <a href=\"https://www.kaggle.com/soumya9977/attention-based-residual-unet-eda-on-cell-imgs\" target=\"_blank\">Attention based Residual Unet + EDA on cell imgs🧬</a> right. <strong>I am having a bit of trouble doing the submission, can you please see the submission code from there, and mention what I can improve.  seems like every cell boundary prediction will come to a new row for each of the three images.</strong></p>",
      "rawMarkdown": "Sorry for responding late, I started doing other new competitions😅,\n\nYou have seen my NB  [Attention based Residual Unet + EDA on cell imgs🧬](https://www.kaggle.com/soumya9977/attention-based-residual-unet-eda-on-cell-imgs) right. **I am having a bit of trouble doing the submission, can you please see the submission code from there, and mention what I can improve.  seems like every cell boundary prediction will come to a new row for each of the three images.**",
      "votes": null
    },
    {
      "id": "1578197",
      "postDate": "11/10/2021 18:28:04",
      "content": "<p>As understand (correct me if I'm wrong) you only predict a binary mask and do not perform any splitting. To begin with, I would suggest using opencv connectedComponents, as it will help you divide mask into separate cell masks.</p>",
      "rawMarkdown": "As understand (correct me if I'm wrong) you only predict a binary mask and do not perform any splitting. To begin with, I would suggest using opencv connectedComponents, as it will help you divide mask into separate cell masks.",
      "votes": null
    },
    {
      "id": "1580033",
      "postDate": "11/12/2021 12:40:54",
      "content": "<p>Yeah, thanks <a href=\"https://www.kaggle.com/danieliusk\" target=\"_blank\">@danieliusk</a> for your advice, I was able to submit. This time submitted the <code>attention base residual Unet</code>, but the score is not much impressive, it is <code>0.036</code>. Can you give any advice on how to improve? NB: I did not add any augmentation, adding augmentation might help.</p>\n<ul>\n<li><p>I am observing that most of the Unet that are doing well are using pre-trained models. Is there any pretrained version for <code>attention-based Unet</code>? </p></li>\n<li><p>And another thing if I train my pre-trained Unet model on different backbones then <code>how can I perform ensemble for all the different backbone-based Unets?</code></p></li>\n</ul>\n<p>Sorry, for asking a lot of questions. I just dont have much experience with kaggle competitions <code>ToT</code></p>",
      "rawMarkdown": "Yeah, thanks @danieliusk for your advice, I was able to submit. This time submitted the `attention base residual Unet`, but the score is not much impressive, it is `0.036`. Can you give any advice on how to improve? NB: I did not add any augmentation, adding augmentation might help.\n\n- I am observing that most of the Unet that are doing well are using pre-trained models. Is there any pretrained version for `attention-based Unet`? \n\n- And another thing if I train my pre-trained Unet model on different backbones then `how can I perform ensemble for all the different backbone-based Unets?`\n\nSorry, for asking a lot of questions. I just dont have much experience with kaggle competitions `ToT`",
      "votes": null
    },
    {
      "id": "1580095",
      "postDate": "11/12/2021 13:20:40",
      "content": "<p>I'm glad you were able to submit :) </p>\n<p>About improving the model and score:</p>\n<ul>\n<li>I would suggest using full size images for training and using geometric augmentations. I was able to improve my score by using test time augmentations. I'm also thinking about trying different approach (for example segmenting borders, cell centers, etc.) - maybe that could help.</li>\n</ul>\n<p>About attention-based U-Net:</p>\n<ul>\n<li>I'm not sure as I'm not using attention based model. My implementation is written from scratch.</li>\n</ul>\n<p>About ensemble:</p>\n<ul>\n<li>it's quite easy to ensemble multiple U-Nets if you perform semantic segmentation. One of the simplest ways is to calculate average of outputs you get by inferring same sample through different U-Nets (before splitting mask into different instances).</li>\n</ul>\n<p>Hope that helps.</p>",
      "rawMarkdown": "I'm glad you were able to submit :) \n\nAbout improving the model and score:\n- I would suggest using full size images for training and using geometric augmentations. I was able to improve my score by using test time augmentations. I'm also thinking about trying different approach (for example segmenting borders, cell centers, etc.) - maybe that could help.\n\nAbout attention-based U-Net:\n- I'm not sure as I'm not using attention based model. My implementation is written from scratch.\n\nAbout ensemble:\n- it's quite easy to ensemble multiple U-Nets if you perform semantic segmentation. One of the simplest ways is to calculate average of outputs you get by inferring same sample through different U-Nets (before splitting mask into different instances).\n\nHope that helps.",
      "votes": null
    },
    {
      "id": "1582127",
      "postDate": "11/14/2021 15:06:40",
      "content": "<p>I don't think UNET based models are appropriate for the instance segmentation data in this competition. Most of the instances are extremely close to each other, overlapping at their borders.</p>",
      "rawMarkdown": "I don't think UNET based models are appropriate for the instance segmentation data in this competition. Most of the instances are extremely close to each other, overlapping at their borders.",
      "votes": null
    },
    {
      "id": "1582389",
      "postDate": "11/14/2021 20:50:36",
      "content": "<p>yeah, <a href=\"https://www.kaggle.com/tolgadincer\" target=\"_blank\">@tolgadincer</a> , seems like this is[overlapping issue] a major problem of the solution, this might affect the predictions, I dont know this problem is the same for MRCNN and Detectron too or not. The previous submission of mine was a simple attention-based Residual Unet without any augmentations. But now as <a href=\"https://www.kaggle.com/danieliusk\" target=\"_blank\">@danieliusk</a> suggested I tried TTA with some geometric augmentations at the training time, it seems like that this time there are some overlaps in the predictions, and I'm getting <strong>submission errors</strong> for this. I am going to try this to remove the overlaps <a href=\"https://www.kaggle.com/c/sartorius-cell-instance-segmentation/discussion/279995\" target=\"_blank\">No Overlap Issue: Quick Fix</a>. Lets see where I get. </p>\n<ul>\n<li><p>Idea from this <code>Topic</code> is not bad either, <a href=\"https://www.kaggle.com/c/sartorius-cell-instance-segmentation/discussion/286553\" target=\"_blank\">UNet Strikes Back 🔥 | LB: 0.155+</a>. Which is to perform ensemble with Unet and MRCNN.</p></li>\n<li><p>There are straight Nbs that use straight MRCNN or detectron but still get 0.2+ LB score. Compared to that Unet performance is not that bad, although, I believe that <a href=\"https://www.kaggle.com/danieliusk\" target=\"_blank\">@danieliusk</a> has achieved some good results using Unet only[0.18+ LB], and he is also thinking of improvements.</p></li>\n<li><p>I wonder what people are using to get that 0.3+ LB score.  </p></li>\n</ul>",
      "rawMarkdown": "yeah, @tolgadincer , seems like this is[overlapping issue] a major problem of the solution, this might affect the predictions, I dont know this problem is the same for MRCNN and Detectron too or not. The previous submission of mine was a simple attention-based Residual Unet without any augmentations. But now as @danieliusk suggested I tried TTA with some geometric augmentations at the training time, it seems like that this time there are some overlaps in the predictions, and I'm getting **submission errors** for this. I am going to try this to remove the overlaps [No Overlap Issue: Quick Fix](https://www.kaggle.com/c/sartorius-cell-instance-segmentation/discussion/279995). Lets see where I get. \n\n- Idea from this `Topic` is not bad either, [UNet Strikes Back 🔥 | LB: 0.155+](https://www.kaggle.com/c/sartorius-cell-instance-segmentation/discussion/286553). Which is to perform ensemble with Unet and MRCNN.\n\n- There are straight Nbs that use straight MRCNN or detectron but still get 0.2+ LB score. Compared to that Unet performance is not that bad, although, I believe that @danieliusk has achieved some good results using Unet only[0.18+ LB], and he is also thinking of improvements.\n\n- I wonder what people are using to get that 0.3+ LB score.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1574663,
      "author_name": "danieliusk",
      "author_url": "",
      "post_date": "11/07/2021 19:09:53",
      "content": "<p>I also believe that it is possible to reach a good score using semantic segmentation models like U-Net. In fact, at the moment, my submission is based on that idea.</p>\n<p>However, my experiments showed that applying a median filter before dividing a mask into separate masks helps. That's due to a noisy output of a U-Net model.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1577484,
          "author_name": "soumya9977",
          "author_url": "",
          "post_date": "11/10/2021 06:08:36",
          "content": "<p>Hi <a href=\"https://www.kaggle.com/danieliusk\" target=\"_blank\">@danieliusk</a> have you seen this <code>topic</code></p>\n<ul>\n<li><a href=\"https://www.kaggle.com/c/sartorius-cell-instance-segmentation/discussion/286553\" target=\"_blank\">UNet Strikes Back 🔥 | LB: 0.155+</a></li>\n</ul>\n<p>I was thinking that using Unet models wont work, and people were giving me the advice to use MRCNN and stuff, but I guess we can really do some improvements on it.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1577489,
          "author_name": "soumya9977",
          "author_url": "",
          "post_date": "11/10/2021 06:13:44",
          "content": "<p>Sorry for responding late, I started doing other new competitions😅,</p>\n<p>You have seen my NB  <a href=\"https://www.kaggle.com/soumya9977/attention-based-residual-unet-eda-on-cell-imgs\" target=\"_blank\">Attention based Residual Unet + EDA on cell imgs🧬</a> right. <strong>I am having a bit of trouble doing the submission, can you please see the submission code from there, and mention what I can improve.  seems like every cell boundary prediction will come to a new row for each of the three images.</strong></p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1578197,
          "author_name": "danieliusk",
          "author_url": "",
          "post_date": "11/10/2021 18:28:04",
          "content": "<p>As understand (correct me if I'm wrong) you only predict a binary mask and do not perform any splitting. To begin with, I would suggest using opencv connectedComponents, as it will help you divide mask into separate cell masks.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1580033,
          "author_name": "soumya9977",
          "author_url": "",
          "post_date": "11/12/2021 12:40:54",
          "content": "<p>Yeah, thanks <a href=\"https://www.kaggle.com/danieliusk\" target=\"_blank\">@danieliusk</a> for your advice, I was able to submit. This time submitted the <code>attention base residual Unet</code>, but the score is not much impressive, it is <code>0.036</code>. Can you give any advice on how to improve? NB: I did not add any augmentation, adding augmentation might help.</p>\n<ul>\n<li><p>I am observing that most of the Unet that are doing well are using pre-trained models. Is there any pretrained version for <code>attention-based Unet</code>? </p></li>\n<li><p>And another thing if I train my pre-trained Unet model on different backbones then <code>how can I perform ensemble for all the different backbone-based Unets?</code></p></li>\n</ul>\n<p>Sorry, for asking a lot of questions. I just dont have much experience with kaggle competitions <code>ToT</code></p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1580095,
          "author_name": "danieliusk",
          "author_url": "",
          "post_date": "11/12/2021 13:20:40",
          "content": "<p>I'm glad you were able to submit :) </p>\n<p>About improving the model and score:</p>\n<ul>\n<li>I would suggest using full size images for training and using geometric augmentations. I was able to improve my score by using test time augmentations. I'm also thinking about trying different approach (for example segmenting borders, cell centers, etc.) - maybe that could help.</li>\n</ul>\n<p>About attention-based U-Net:</p>\n<ul>\n<li>I'm not sure as I'm not using attention based model. My implementation is written from scratch.</li>\n</ul>\n<p>About ensemble:</p>\n<ul>\n<li>it's quite easy to ensemble multiple U-Nets if you perform semantic segmentation. One of the simplest ways is to calculate average of outputs you get by inferring same sample through different U-Nets (before splitting mask into different instances).</li>\n</ul>\n<p>Hope that helps.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1582127,
          "author_name": "tolgadincer",
          "author_url": "",
          "post_date": "11/14/2021 15:06:40",
          "content": "<p>I don't think UNET based models are appropriate for the instance segmentation data in this competition. Most of the instances are extremely close to each other, overlapping at their borders.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1582389,
          "author_name": "soumya9977",
          "author_url": "",
          "post_date": "11/14/2021 20:50:36",
          "content": "<p>yeah, <a href=\"https://www.kaggle.com/tolgadincer\" target=\"_blank\">@tolgadincer</a> , seems like this is[overlapping issue] a major problem of the solution, this might affect the predictions, I dont know this problem is the same for MRCNN and Detectron too or not. The previous submission of mine was a simple attention-based Residual Unet without any augmentations. But now as <a href=\"https://www.kaggle.com/danieliusk\" target=\"_blank\">@danieliusk</a> suggested I tried TTA with some geometric augmentations at the training time, it seems like that this time there are some overlaps in the predictions, and I'm getting <strong>submission errors</strong> for this. I am going to try this to remove the overlaps <a href=\"https://www.kaggle.com/c/sartorius-cell-instance-segmentation/discussion/279995\" target=\"_blank\">No Overlap Issue: Quick Fix</a>. Lets see where I get. </p>\n<ul>\n<li><p>Idea from this <code>Topic</code> is not bad either, <a href=\"https://www.kaggle.com/c/sartorius-cell-instance-segmentation/discussion/286553\" target=\"_blank\">UNet Strikes Back 🔥 | LB: 0.155+</a>. Which is to perform ensemble with Unet and MRCNN.</p></li>\n<li><p>There are straight Nbs that use straight MRCNN or detectron but still get 0.2+ LB score. Compared to that Unet performance is not that bad, although, I believe that <a href=\"https://www.kaggle.com/danieliusk\" target=\"_blank\">@danieliusk</a> has achieved some good results using Unet only[0.18+ LB], and he is also thinking of improvements.</p></li>\n<li><p>I wonder what people are using to get that 0.3+ LB score.  </p></li>\n</ul>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1571190": "<p align=\"center\">\n<img width = \"400\" src=\"https://i.imgur.com/m8PkdLl.jpg\">\n</p>\n \n\nI have created a notebook for [**Attention-based Residual Unet**](https://www.kaggle.com/soumya9977/attention-based-residual-unet-eda-on-cell-imgs) with some EDA on the three cell types,  \n\n> 1. In this notebook I have tried to do a thorough analysis of different cell types given in the dataset.\n2. Did some visualizations for different types of augmentations.\n3. And mainly I tried to Implement Attention based Residual Unet. It is a scratch implementation.\n4. Used tf.data for data pipeline. Tried to make this end to end, from EDA to submission.\n\nBut there is a way to perform Instance Segmentation, which is using `watershed algorithm` with Unet. You can check out this [repo](https://github.com/THULiusj/Cell-segmentation-microscope-image-Unet-Watershed-AzureMachineLearningService/tree/master/unet%2Bwatershed_research_code) which can help you implement that.",
    "1574663": "I also believe that it is possible to reach a good score using semantic segmentation models like U-Net. In fact, at the moment, my submission is based on that idea.\n\nHowever, my experiments showed that applying a median filter before dividing a mask into separate masks helps. That's due to a noisy output of a U-Net model.",
    "1577484": "Hi @danieliusk have you seen this `topic`\n- [UNet Strikes Back 🔥 | LB: 0.155+](https://www.kaggle.com/c/sartorius-cell-instance-segmentation/discussion/286553)\n\nI was thinking that using Unet models wont work, and people were giving me the advice to use MRCNN and stuff, but I guess we can really do some improvements on it.",
    "1577489": "Sorry for responding late, I started doing other new competitions😅,\n\nYou have seen my NB  [Attention based Residual Unet + EDA on cell imgs🧬](https://www.kaggle.com/soumya9977/attention-based-residual-unet-eda-on-cell-imgs) right. **I am having a bit of trouble doing the submission, can you please see the submission code from there, and mention what I can improve.  seems like every cell boundary prediction will come to a new row for each of the three images.**",
    "1578197": "As understand (correct me if I'm wrong) you only predict a binary mask and do not perform any splitting. To begin with, I would suggest using opencv connectedComponents, as it will help you divide mask into separate cell masks.",
    "1580033": "Yeah, thanks @danieliusk for your advice, I was able to submit. This time submitted the `attention base residual Unet`, but the score is not much impressive, it is `0.036`. Can you give any advice on how to improve? NB: I did not add any augmentation, adding augmentation might help.\n\n- I am observing that most of the Unet that are doing well are using pre-trained models. Is there any pretrained version for `attention-based Unet`? \n\n- And another thing if I train my pre-trained Unet model on different backbones then `how can I perform ensemble for all the different backbone-based Unets?`\n\nSorry, for asking a lot of questions. I just dont have much experience with kaggle competitions `ToT`",
    "1580095": "I'm glad you were able to submit :) \n\nAbout improving the model and score:\n- I would suggest using full size images for training and using geometric augmentations. I was able to improve my score by using test time augmentations. I'm also thinking about trying different approach (for example segmenting borders, cell centers, etc.) - maybe that could help.\n\nAbout attention-based U-Net:\n- I'm not sure as I'm not using attention based model. My implementation is written from scratch.\n\nAbout ensemble:\n- it's quite easy to ensemble multiple U-Nets if you perform semantic segmentation. One of the simplest ways is to calculate average of outputs you get by inferring same sample through different U-Nets (before splitting mask into different instances).\n\nHope that helps.",
    "1582127": "I don't think UNET based models are appropriate for the instance segmentation data in this competition. Most of the instances are extremely close to each other, overlapping at their borders.",
    "1582389": "yeah, @tolgadincer , seems like this is[overlapping issue] a major problem of the solution, this might affect the predictions, I dont know this problem is the same for MRCNN and Detectron too or not. The previous submission of mine was a simple attention-based Residual Unet without any augmentations. But now as @danieliusk suggested I tried TTA with some geometric augmentations at the training time, it seems like that this time there are some overlaps in the predictions, and I'm getting **submission errors** for this. I am going to try this to remove the overlaps [No Overlap Issue: Quick Fix](https://www.kaggle.com/c/sartorius-cell-instance-segmentation/discussion/279995). Lets see where I get. \n\n- Idea from this `Topic` is not bad either, [UNet Strikes Back 🔥 | LB: 0.155+](https://www.kaggle.com/c/sartorius-cell-instance-segmentation/discussion/286553). Which is to perform ensemble with Unet and MRCNN.\n\n- There are straight Nbs that use straight MRCNN or detectron but still get 0.2+ LB score. Compared to that Unet performance is not that bad, although, I believe that @danieliusk has achieved some good results using Unet only[0.18+ LB], and he is also thinking of improvements.\n\n- I wonder what people are using to get that 0.3+ LB score."
  },
  "source": "meta"
}