{
  "id": 354857,
  "title": "2nd Place Solution",
  "url": "/competitions/hubmap-organ-segmentation/discussion/354857",
  "author_name": "Victor Durnov",
  "post_date": "2022-09-24T09:25:54.665000",
  "votes": 56,
  "comment_count": 11,
  "views": 0,
  "content": "<p>Big thanks to the organizers for the great competition!<br>\nAlso thanks to all competitors for sharing their experiments here, especially <a href=\"https://www.kaggle.com/hengck23\" target=\"_blank\">@hengck23</a></p>\n<h1>Models</h1>\n<p>In this competition the heavy encoders and larger resolution worked better. I've used 3 CNN encoders (efficientnet_b7, convnext_large, tf_efficientnetv2_l) and 1 transformer (coat_lite_medium). Coat performed the best as single model, but ensemble with CNNs scored more. Also tried few versions of swin v1 and v2, but it performed worse.</p>\n<p>All models trained on 3 input resolutions: 768 * 768, 1024 * 1024, 1472 * 1472 with 5 folds.</p>\n<p>Models also trained to predict organ and pixel_size. I think these aux outputs help to train more robust model. pixel_size calculated for resized input resolution and changed during training augmentations.</p>\n<h1>Augmentations</h1>\n<p>random cropping/padding<br>\nscaling<br>\nrotating<br>\nflipping<br>\ncolor changing<br>\nblur/noise<br>\nsaturation/brightness/contrast<br>\nelastic</p>\n<h1>External data</h1>\n<p>External data helped a lot here. I've download some HPA data with this notebook <a href=\"https://www.kaggle.com/code/carnozhao/hpa-data-download\" target=\"_blank\">https://www.kaggle.com/code/carnozhao/hpa-data-download</a> and picked some images manually from sources posted here and previous Hubmap and Panda competitions. </p>\n<h1>Pseudo labeled</h1>\n<p>All external data pseudo-labeled using ensemble of initial models. <br>\nAlso training data was pseudo-labeled and in 30% used as ground truth for training.</p>\n<h1>Color transfering</h1>\n<p>Training images recolored using this great notebook <a href=\"https://www.kaggle.com/code/gray98/stain-normalization-color-transfer\" target=\"_blank\">https://www.kaggle.com/code/gray98/stain-normalization-color-transfer</a> with 3 different target images and used with 15% chance instead of original during training.</p>\n<h1>Validation</h1>\n<p>Test-time augmentations used on validation (flip, crop, padding) + external data also separated on folds and used as validation to get best checkpoints. </p>\n<p>Inference notebook: <a href=\"https://www.kaggle.com/code/victorsd/2nd-place-inference/notebook?scriptVersionId=106240458\" target=\"_blank\">https://www.kaggle.com/code/victorsd/2nd-place-inference/notebook?scriptVersionId=106240458</a></p>",
  "messages": [
    {
      "id": 1953175,
      "postDate": "2022-09-24T09:25:54.667Z",
      "content": "<p>Big thanks to the organizers for the great competition!<br>\nAlso thanks to all competitors for sharing their experiments here, especially <a href=\"https://www.kaggle.com/hengck23\" target=\"_blank\">@hengck23</a></p>\n<h1>Models</h1>\n<p>In this competition the heavy encoders and larger resolution worked better. I've used 3 CNN encoders (efficientnet_b7, convnext_large, tf_efficientnetv2_l) and 1 transformer (coat_lite_medium). Coat performed the best as single model, but ensemble with CNNs scored more. Also tried few versions of swin v1 and v2, but it performed worse.</p>\n<p>All models trained on 3 input resolutions: 768 * 768, 1024 * 1024, 1472 * 1472 with 5 folds.</p>\n<p>Models also trained to predict organ and pixel_size. I think these aux outputs help to train more robust model. pixel_size calculated for resized input resolution and changed during training augmentations.</p>\n<h1>Augmentations</h1>\n<p>random cropping/padding<br>\nscaling<br>\nrotating<br>\nflipping<br>\ncolor changing<br>\nblur/noise<br>\nsaturation/brightness/contrast<br>\nelastic</p>\n<h1>External data</h1>\n<p>External data helped a lot here. I've download some HPA data with this notebook <a href=\"https://www.kaggle.com/code/carnozhao/hpa-data-download\" target=\"_blank\">https://www.kaggle.com/code/carnozhao/hpa-data-download</a> and picked some images manually from sources posted here and previous Hubmap and Panda competitions. </p>\n<h1>Pseudo labeled</h1>\n<p>All external data pseudo-labeled using ensemble of initial models. <br>\nAlso training data was pseudo-labeled and in 30% used as ground truth for training.</p>\n<h1>Color transfering</h1>\n<p>Training images recolored using this great notebook <a href=\"https://www.kaggle.com/code/gray98/stain-normalization-color-transfer\" target=\"_blank\">https://www.kaggle.com/code/gray98/stain-normalization-color-transfer</a> with 3 different target images and used with 15% chance instead of original during training.</p>\n<h1>Validation</h1>\n<p>Test-time augmentations used on validation (flip, crop, padding) + external data also separated on folds and used as validation to get best checkpoints. </p>\n<p>Inference notebook: <a href=\"https://www.kaggle.com/code/victorsd/2nd-place-inference/notebook?scriptVersionId=106240458\" target=\"_blank\">https://www.kaggle.com/code/victorsd/2nd-place-inference/notebook?scriptVersionId=106240458</a></p>",
      "rawMarkdown": "Big thanks to the organizers for the great competition!\nAlso thanks to all competitors for sharing their experiments here, especially @hengck23\n\n# Models\n\nIn this competition the heavy encoders and larger resolution worked better. I've used 3 CNN encoders (efficientnet_b7, convnext_large, tf_efficientnetv2_l) and 1 transformer (coat_lite_medium). Coat performed the best as single model, but ensemble with CNNs scored more. Also tried few versions of swin v1 and v2, but it performed worse.\n\nAll models trained on 3 input resolutions: 768 * 768, 1024 * 1024, 1472 * 1472 with 5 folds.\n\nModels also trained to predict organ and pixel_size. I think these aux outputs help to train more robust model. pixel_size calculated for resized input resolution and changed during training augmentations.\n\n# Augmentations\n\nrandom cropping/padding\nscaling\nrotating\nflipping\ncolor changing\nblur/noise\nsaturation/brightness/contrast\nelastic\n\n# External data\n\nExternal data helped a lot here. I've download some HPA data with this notebook https://www.kaggle.com/code/carnozhao/hpa-data-download and picked some images manually from sources posted here and previous Hubmap and Panda competitions. \n\n# Pseudo labeled\n\nAll external data pseudo-labeled using ensemble of initial models. \nAlso training data was pseudo-labeled and in 30% used as ground truth for training.\n\n# Color transfering\n\nTraining images recolored using this great notebook https://www.kaggle.com/code/gray98/stain-normalization-color-transfer with 3 different target images and used with 15% chance instead of original during training.\n\n# Validation\n\nTest-time augmentations used on validation (flip, crop, padding) + external data also separated on folds and used as validation to get best checkpoints. \n\n\nInference notebook: https://www.kaggle.com/code/victorsd/2nd-place-inference/notebook?scriptVersionId=106240458",
      "votes": 56
    },
    {
      "id": 1956486,
      "postDate": "2022-09-26T13:30:06.060Z",
      "content": "<p>Congratulations , really good summary! Could you provide us with the code so we can understand the solution better ?<br>\nOne thing that i wanted to mention here, <br>\n<code>Models also trained to predict organ and pixel_size. I think these aux outputs help to train more robust model. pixel_size calculated for resized input resolution and changed during training augmentations.</code><br>\n It was a brilliant idea!</p>",
      "rawMarkdown": "Congratulations , really good summary! Could you provide us with the code so we can understand the solution better ?\nOne thing that i wanted to mention here, \n`Models also trained to predict organ and pixel_size. I think these aux outputs help to train more robust model. pixel_size calculated for resized input resolution and changed during training augmentations.`\n It was a brilliant idea!",
      "votes": 1
    },
    {
      "id": 1953614,
      "postDate": "2022-09-24T15:58:28.807Z",
      "content": "<p>Congratulations! Will you post your training notebooks?</p>",
      "rawMarkdown": "Congratulations! Will you post your training notebooks?",
      "votes": 1,
      "replies": [
        {
          "id": 1954096,
          "postDate": "2022-09-25T02:49:47.600Z",
          "content": "<p>I'll check this with the organizers when will prepare my solution. It is a mess of files/experiments now, not notebooks.</p>",
          "rawMarkdown": "I'll check this with the organizers when will prepare my solution. It is a mess of files/experiments now, not notebooks.",
          "votes": 2
        }
      ]
    },
    {
      "id": 1953184,
      "postDate": "2022-09-24T09:33:52.633Z",
      "content": "<p>Congratulations! I didn't realize that external data and pseudo label help such a lot, thanks for your sharing! :)</p>",
      "rawMarkdown": "Congratulations! I didn't realize that external data and pseudo label help such a lot, thanks for your sharing! :)",
      "votes": 1,
      "replies": [
        {
          "id": 1953191,
          "postDate": "2022-09-24T09:42:12.743Z",
          "content": "<p>Thanks! Your stain normalization for test on inference is also interesting!</p>",
          "rawMarkdown": "Thanks! Your stain normalization for test on inference is also interesting!",
          "votes": 1
        }
      ]
    },
    {
      "id": 2004177,
      "postDate": "2022-10-26T06:08:21.870Z",
      "content": "<p>Great work. Can you share the loss function and LR scheduler used for training these models? Loss function is the most interesting thing with your aux outputs. </p>",
      "rawMarkdown": "Great work. Can you share the loss function and LR scheduler used for training these models? Loss function is the most interesting thing with your aux outputs. ",
      "replies": [
        {
          "id": 2004203,
          "postDate": "2022-10-26T06:25:28.620Z",
          "content": "<p>dice+focal for segmentation, bce for organ classification, mse for pixel_size</p>",
          "rawMarkdown": "dice+focal for segmentation, bce for organ classification, mse for pixel_size"
        },
        {
          "id": 2004205,
          "postDate": "2022-10-26T06:26:20.823Z",
          "content": "<p>lr = 1e-4, ReduceLROnPlateau</p>",
          "rawMarkdown": "lr = 1e-4, ReduceLROnPlateau",
          "votes": 1
        },
        {
          "id": 2004218,
          "postDate": "2022-10-26T06:32:54.270Z",
          "content": "<p>Thanks a lot for your quick response. Learned so many things here. I going to try to recreate your solution.</p>",
          "rawMarkdown": "Thanks a lot for your quick response. Learned so many things here. I going to try to recreate your solution."
        }
      ]
    },
    {
      "id": 1957580,
      "postDate": "2022-09-27T04:27:18.430Z",
      "rawMarkdown": "",
      "isDeleted": true,
      "replies": [
        {
          "id": 1957692,
          "postDate": "2022-09-27T06:00:14.073Z",
          "content": "<p>2*a6000 (48gb). Really good GPU for larger models and input size.</p>",
          "rawMarkdown": "2*a6000 (48gb). Really good GPU for larger models and input size."
        }
      ]
    }
  ],
  "comments": [
    {
      "id": 1956486,
      "author_name": "MohamedAmine SAIGHI",
      "author_url": "",
      "post_date": "2022-09-26T13:30:06.060000",
      "content": "<p>Congratulations , really good summary! Could you provide us with the code so we can understand the solution better ?<br>\nOne thing that i wanted to mention here, <br>\n<code>Models also trained to predict organ and pixel_size. I think these aux outputs help to train more robust model. pixel_size calculated for resized input resolution and changed during training augmentations.</code><br>\n It was a brilliant idea!</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 1953614,
      "author_name": "Swikwislkdjc",
      "author_url": "",
      "post_date": "2022-09-24T15:58:28.807000",
      "content": "<p>Congratulations! Will you post your training notebooks?</p>",
      "votes": 1,
      "replies": [
        {
          "id": 1954096,
          "author_name": "Victor Durnov",
          "author_url": "",
          "post_date": "2022-09-25T02:49:47.600000",
          "content": "<p>I'll check this with the organizers when will prepare my solution. It is a mess of files/experiments now, not notebooks.</p>",
          "votes": 2,
          "replies": []
        }
      ]
    },
    {
      "id": 1953184,
      "author_name": "Rock",
      "author_url": "",
      "post_date": "2022-09-24T09:33:52.633000",
      "content": "<p>Congratulations! I didn't realize that external data and pseudo label help such a lot, thanks for your sharing! :)</p>",
      "votes": 1,
      "replies": [
        {
          "id": 1953191,
          "author_name": "Victor Durnov",
          "author_url": "",
          "post_date": "2022-09-24T09:42:12.743000",
          "content": "<p>Thanks! Your stain normalization for test on inference is also interesting!</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 2004177,
      "author_name": "Mugdha Hardikar",
      "author_url": "",
      "post_date": "2022-10-26T06:08:21.870000",
      "content": "<p>Great work. Can you share the loss function and LR scheduler used for training these models? Loss function is the most interesting thing with your aux outputs. </p>",
      "votes": 0,
      "replies": [
        {
          "id": 2004203,
          "author_name": "Victor Durnov",
          "author_url": "",
          "post_date": "2022-10-26T06:25:28.620000",
          "content": "<p>dice+focal for segmentation, bce for organ classification, mse for pixel_size</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 2004205,
          "author_name": "Victor Durnov",
          "author_url": "",
          "post_date": "2022-10-26T06:26:20.823000",
          "content": "<p>lr = 1e-4, ReduceLROnPlateau</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 2004218,
          "author_name": "Mugdha Hardikar",
          "author_url": "",
          "post_date": "2022-10-26T06:32:54.270000",
          "content": "<p>Thanks a lot for your quick response. Learned so many things here. I going to try to recreate your solution.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 1957580,
      "author_name": "",
      "author_url": "",
      "post_date": "2022-09-27T04:27:18.430000",
      "content": "",
      "votes": 0,
      "replies": [
        {
          "id": 1957692,
          "author_name": "Victor Durnov",
          "author_url": "",
          "post_date": "2022-09-27T06:00:14.073000",
          "content": "<p>2*a6000 (48gb). Really good GPU for larger models and input size.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1953175": "Big thanks to the organizers for the great competition!\nAlso thanks to all competitors for sharing their experiments here, especially @hengck23\n\n# Models\n\nIn this competition the heavy encoders and larger resolution worked better. I've used 3 CNN encoders (efficientnet_b7, convnext_large, tf_efficientnetv2_l) and 1 transformer (coat_lite_medium). Coat performed the best as single model, but ensemble with CNNs scored more. Also tried few versions of swin v1 and v2, but it performed worse.\n\nAll models trained on 3 input resolutions: 768 * 768, 1024 * 1024, 1472 * 1472 with 5 folds.\n\nModels also trained to predict organ and pixel_size. I think these aux outputs help to train more robust model. pixel_size calculated for resized input resolution and changed during training augmentations.\n\n# Augmentations\n\nrandom cropping/padding\nscaling\nrotating\nflipping\ncolor changing\nblur/noise\nsaturation/brightness/contrast\nelastic\n\n# External data\n\nExternal data helped a lot here. I've download some HPA data with this notebook https://www.kaggle.com/code/carnozhao/hpa-data-download and picked some images manually from sources posted here and previous Hubmap and Panda competitions. \n\n# Pseudo labeled\n\nAll external data pseudo-labeled using ensemble of initial models. \nAlso training data was pseudo-labeled and in 30% used as ground truth for training.\n\n# Color transfering\n\nTraining images recolored using this great notebook https://www.kaggle.com/code/gray98/stain-normalization-color-transfer with 3 different target images and used with 15% chance instead of original during training.\n\n# Validation\n\nTest-time augmentations used on validation (flip, crop, padding) + external data also separated on folds and used as validation to get best checkpoints. \n\n\nInference notebook: https://www.kaggle.com/code/victorsd/2nd-place-inference/notebook?scriptVersionId=106240458",
    "1956486": "Congratulations , really good summary! Could you provide us with the code so we can understand the solution better ?\nOne thing that i wanted to mention here, \n`Models also trained to predict organ and pixel_size. I think these aux outputs help to train more robust model. pixel_size calculated for resized input resolution and changed during training augmentations.`\n It was a brilliant idea!",
    "1953614": "Congratulations! Will you post your training notebooks?",
    "1953184": "Congratulations! I didn't realize that external data and pseudo label help such a lot, thanks for your sharing! :)",
    "2004177": "Great work. Can you share the loss function and LR scheduler used for training these models? Loss function is the most interesting thing with your aux outputs. ",
    "1957580": ""
  }
}