{
  "id": 70370,
  "title": "20th partial solution : MASKRCNN",
  "url": "/competitions/rsna-pneumonia-detection-challenge/writeups/formosan-black-bear-20th-partial-solution-maskrcnn",
  "author_name": "",
  "post_date": "2018-11-04T01:19:41.680Z",
  "votes": 24,
  "comment_count": 11,
  "views": 0,
  "content": "<p>I would like to share some works about MASKRCNN.</p>\n\n<p>The based model from\n<a href=\"https://github.com/matterport/Mask_RCNN\">https://github.com/matterport/Mask_RCNN</a></p>\n\n<p>Since I only have about one week to finetune the network before the due date,\nthe parameters may not be optimized.</p>\n\n<p>The classifier of MASKRCNN  performs badly , so I use <strong>retinanet model</strong> as classifier</p>\n\n<p>(Thanks for my teammate <a href=\"https://www.kaggle.com/andrewwang7\">andrewwang</a> )</p>\n\n<p>Final result : Stage1 score 0.236 / Stage2 score 0.217</p>\n\n<p><strong>Hyperparameter Setting</strong></p>\n\n<pre><code>class DetectorConfig(Config):\n    \"\"\"Configuration for training pneumonia detection on the RSNA pneumonia dataset.\n    Overrides values in the base Config class.\n    \"\"\"\n    # Give the configuration a recognizable name  \n    NAME = 'pneumonia'\n\n    # Train on 1 GPU and 8 images per GPU. We can put multiple images on each\n    # GPU because the images are small. Batch size is 8 (GPUs * images/GPU).\n    GPU_COUNT = 1\n    IMAGES_PER_GPU = 8 #256:8 \n    BACKBONE = 'resnet101'\n    NUM_CLASSES = 2  # background + 1 pneumonia classes   \n    IMAGE_MIN_DIM = 256\n    IMAGE_MAX_DIM = 256\n    RPN_ANCHOR_SCALES = (64, 128,192)\n    RPN_NMS_THRESHOLD  = 0.9\n    TRAIN_ROIS_PER_IMAGE = 16\n    MAX_GT_INSTANCES = 3\n    DETECTION_MAX_INSTANCES = 2 #ytt\n    DETECTION_MIN_CONFIDENCE = 0.7\n    DETECTION_NMS_THRESHOLD = 0.3\n    STEPS_PER_EPOCH = 500 \n    TRAIN_BN =True \n</code></pre>\n\n<p>Set NMS threshold 0.9 boosts the lb score.</p>\n\n<p><strong>Augmentation</strong></p>\n\n<ul>\n<li>many kind of augmentation methods improve training loss , but <strong>only\nhorizontal flip helps LB score</strong>.</li>\n</ul>\n\n<p><strong>Model modification</strong></p>\n\n<ul>\n<li><p>add scSE blocks  in resnet101 backbone</p></li>\n<li><p>add dropout in resnet101 backbone</p></li>\n</ul>\n\n<p>The changes reduce training loss but not much.</p>\n\n<p><strong>Training</strong></p>\n\n<p>only positive samples (5659) used in training</p>\n\n<p>Training on 5093 samples\n,Validating on 566 samples</p>\n\n<pre><code>LEARNING_RATE = 0.005\n\nmodel.train(dataset_train, dataset_val,\n             learning_rate=LEARNING_RATE*2,\n             epochs=1, #default 2\n             layers='heads',\n             augmentation=None)  ## no need to augment yet\n\nmodel.train(dataset_train, dataset_val,\n             learning_rate=LEARNING_RATE,\n             epochs=6,\n             layers='all',\n             augmentation=augmentation)  \n\nmodel.train(dataset_train, dataset_val,\n            learning_rate=LEARNING_RATE/5,\n            epochs=9,\n            layers='all',\n            augmentation=augmentation)\nmodel.train(dataset_train, dataset_val,\n        #learning_rate=LEARNING_RATE/5,\n        learning_rate=LEARNING_RATE/10,\n        epochs=12,\n        layers='all',\n        augmentation=augmentation)\n</code></pre>",
  "messages": [
    {
      "id": "414344",
      "postDate": "11/02/2018 15:25:07",
      "content": "<p>I would like to share some works about MASKRCNN.</p>\n\n<p>The based model from\n<a href=\"https://github.com/matterport/Mask_RCNN\">https://github.com/matterport/Mask_RCNN</a></p>\n\n<p>Since I only have about one week to finetune the network before the due date,\nthe parameters may not be optimized.</p>\n\n<p>The classifier of MASKRCNN  performs badly , so I use <strong>retinanet model</strong> as classifier</p>\n\n<p>(Thanks for my teammate <a href=\"https://www.kaggle.com/andrewwang7\">andrewwang</a> )</p>\n\n<p>Final result : Stage1 score 0.236 / Stage2 score 0.217</p>\n\n<p><strong>Hyperparameter Setting</strong></p>\n\n<pre><code>class DetectorConfig(Config):\n    \"\"\"Configuration for training pneumonia detection on the RSNA pneumonia dataset.\n    Overrides values in the base Config class.\n    \"\"\"\n    # Give the configuration a recognizable name  \n    NAME = 'pneumonia'\n\n    # Train on 1 GPU and 8 images per GPU. We can put multiple images on each\n    # GPU because the images are small. Batch size is 8 (GPUs * images/GPU).\n    GPU_COUNT = 1\n    IMAGES_PER_GPU = 8 #256:8 \n    BACKBONE = 'resnet101'\n    NUM_CLASSES = 2  # background + 1 pneumonia classes   \n    IMAGE_MIN_DIM = 256\n    IMAGE_MAX_DIM = 256\n    RPN_ANCHOR_SCALES = (64, 128,192)\n    RPN_NMS_THRESHOLD  = 0.9\n    TRAIN_ROIS_PER_IMAGE = 16\n    MAX_GT_INSTANCES = 3\n    DETECTION_MAX_INSTANCES = 2 #ytt\n    DETECTION_MIN_CONFIDENCE = 0.7\n    DETECTION_NMS_THRESHOLD = 0.3\n    STEPS_PER_EPOCH = 500 \n    TRAIN_BN =True \n</code></pre>\n\n<p>Set NMS threshold 0.9 boosts the lb score.</p>\n\n<p><strong>Augmentation</strong></p>\n\n<ul>\n<li>many kind of augmentation methods improve training loss , but <strong>only\nhorizontal flip helps LB score</strong>.</li>\n</ul>\n\n<p><strong>Model modification</strong></p>\n\n<ul>\n<li><p>add scSE blocks  in resnet101 backbone</p></li>\n<li><p>add dropout in resnet101 backbone</p></li>\n</ul>\n\n<p>The changes reduce training loss but not much.</p>\n\n<p><strong>Training</strong></p>\n\n<p>only positive samples (5659) used in training</p>\n\n<p>Training on 5093 samples\n,Validating on 566 samples</p>\n\n<pre><code>LEARNING_RATE = 0.005\n\nmodel.train(dataset_train, dataset_val,\n             learning_rate=LEARNING_RATE*2,\n             epochs=1, #default 2\n             layers='heads',\n             augmentation=None)  ## no need to augment yet\n\nmodel.train(dataset_train, dataset_val,\n             learning_rate=LEARNING_RATE,\n             epochs=6,\n             layers='all',\n             augmentation=augmentation)  \n\nmodel.train(dataset_train, dataset_val,\n            learning_rate=LEARNING_RATE/5,\n            epochs=9,\n            layers='all',\n            augmentation=augmentation)\nmodel.train(dataset_train, dataset_val,\n        #learning_rate=LEARNING_RATE/5,\n        learning_rate=LEARNING_RATE/10,\n        epochs=12,\n        layers='all',\n        augmentation=augmentation)\n</code></pre>",
      "rawMarkdown": "I would like to share some works about MASKRCNN.\n\nThe based model from\nhttps://github.com/matterport/Mask_RCNN\n\nSince I only have about one week to finetune the network before the due date,\nthe parameters may not be optimized.\n\nThe classifier of MASKRCNN  performs badly , so I use **retinanet model** as classifier\n\n(Thanks for my teammate [andrewwang][1] )\n\nFinal result : Stage1 score 0.236 / Stage2 score 0.217\n\n**Hyperparameter Setting**\n\n    class DetectorConfig(Config):\n        \"\"\"Configuration for training pneumonia detection on the RSNA pneumonia dataset.\n        Overrides values in the base Config class.\n        \"\"\"\n        # Give the configuration a recognizable name  \n        NAME = 'pneumonia'\n        \n        # Train on 1 GPU and 8 images per GPU. We can put multiple images on each\n        # GPU because the images are small. Batch size is 8 (GPUs * images/GPU).\n        GPU_COUNT = 1\n        IMAGES_PER_GPU = 8 #256:8 \n        BACKBONE = 'resnet101'\n        NUM_CLASSES = 2  # background + 1 pneumonia classes   \n        IMAGE_MIN_DIM = 256\n        IMAGE_MAX_DIM = 256\n        RPN_ANCHOR_SCALES = (64, 128,192)\n        RPN_NMS_THRESHOLD  = 0.9\n        TRAIN_ROIS_PER_IMAGE = 16\n        MAX_GT_INSTANCES = 3\n        DETECTION_MAX_INSTANCES = 2 #ytt\n        DETECTION_MIN_CONFIDENCE = 0.7\n        DETECTION_NMS_THRESHOLD = 0.3\n        STEPS_PER_EPOCH = 500 \n        TRAIN_BN =True \n\nSet NMS threshold 0.9 boosts the lb score.\n\n\n**Augmentation**\n\n - many kind of augmentation methods improve training loss , but **only\n   horizontal flip helps LB score**.\n\n**Model modification**\n\n - add scSE blocks  in resnet101 backbone\n\n - add dropout in resnet101 backbone\n\nThe changes reduce training loss but not much.\n\n\n **Training**\n\nonly positive samples (5659) used in training\n\nTraining on 5093 samples\n,Validating on 566 samples\n\n\n    LEARNING_RATE = 0.005\n    \n    model.train(dataset_train, dataset_val,\n                 learning_rate=LEARNING_RATE*2,\n                 epochs=1, #default 2\n                 layers='heads',\n                 augmentation=None)  ## no need to augment yet\n    \n    model.train(dataset_train, dataset_val,\n                 learning_rate=LEARNING_RATE,\n                 epochs=6,\n                 layers='all',\n                 augmentation=augmentation)  \n                \n    model.train(dataset_train, dataset_val,\n                learning_rate=LEARNING_RATE/5,\n                epochs=9,\n                layers='all',\n                augmentation=augmentation)\n    model.train(dataset_train, dataset_val,\n            #learning_rate=LEARNING_RATE/5,\n            learning_rate=LEARNING_RATE/10,\n            epochs=12,\n            layers='all',\n            augmentation=augmentation)\n\n\n  [1]: https://www.kaggle.com/andrewwang7",
      "votes": null
    },
    {
      "id": "414349",
      "postDate": "11/02/2018 15:30:37",
      "content": "<p>keep waiting for other winners share.....</p>",
      "rawMarkdown": "keep waiting for other winners share.....",
      "votes": null
    },
    {
      "id": "414350",
      "postDate": "11/02/2018 15:34:41",
      "content": "<p>Thank you for this info. How were you implementing the model modification steps of adding dropout and scSE to the MaskRCNN backbone?</p>",
      "rawMarkdown": "Thank you for this info. How were you implementing the model modification steps of adding dropout and scSE to the MaskRCNN backbone?",
      "votes": null
    },
    {
      "id": "414354",
      "postDate": "11/02/2018 15:41:02",
      "content": "<p>the maskrcnn source code in mrcnn/model.py, copy the whole \"mrcnn\" folder to my codebase and modify it!</p>",
      "rawMarkdown": "the maskrcnn source code in mrcnn/model.py, copy the whole \"mrcnn\" folder to my codebase and modify it!",
      "votes": null
    },
    {
      "id": "414416",
      "postDate": "11/02/2018 18:09:56",
      "content": "<p>Thanks for sharing. one newbie question: i thought retinanet can be used for bounding box detection. \nhow did you use it for classification ? </p>",
      "rawMarkdown": "Thanks for sharing. one newbie question: i thought retinanet can be used for bounding box detection. \nhow did you use it for classification ?",
      "votes": null
    },
    {
      "id": "414438",
      "postDate": "11/02/2018 19:10:05",
      "content": "<p>Thanks for sharing, Do you edit the original classifier and relace the retina-net  or did I miss something as retina-net classifier are already there?  </p>",
      "rawMarkdown": "Thanks for sharing, Do you edit the original classifier and relace the retina-net  or did I miss something as retina-net classifier are already there?",
      "votes": null
    },
    {
      "id": "414451",
      "postDate": "11/02/2018 19:50:13",
      "content": "<p>when the items of retinanet csv file are empty (detect nothing)  ,\nremove the corresponding item (boundary boxes) of maskrcnn csv file.</p>",
      "rawMarkdown": "when the items of retinanet csv file are empty (detect nothing)  ,\nremove the corresponding item (boundary boxes) of maskrcnn csv file.",
      "votes": null
    },
    {
      "id": "414452",
      "postDate": "11/02/2018 19:51:57",
      "content": "<p>no , just ensemble maskrcnn csv file with retinanet csv file</p>",
      "rawMarkdown": "no , just ensemble maskrcnn csv file with retinanet csv file",
      "votes": null
    },
    {
      "id": "414544",
      "postDate": "11/03/2018 00:15:17",
      "content": "<p>Congrats and thanks for sharing.</p>",
      "rawMarkdown": "Congrats and thanks for sharing.",
      "votes": null
    },
    {
      "id": "414547",
      "postDate": "11/03/2018 00:49:25",
      "content": "<p>Your learning rate starts at 0.05. For a complex network like Mask-RCNN, that's really high. Can the learning rate be started at a lower value, say 0.001, and still achieve similar results?</p>",
      "rawMarkdown": "Your learning rate starts at 0.05. For a complex network like Mask-RCNN, that's really high. Can the learning rate be started at a lower value, say 0.001, and still achieve similar results?",
      "votes": null
    },
    {
      "id": "414958",
      "postDate": "11/04/2018 01:19:12",
      "content": "<p>sorry typo</p>\n\n<p>LEARNING_RATE = 0.005</p>",
      "rawMarkdown": "sorry typo\n\nLEARNING_RATE = 0.005",
      "votes": null
    },
    {
      "id": "526815",
      "postDate": "05/03/2019 20:50:24",
      "content": "<p>Thanks for Sharing. Can you please share your complete code.</p>",
      "rawMarkdown": "Thanks for Sharing. Can you please share your complete code.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 414349,
      "author_name": "atom1231",
      "author_url": "",
      "post_date": "11/02/2018 15:30:37",
      "content": "<p>keep waiting for other winners share.....</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 414350,
      "author_name": "robrasmussen",
      "author_url": "",
      "post_date": "11/02/2018 15:34:41",
      "content": "<p>Thank you for this info. How were you implementing the model modification steps of adding dropout and scSE to the MaskRCNN backbone?</p>",
      "votes": null,
      "replies": [
        {
          "id": 414354,
          "author_name": "atom1231",
          "author_url": "",
          "post_date": "11/02/2018 15:41:02",
          "content": "<p>the maskrcnn source code in mrcnn/model.py, copy the whole \"mrcnn\" folder to my codebase and modify it!</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 414416,
      "author_name": "mpsampat",
      "author_url": "",
      "post_date": "11/02/2018 18:09:56",
      "content": "<p>Thanks for sharing. one newbie question: i thought retinanet can be used for bounding box detection. \nhow did you use it for classification ? </p>",
      "votes": null,
      "replies": [
        {
          "id": 414451,
          "author_name": "atom1231",
          "author_url": "",
          "post_date": "11/02/2018 19:50:13",
          "content": "<p>when the items of retinanet csv file are empty (detect nothing)  ,\nremove the corresponding item (boundary boxes) of maskrcnn csv file.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 414438,
      "author_name": "yakinrubaiat",
      "author_url": "",
      "post_date": "11/02/2018 19:10:05",
      "content": "<p>Thanks for sharing, Do you edit the original classifier and relace the retina-net  or did I miss something as retina-net classifier are already there?  </p>",
      "votes": null,
      "replies": [
        {
          "id": 414452,
          "author_name": "atom1231",
          "author_url": "",
          "post_date": "11/02/2018 19:51:57",
          "content": "<p>no , just ensemble maskrcnn csv file with retinanet csv file</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 414544,
      "author_name": "sheriytm",
      "author_url": "",
      "post_date": "11/03/2018 00:15:17",
      "content": "<p>Congrats and thanks for sharing.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 414547,
      "author_name": "nzabcd",
      "author_url": "",
      "post_date": "11/03/2018 00:49:25",
      "content": "<p>Your learning rate starts at 0.05. For a complex network like Mask-RCNN, that's really high. Can the learning rate be started at a lower value, say 0.001, and still achieve similar results?</p>",
      "votes": null,
      "replies": [
        {
          "id": 414958,
          "author_name": "atom1231",
          "author_url": "",
          "post_date": "11/04/2018 01:19:12",
          "content": "<p>sorry typo</p>\n\n<p>LEARNING_RATE = 0.005</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 526815,
      "author_name": "usamaraja125",
      "author_url": "",
      "post_date": "05/03/2019 20:50:24",
      "content": "<p>Thanks for Sharing. Can you please share your complete code.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "414344": "I would like to share some works about MASKRCNN.\n\nThe based model from\nhttps://github.com/matterport/Mask_RCNN\n\nSince I only have about one week to finetune the network before the due date,\nthe parameters may not be optimized.\n\nThe classifier of MASKRCNN  performs badly , so I use **retinanet model** as classifier\n\n(Thanks for my teammate [andrewwang][1] )\n\nFinal result : Stage1 score 0.236 / Stage2 score 0.217\n\n**Hyperparameter Setting**\n\n    class DetectorConfig(Config):\n        \"\"\"Configuration for training pneumonia detection on the RSNA pneumonia dataset.\n        Overrides values in the base Config class.\n        \"\"\"\n        # Give the configuration a recognizable name  \n        NAME = 'pneumonia'\n        \n        # Train on 1 GPU and 8 images per GPU. We can put multiple images on each\n        # GPU because the images are small. Batch size is 8 (GPUs * images/GPU).\n        GPU_COUNT = 1\n        IMAGES_PER_GPU = 8 #256:8 \n        BACKBONE = 'resnet101'\n        NUM_CLASSES = 2  # background + 1 pneumonia classes   \n        IMAGE_MIN_DIM = 256\n        IMAGE_MAX_DIM = 256\n        RPN_ANCHOR_SCALES = (64, 128,192)\n        RPN_NMS_THRESHOLD  = 0.9\n        TRAIN_ROIS_PER_IMAGE = 16\n        MAX_GT_INSTANCES = 3\n        DETECTION_MAX_INSTANCES = 2 #ytt\n        DETECTION_MIN_CONFIDENCE = 0.7\n        DETECTION_NMS_THRESHOLD = 0.3\n        STEPS_PER_EPOCH = 500 \n        TRAIN_BN =True \n\nSet NMS threshold 0.9 boosts the lb score.\n\n\n**Augmentation**\n\n - many kind of augmentation methods improve training loss , but **only\n   horizontal flip helps LB score**.\n\n**Model modification**\n\n - add scSE blocks  in resnet101 backbone\n\n - add dropout in resnet101 backbone\n\nThe changes reduce training loss but not much.\n\n\n **Training**\n\nonly positive samples (5659) used in training\n\nTraining on 5093 samples\n,Validating on 566 samples\n\n\n    LEARNING_RATE = 0.005\n    \n    model.train(dataset_train, dataset_val,\n                 learning_rate=LEARNING_RATE*2,\n                 epochs=1, #default 2\n                 layers='heads',\n                 augmentation=None)  ## no need to augment yet\n    \n    model.train(dataset_train, dataset_val,\n                 learning_rate=LEARNING_RATE,\n                 epochs=6,\n                 layers='all',\n                 augmentation=augmentation)  \n                \n    model.train(dataset_train, dataset_val,\n                learning_rate=LEARNING_RATE/5,\n                epochs=9,\n                layers='all',\n                augmentation=augmentation)\n    model.train(dataset_train, dataset_val,\n            #learning_rate=LEARNING_RATE/5,\n            learning_rate=LEARNING_RATE/10,\n            epochs=12,\n            layers='all',\n            augmentation=augmentation)\n\n\n  [1]: https://www.kaggle.com/andrewwang7",
    "414349": "keep waiting for other winners share.....",
    "414350": "Thank you for this info. How were you implementing the model modification steps of adding dropout and scSE to the MaskRCNN backbone?",
    "414354": "the maskrcnn source code in mrcnn/model.py, copy the whole \"mrcnn\" folder to my codebase and modify it!",
    "414416": "Thanks for sharing. one newbie question: i thought retinanet can be used for bounding box detection. \nhow did you use it for classification ?",
    "414438": "Thanks for sharing, Do you edit the original classifier and relace the retina-net  or did I miss something as retina-net classifier are already there?",
    "414451": "when the items of retinanet csv file are empty (detect nothing)  ,\nremove the corresponding item (boundary boxes) of maskrcnn csv file.",
    "414452": "no , just ensemble maskrcnn csv file with retinanet csv file",
    "414544": "Congrats and thanks for sharing.",
    "414547": "Your learning rate starts at 0.05. For a complex network like Mask-RCNN, that's really high. Can the learning rate be started at a lower value, say 0.001, and still achieve similar results?",
    "414958": "sorry typo\n\nLEARNING_RATE = 0.005",
    "526815": "Thanks for Sharing. Can you please share your complete code."
  },
  "source": "meta"
}