{
  "id": 165223,
  "title": "Segmentation before classification",
  "url": "/competitions/siim-isic-melanoma-classification/discussion/165223",
  "author_name": "Zakirov Jamil",
  "post_date": "2020-07-08T22:10:21.096000",
  "votes": 14,
  "comment_count": 15,
  "views": 0,
  "content": "<p>Hi, fellow Kagglers.</p>\n\n<p>I noticed that original image size varies significantly from relatively small to really big (see image attached). In most of the kernels authors resize images to some fixed size (like 512x512), but in cases when most of the image is skin and nevus/melanoma takes just a small part this approach leads to huge loss of relevant information. </p>\n\n<p>Have anyone tried first segmenting skin lesions, then cropping them from the image and only after that resizing to fixed resolution?\nIt looks like a simple idea to boost your scores, but I couldn't find any relevant paper. If someone did, please share! </p>\n\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2364386%2F84d9b7ec31f685fd6b3c04e3d41b9ef6%2FScreenshot%202020-07-09%20at%2001.04.34.png?generation=1594245962900331&amp;alt=media\" alt=\"\"></p>",
  "messages": [
    {
      "id": 920891,
      "postDate": "2020-07-08T22:10:21.097Z",
      "content": "<p>Hi, fellow Kagglers.</p>\n\n<p>I noticed that original image size varies significantly from relatively small to really big (see image attached). In most of the kernels authors resize images to some fixed size (like 512x512), but in cases when most of the image is skin and nevus/melanoma takes just a small part this approach leads to huge loss of relevant information. </p>\n\n<p>Have anyone tried first segmenting skin lesions, then cropping them from the image and only after that resizing to fixed resolution?\nIt looks like a simple idea to boost your scores, but I couldn't find any relevant paper. If someone did, please share! </p>\n\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2364386%2F84d9b7ec31f685fd6b3c04e3d41b9ef6%2FScreenshot%202020-07-09%20at%2001.04.34.png?generation=1594245962900331&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "Hi, fellow Kagglers.\n\nI noticed that original image size varies significantly from relatively small to really big (see image attached). In most of the kernels authors resize images to some fixed size (like 512x512), but in cases when most of the image is skin and nevus/melanoma takes just a small part this approach leads to huge loss of relevant information. \n\nHave anyone tried first segmenting skin lesions, then cropping them from the image and only after that resizing to fixed resolution?\nIt looks like a simple idea to boost your scores, but I couldn't find any relevant paper. If someone did, please share! \n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2364386%2F84d9b7ec31f685fd6b3c04e3d41b9ef6%2FScreenshot%202020-07-09%20at%2001.04.34.png?generation=1594245962900331&amp;alt=media)\n",
      "votes": 14
    },
    {
      "id": 922189,
      "postDate": "2020-07-09T21:43:17.750Z",
      "content": "<p>Your idea is good, however, I see serious problem with implementation - how can you do segmentation without any masks for images? I mean how do you train your model if you don't know what should segmentation look like?</p>",
      "rawMarkdown": "Your idea is good, however, I see serious problem with implementation - how can you do segmentation without any masks for images? I mean how do you train your model if you don't know what should segmentation look like?",
      "votes": 1,
      "replies": [
        {
          "id": 922537,
          "postDate": "2020-07-10T07:24:31.880Z",
          "content": "<p>I'm using data from ISIC2019 and ISIC Archive, which contains ~11.000 segmentation masks. Model trains <em>really</em> fast, because it's an easy task. Got 0.9+ IoU after 15 epochs</p>",
          "rawMarkdown": "I'm using data from ISIC2019 and ISIC Archive, which contains ~11.000 segmentation masks. Model trains *really* fast, because it's an easy task. Got 0.9+ IoU after 15 epochs",
          "votes": 1
        },
        {
          "id": 922664,
          "postDate": "2020-07-10T09:02:49.977Z",
          "content": "<p>very interesting, thanks for sharing</p>",
          "rawMarkdown": "very interesting, thanks for sharing"
        },
        {
          "id": 924555,
          "postDate": "2020-07-11T13:56:25.813Z",
          "content": "<p>fyi, you should be able to double the training data with this: <a href=\"https://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/163650\">https://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/163650</a></p>",
          "rawMarkdown": "fyi, you should be able to double the training data with this: https://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/163650"
        },
        {
          "id": 924817,
          "postDate": "2020-07-11T16:33:06.057Z",
          "rawMarkdown": "",
          "isDeleted": true
        },
        {
          "id": 925757,
          "postDate": "2020-07-12T09:44:51.160Z",
          "content": "<p><a href=\"/synked\">@synked</a> You are right, there is no segmentation in ISIC 2019, I'm using only Archive data for now</p>",
          "rawMarkdown": "@synked You are right, there is no segmentation in ISIC 2019, I'm using only Archive data for now"
        }
      ]
    },
    {
      "id": 928332,
      "postDate": "2020-07-13T22:07:27.543Z",
      "content": "<p>interesting observation, need to experience</p>",
      "rawMarkdown": "interesting observation, need to experience"
    },
    {
      "id": 925382,
      "postDate": "2020-07-12T03:49:45.840Z",
      "content": "<p>I had a go at using some non-CNN based segmentations to define bounding boxes and crop the images here:\n<a href=\"https://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/163930\">https://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/163930</a></p>\n\n<p>I found that just using center crops worked better. I think I have a much more robust pipeline now though so I might retry it and see if there are any improvements.</p>",
      "rawMarkdown": "I had a go at using some non-CNN based segmentations to define bounding boxes and crop the images here:\nhttps://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/163930\n\nI found that just using center crops worked better. I think I have a much more robust pipeline now though so I might retry it and see if there are any improvements."
    },
    {
      "id": 924886,
      "postDate": "2020-07-11T17:14:51.470Z",
      "content": "<p>Here is a paper in which segmentation was applied as a pre-processing step for a classifier, here\nhowever it was not simply about identifying the lesion but also any relevant sub-patches that may contribute to the \nprediction: <a href=\"https://www.nature.com/articles/s41591-018-0107-6\">https://www.nature.com/articles/s41591-018-0107-6</a></p>\n\n<p>Image segmentation is primarily useful for reproducibility, to indeed avoid any bias due to systematic image shifting.</p>",
      "rawMarkdown": "Here is a paper in which segmentation was applied as a pre-processing step for a classifier, here\nhowever it was not simply about identifying the lesion but also any relevant sub-patches that may contribute to the \nprediction: https://www.nature.com/articles/s41591-018-0107-6\n\nImage segmentation is primarily useful for reproducibility, to indeed avoid any bias due to systematic image shifting."
    },
    {
      "id": 922568,
      "postDate": "2020-07-10T07:51:12.640Z",
      "content": "<p>Many people are center-cropping the images before resizing. I'm pretty sure this already works well and makes sure the aspect ratio is the same for all images (1:1) (as the moles are often centered as well).</p>",
      "rawMarkdown": "Many people are center-cropping the images before resizing. I'm pretty sure this already works well and makes sure the aspect ratio is the same for all images (1:1) (as the moles are often centered as well).",
      "replies": [
        {
          "id": 922599,
          "postDate": "2020-07-10T08:19:09.963Z",
          "content": "<p>How to choose correct size for initial center-cropping? </p>\n\n<p>I'm doing in slightly different way now. I first resize with keeping original aspect ration and setting smallest side to, for example 512, and then make center crop. This makes it's easier to keep nevus on the image, but not always works perfect </p>",
          "rawMarkdown": "How to choose correct size for initial center-cropping? \n \nI'm doing in slightly different way now. I first resize with keeping original aspect ration and setting smallest side to, for example 512, and then make center crop. This makes it's easier to keep nevus on the image, but not always works perfect "
        },
        {
          "id": 922624,
          "postDate": "2020-07-10T08:36:54.990Z",
          "content": "<p>Center cropping will just cut off the sides from the longest axis (which is height in this dataset if I am not mistaken).</p>\n\n<p>So if your height is 1000 and width 500, then you cut 250 pixels from the upper and bottom side.</p>\n\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F443651%2F28d85e8301f488a5d5f890ef1ee9b0fa%2Fcenter_crop.png?generation=1594370198067768&amp;alt=media\" alt=\"\"></p>",
          "rawMarkdown": "Center cropping will just cut off the sides from the longest axis (which is height in this dataset if I am not mistaken).\n\nSo if your height is 1000 and width 500, then you cut 250 pixels from the upper and bottom side.\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F443651%2F28d85e8301f488a5d5f890ef1ee9b0fa%2Fcenter_crop.png?generation=1594370198067768&amp;alt=media)\n",
          "votes": 1
        },
        {
          "id": 924762,
          "postDate": "2020-07-11T16:10:12.163Z",
          "content": "<p>You are both describing the same thing. You are both doing \"center square crop resize\" which is done in all my TFRecords and JPEG datasets</p>",
          "rawMarkdown": "You are both describing the same thing. You are both doing \"center square crop resize\" which is done in all my TFRecords and JPEG datasets",
          "votes": 1
        },
        {
          "id": 924820,
          "postDate": "2020-07-11T16:34:15.117Z",
          "content": "<p>Well smart cropping seems like a promising idea, imagine that the sun here represents a mole, center cropping would lose most of the information about the mole.</p>\n\n<p>If you are able to know where the mole is, then you can do a smart cropping.</p>\n\n<p>I personally only worked with simple resize (no cropping) for the moment, has anyone measure the uplift of working with center cropped images?</p>",
          "rawMarkdown": "Well smart cropping seems like a promising idea, imagine that the sun here represents a mole, center cropping would lose most of the information about the mole.\n\nIf you are able to know where the mole is, then you can do a smart cropping.\n\nI personally only worked with simple resize (no cropping) for the moment, has anyone measure the uplift of working with center cropped images?"
        },
        {
          "id": 924831,
          "postDate": "2020-07-11T16:39:32.710Z",
          "content": "<p>Since the mole is the reason the doctor takes the photo, most moles are centered in the picture.</p>",
          "rawMarkdown": "Since the mole is the reason the doctor takes the photo, most moles are centered in the picture.",
          "votes": 2
        }
      ]
    }
  ],
  "comments": [
    {
      "id": 922189,
      "author_name": "Jacek Poplawski",
      "author_url": "",
      "post_date": "2020-07-09T21:43:17.750000",
      "content": "<p>Your idea is good, however, I see serious problem with implementation - how can you do segmentation without any masks for images? I mean how do you train your model if you don't know what should segmentation look like?</p>",
      "votes": 1,
      "replies": [
        {
          "id": 922537,
          "author_name": "Zakirov Jamil",
          "author_url": "",
          "post_date": "2020-07-10T07:24:31.880000",
          "content": "<p>I'm using data from ISIC2019 and ISIC Archive, which contains ~11.000 segmentation masks. Model trains <em>really</em> fast, because it's an easy task. Got 0.9+ IoU after 15 epochs</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 922664,
          "author_name": "Jacek Poplawski",
          "author_url": "",
          "post_date": "2020-07-10T09:02:49.977000",
          "content": "<p>very interesting, thanks for sharing</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 924555,
          "author_name": "chdlr",
          "author_url": "",
          "post_date": "2020-07-11T13:56:25.813000",
          "content": "<p>fyi, you should be able to double the training data with this: <a href=\"https://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/163650\">https://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/163650</a></p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 924817,
          "author_name": "",
          "author_url": "",
          "post_date": "2020-07-11T16:33:06.057000",
          "content": "",
          "votes": 0,
          "replies": []
        },
        {
          "id": 925757,
          "author_name": "Zakirov Jamil",
          "author_url": "",
          "post_date": "2020-07-12T09:44:51.160000",
          "content": "<p><a href=\"/synked\">@synked</a> You are right, there is no segmentation in ISIC 2019, I'm using only Archive data for now</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 928332,
      "author_name": "Aleksandr Vasilev",
      "author_url": "",
      "post_date": "2020-07-13T22:07:27.543000",
      "content": "<p>interesting observation, need to experience</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 925382,
      "author_name": "datasaurus",
      "author_url": "",
      "post_date": "2020-07-12T03:49:45.840000",
      "content": "<p>I had a go at using some non-CNN based segmentations to define bounding boxes and crop the images here:\n<a href=\"https://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/163930\">https://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/163930</a></p>\n\n<p>I found that just using center crops worked better. I think I have a much more robust pipeline now though so I might retry it and see if there are any improvements.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 924886,
      "author_name": "Bram Van Es",
      "author_url": "",
      "post_date": "2020-07-11T17:14:51.470000",
      "content": "<p>Here is a paper in which segmentation was applied as a pre-processing step for a classifier, here\nhowever it was not simply about identifying the lesion but also any relevant sub-patches that may contribute to the \nprediction: <a href=\"https://www.nature.com/articles/s41591-018-0107-6\">https://www.nature.com/articles/s41591-018-0107-6</a></p>\n\n<p>Image segmentation is primarily useful for reproducibility, to indeed avoid any bias due to systematic image shifting.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 922568,
      "author_name": "Gilles Vandewiele",
      "author_url": "",
      "post_date": "2020-07-10T07:51:12.640000",
      "content": "<p>Many people are center-cropping the images before resizing. I'm pretty sure this already works well and makes sure the aspect ratio is the same for all images (1:1) (as the moles are often centered as well).</p>",
      "votes": 0,
      "replies": [
        {
          "id": 922599,
          "author_name": "Zakirov Jamil",
          "author_url": "",
          "post_date": "2020-07-10T08:19:09.963000",
          "content": "<p>How to choose correct size for initial center-cropping? </p>\n\n<p>I'm doing in slightly different way now. I first resize with keeping original aspect ration and setting smallest side to, for example 512, and then make center crop. This makes it's easier to keep nevus on the image, but not always works perfect </p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 922624,
          "author_name": "Gilles Vandewiele",
          "author_url": "",
          "post_date": "2020-07-10T08:36:54.990000",
          "content": "<p>Center cropping will just cut off the sides from the longest axis (which is height in this dataset if I am not mistaken).</p>\n\n<p>So if your height is 1000 and width 500, then you cut 250 pixels from the upper and bottom side.</p>\n\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F443651%2F28d85e8301f488a5d5f890ef1ee9b0fa%2Fcenter_crop.png?generation=1594370198067768&amp;alt=media\" alt=\"\"></p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 924762,
          "author_name": "Chris Deotte",
          "author_url": "",
          "post_date": "2020-07-11T16:10:12.163000",
          "content": "<p>You are both describing the same thing. You are both doing \"center square crop resize\" which is done in all my TFRecords and JPEG datasets</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 924820,
          "author_name": "Optimo",
          "author_url": "",
          "post_date": "2020-07-11T16:34:15.117000",
          "content": "<p>Well smart cropping seems like a promising idea, imagine that the sun here represents a mole, center cropping would lose most of the information about the mole.</p>\n\n<p>If you are able to know where the mole is, then you can do a smart cropping.</p>\n\n<p>I personally only worked with simple resize (no cropping) for the moment, has anyone measure the uplift of working with center cropped images?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 924831,
          "author_name": "Chris Deotte",
          "author_url": "",
          "post_date": "2020-07-11T16:39:32.710000",
          "content": "<p>Since the mole is the reason the doctor takes the photo, most moles are centered in the picture.</p>",
          "votes": 2,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "920891": "Hi, fellow Kagglers.\n\nI noticed that original image size varies significantly from relatively small to really big (see image attached). In most of the kernels authors resize images to some fixed size (like 512x512), but in cases when most of the image is skin and nevus/melanoma takes just a small part this approach leads to huge loss of relevant information. \n\nHave anyone tried first segmenting skin lesions, then cropping them from the image and only after that resizing to fixed resolution?\nIt looks like a simple idea to boost your scores, but I couldn't find any relevant paper. If someone did, please share! \n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2364386%2F84d9b7ec31f685fd6b3c04e3d41b9ef6%2FScreenshot%202020-07-09%20at%2001.04.34.png?generation=1594245962900331&amp;alt=media)\n",
    "922189": "Your idea is good, however, I see serious problem with implementation - how can you do segmentation without any masks for images? I mean how do you train your model if you don't know what should segmentation look like?",
    "928332": "interesting observation, need to experience",
    "925382": "I had a go at using some non-CNN based segmentations to define bounding boxes and crop the images here:\nhttps://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/163930\n\nI found that just using center crops worked better. I think I have a much more robust pipeline now though so I might retry it and see if there are any improvements.",
    "924886": "Here is a paper in which segmentation was applied as a pre-processing step for a classifier, here\nhowever it was not simply about identifying the lesion but also any relevant sub-patches that may contribute to the \nprediction: https://www.nature.com/articles/s41591-018-0107-6\n\nImage segmentation is primarily useful for reproducibility, to indeed avoid any bias due to systematic image shifting.",
    "922568": "Many people are center-cropping the images before resizing. I'm pretty sure this already works well and makes sure the aspect ratio is the same for all images (1:1) (as the moles are often centered as well)."
  }
}