{
  "id": 54089,
  "title": "Matterport Mask-RCNN Code [LB 0.476]",
  "url": "/competitions/data-science-bowl-2018/discussion/54089",
  "author_name": "Waleed",
  "post_date": "2018-04-09T14:07:10.191000",
  "votes": 101,
  "comment_count": 94,
  "views": 0,
  "content": "<p>I know it's a bit late in the game, but I just got on this competition recently when a friend told me that some people are using our implementation. I just pushed a complete pipeline for this competition that includes training, visualization, and submission. I hope you find it useful. </p>\n\n<p>The code is in the Matterport <a href=\"https://github.com/matterport/Mask_RCNN\">Mask-RCNN repo</a> in the <code>samples/nucleus</code> directory. It consists of three parts:</p>\n\n<ol>\n<li><p><code>nucleus.py</code> contains the Dataset class, configuration, RLE functions, and submission code. Instructions for using it <a href=\"https://github.com/matterport/Mask_RCNN/tree/master/samples/nucleus\">here</a>. </p></li>\n<li><p><a href=\"https://github.com/matterport/Mask_RCNN/blob/master/samples/nucleus/inspect_nucleus_data.ipynb\">inspect_nucleus_data.ipynb</a> Exploratory data analysis, and visualizations to show anchors and their sizes relative to objects.</p></li>\n<li><p><a href=\"https://github.com/matterport/Mask_RCNN/blob/master/samples/nucleus/inspect_nucleus_model.ipynb\">inspect_nucleus_model.ipynb</a> Runs the model, computes AP on individual images, and visualizes differences between ground truth and detections.</p></li>\n</ol>\n\n<p>And here are my design choices. They're not ideal by any means. Just what I managed to find in a limited time. You should be able to fine-tune it and get better results.</p>\n\n<ul>\n<li>The model is based on ResNet50 started with imagenet weights. I chose that, as opposed to ResNet101, because there is only one object type and the image variety is limited. I haven't gotten the chance to try 101 yet.</li>\n<li>Most objects are small, some are 2x2 pixels. This requires special care. The first two layers of ResNet subsample twice (a conv with stride=2 and a maxpool), so we lose resolution quickly. One way to handle this is to change the network architecture to reduce early subsampling. I chose a different approach, which is to scale up the image x2 instead. It's simpler to implement and does the same thing, mostly.</li>\n<li>Since images are spatially uniform and objects are small, training with random crops makes sense. I use random crops of 512x512 (effectively 256x256 in image domain due to the upscaling of the image). During inference, though, the network runs on the entire image.</li>\n<li>No pre-processing or post-processing. If you have experience in that area you can probably improve the results significantly.</li>\n<li>No external dataset. I used the cleaned up version of the competition dataset (link was posted in the forum somewhere). This is an area where you can probably get a quick win by using more datasets.</li>\n<li>Many of the network settings can be controlled through the Config class, but not all. One setting I changed, <strong>but is not in the code</strong>, is editing the mask binarization threshold in <code>unmold_mask</code>. Default is 0.5, and I changed it to 0.4.</li>\n<li>Simple image augmentations: LR flip, UD flip, 90-degree rotations, and Gaussian noise.</li>\n</ul>\n\n<p>Let me know if I missed something. And if you have ideas to improve on it, I'd love to hear them as well. </p>",
  "messages": [
    {
      "id": 311157,
      "postDate": "2018-04-09T14:07:10.190Z",
      "content": "<p>I know it's a bit late in the game, but I just got on this competition recently when a friend told me that some people are using our implementation. I just pushed a complete pipeline for this competition that includes training, visualization, and submission. I hope you find it useful. </p>\n\n<p>The code is in the Matterport <a href=\"https://github.com/matterport/Mask_RCNN\">Mask-RCNN repo</a> in the <code>samples/nucleus</code> directory. It consists of three parts:</p>\n\n<ol>\n<li><p><code>nucleus.py</code> contains the Dataset class, configuration, RLE functions, and submission code. Instructions for using it <a href=\"https://github.com/matterport/Mask_RCNN/tree/master/samples/nucleus\">here</a>. </p></li>\n<li><p><a href=\"https://github.com/matterport/Mask_RCNN/blob/master/samples/nucleus/inspect_nucleus_data.ipynb\">inspect_nucleus_data.ipynb</a> Exploratory data analysis, and visualizations to show anchors and their sizes relative to objects.</p></li>\n<li><p><a href=\"https://github.com/matterport/Mask_RCNN/blob/master/samples/nucleus/inspect_nucleus_model.ipynb\">inspect_nucleus_model.ipynb</a> Runs the model, computes AP on individual images, and visualizes differences between ground truth and detections.</p></li>\n</ol>\n\n<p>And here are my design choices. They're not ideal by any means. Just what I managed to find in a limited time. You should be able to fine-tune it and get better results.</p>\n\n<ul>\n<li>The model is based on ResNet50 started with imagenet weights. I chose that, as opposed to ResNet101, because there is only one object type and the image variety is limited. I haven't gotten the chance to try 101 yet.</li>\n<li>Most objects are small, some are 2x2 pixels. This requires special care. The first two layers of ResNet subsample twice (a conv with stride=2 and a maxpool), so we lose resolution quickly. One way to handle this is to change the network architecture to reduce early subsampling. I chose a different approach, which is to scale up the image x2 instead. It's simpler to implement and does the same thing, mostly.</li>\n<li>Since images are spatially uniform and objects are small, training with random crops makes sense. I use random crops of 512x512 (effectively 256x256 in image domain due to the upscaling of the image). During inference, though, the network runs on the entire image.</li>\n<li>No pre-processing or post-processing. If you have experience in that area you can probably improve the results significantly.</li>\n<li>No external dataset. I used the cleaned up version of the competition dataset (link was posted in the forum somewhere). This is an area where you can probably get a quick win by using more datasets.</li>\n<li>Many of the network settings can be controlled through the Config class, but not all. One setting I changed, <strong>but is not in the code</strong>, is editing the mask binarization threshold in <code>unmold_mask</code>. Default is 0.5, and I changed it to 0.4.</li>\n<li>Simple image augmentations: LR flip, UD flip, 90-degree rotations, and Gaussian noise.</li>\n</ul>\n\n<p>Let me know if I missed something. And if you have ideas to improve on it, I'd love to hear them as well. </p>",
      "rawMarkdown": "I know it's a bit late in the game, but I just got on this competition recently when a friend told me that some people are using our implementation. I just pushed a complete pipeline for this competition that includes training, visualization, and submission. I hope you find it useful. \n\nThe code is in the Matterport [Mask-RCNN repo](https://github.com/matterport/Mask_RCNN) in the `samples/nucleus` directory. It consists of three parts:\n\n1. `nucleus.py` contains the Dataset class, configuration, RLE functions, and submission code. Instructions for using it [here](https://github.com/matterport/Mask_RCNN/tree/master/samples/nucleus). \n\n2. [inspect_nucleus_data.ipynb](https://github.com/matterport/Mask_RCNN/blob/master/samples/nucleus/inspect_nucleus_data.ipynb) Exploratory data analysis, and visualizations to show anchors and their sizes relative to objects.\n\n3. [inspect_nucleus_model.ipynb](https://github.com/matterport/Mask_RCNN/blob/master/samples/nucleus/inspect_nucleus_model.ipynb) Runs the model, computes AP on individual images, and visualizes differences between ground truth and detections.\n\nAnd here are my design choices. They're not ideal by any means. Just what I managed to find in a limited time. You should be able to fine-tune it and get better results.\n\n- The model is based on ResNet50 started with imagenet weights. I chose that, as opposed to ResNet101, because there is only one object type and the image variety is limited. I haven't gotten the chance to try 101 yet.\n- Most objects are small, some are 2x2 pixels. This requires special care. The first two layers of ResNet subsample twice (a conv with stride=2 and a maxpool), so we lose resolution quickly. One way to handle this is to change the network architecture to reduce early subsampling. I chose a different approach, which is to scale up the image x2 instead. It's simpler to implement and does the same thing, mostly.\n- Since images are spatially uniform and objects are small, training with random crops makes sense. I use random crops of 512x512 (effectively 256x256 in image domain due to the upscaling of the image). During inference, though, the network runs on the entire image.\n- No pre-processing or post-processing. If you have experience in that area you can probably improve the results significantly.\n- No external dataset. I used the cleaned up version of the competition dataset (link was posted in the forum somewhere). This is an area where you can probably get a quick win by using more datasets.\n- Many of the network settings can be controlled through the Config class, but not all. One setting I changed, **but is not in the code**, is editing the mask binarization threshold in `unmold_mask`. Default is 0.5, and I changed it to 0.4.\n- Simple image augmentations: LR flip, UD flip, 90-degree rotations, and Gaussian noise.\n\nLet me know if I missed something. And if you have ideas to improve on it, I'd love to hear them as well. ",
      "votes": 101
    },
    {
      "id": 315746,
      "postDate": "2018-04-17T14:38:11.630Z",
      "content": "<p>we used matter port and like I said it gave us in stage one 0.532 only the model. </p>\n\n<p>our config was - </p>\n\n<pre><code>IMAGE_MAX_DIM    =  1024\nIMAGE_MIN_DIM    = 512\nRPN_ANCHOR_SCALES   =    (8,16,32,64,128)\nRPN_ANCHOR_RATIOS =[0.5,1,2]   \nRPN_ANCHOR_STRIDE=1\n\nDETECTION_MAX_INSTANCES=500\nRPN_TRAIN_ANCHORS_PER_IMAGE=250\nTRAIN_ROIS_PER_IMAGE = 500\nLEARNING_RATE = 0.01 \n#USE_MINI_MASK = False       \n\n# Image mean (RGB)\nMEAN_PIXEL = np.array([123.7, 116.8, 103.9])\nDETECTION_MAX_INSTANCES=500\nMAX_GT_INSTANCES=500\n</code></pre>\n\n<p>going to 1024 from 256 got us better result. </p>\n\n<p>what was really meaningful is training with coco pertained model.  training only heads got us to 0.504 after 8 epochs\nafter that we trained more heads and 0.2 extra points was training 3+ for more epochs. using smaller lr</p>\n\n<p>I trained on lr 0.002 and tuning 0.0005. </p>\n\n<p>detecting with 0.8 confidence and 0.3 mms gave best results. </p>\n\n<p>we used of course many basic augmentation like rotate and zoom and noise. \nwe excluded masks that where empty after the augmentation.</p>",
      "rawMarkdown": "we used matter port and like I said it gave us in stage one 0.532 only the model. \n\nour config was - \n\n    IMAGE_MAX_DIM    =  1024\n    IMAGE_MIN_DIM    = 512\n    RPN_ANCHOR_SCALES   =    (8,16,32,64,128)\n    RPN_ANCHOR_RATIOS =[0.5,1,2]   \n    RPN_ANCHOR_STRIDE=1\n  \n    DETECTION_MAX_INSTANCES=500\n    RPN_TRAIN_ANCHORS_PER_IMAGE=250\n    TRAIN_ROIS_PER_IMAGE = 500\n    LEARNING_RATE = 0.01 \n    #USE_MINI_MASK = False       \n    \n    # Image mean (RGB)\n    MEAN_PIXEL = np.array([123.7, 116.8, 103.9])\n    DETECTION_MAX_INSTANCES=500\n    MAX_GT_INSTANCES=500\n\n\ngoing to 1024 from 256 got us better result. \n\nwhat was really meaningful is training with coco pertained model.  training only heads got us to 0.504 after 8 epochs\nafter that we trained more heads and 0.2 extra points was training 3+ for more epochs. using smaller lr\n\nI trained on lr 0.002 and tuning 0.0005. \n\ndetecting with 0.8 confidence and 0.3 mms gave best results. \n\nwe used of course many basic augmentation like rotate and zoom and noise. \nwe excluded masks that where empty after the augmentation.",
      "votes": 8,
      "replies": [
        {
          "id": 315791,
          "postDate": "2018-04-17T15:56:05.187Z",
          "content": "<p>I used size 512, I tried 1024 and didn't see much improvement, perhaps I messed up the config. Thanks for sharing this. </p>",
          "rawMarkdown": "I used size 512, I tried 1024 and didn't see much improvement, perhaps I messed up the config. Thanks for sharing this. "
        },
        {
          "id": 315795,
          "postDate": "2018-04-17T16:00:40.133Z",
          "content": "<p>Thanks for sharing your config.\nI used 512 and got about 0.44. I used model pre-trained on COCO.</p>",
          "rawMarkdown": "Thanks for sharing your config.\nI used 512 and got about 0.44. I used model pre-trained on COCO."
        },
        {
          "id": 315975,
          "postDate": "2018-04-17T23:11:42.867Z",
          "content": "<p>@AviWolfson thanks for sharing. </p>\n\n<p>A quick question, did you use the latest matterport code or the one before his recent updates as from early April? I get different results between the 2 versions. Better LB with the older code.</p>",
          "rawMarkdown": "@AviWolfson thanks for sharing. \n\nA quick question, did you use the latest matterport code or the one before his recent updates as from early April? I get different results between the 2 versions. Better LB with the older code."
        },
        {
          "id": 316060,
          "postDate": "2018-04-18T05:35:08.487Z",
          "content": "<p>the oldest one</p>",
          "rawMarkdown": "the oldest one"
        },
        {
          "id": 316061,
          "postDate": "2018-04-18T05:35:49.540Z",
          "content": "<p>have u done rotating augmentation? I am sure all of the augmentation we did contrib too</p>",
          "rawMarkdown": "have u done rotating augmentation? I am sure all of the augmentation we did contrib too"
        },
        {
          "id": 316076,
          "postDate": "2018-04-18T06:21:51.723Z",
          "content": "<p>@AviWolfson, augmentation made both val_loss and LB scores worse when I used it with my UNET model. So when I later used mask RCNN, I did not try it.</p>",
          "rawMarkdown": "@AviWolfson, augmentation made both val_loss and LB scores worse when I used it with my UNET model. So when I later used mask RCNN, I did not try it.",
          "votes": 1
        },
        {
          "id": 316700,
          "postDate": "2018-04-19T17:37:01.573Z",
          "content": "<p>@AviWolfson! Thanks for sharing the parameters. I made this doc to compare parameters across contestants.\n<a href=\"https://github.com/mpsampat/DSB_2018_Parameter_Selection_For_Matterport_Mask_RCNN/blob/master/comparison_of_Matterport_Mask_RCNN_parameters.md\">https://github.com/mpsampat/DSB_2018_Parameter_Selection_For_Matterport_Mask_RCNN/blob/master/comparison_of_Matterport_Mask_RCNN_parameters.md</a>\nIf you have time, could you send me your missing parameters ? \nAlso did you use this Mask_RCNN code base \n <a href=\"https://github.com/killthekitten/kaggle-ds-bowl-2018-baseline\">https://github.com/killthekitten/kaggle-ds-bowl-2018-baseline</a></p>",
          "rawMarkdown": "@AviWolfson! Thanks for sharing the parameters. I made this doc to compare parameters across contestants.\nhttps://github.com/mpsampat/DSB_2018_Parameter_Selection_For_Matterport_Mask_RCNN/blob/master/comparison_of_Matterport_Mask_RCNN_parameters.md\nIf you have time, could you send me your missing parameters ? \nAlso did you use this Mask_RCNN code base \n https://github.com/killthekitten/kaggle-ds-bowl-2018-baseline"
        }
      ]
    },
    {
      "id": 311650,
      "postDate": "2018-04-10T12:32:52.633Z",
      "content": "<p>I got with matterport 0.532</p>",
      "rawMarkdown": "I got with matterport 0.532",
      "votes": 5,
      "replies": [
        {
          "id": 311653,
          "postDate": "2018-04-10T12:39:43.203Z",
          "content": "<p>Awaresome, is it single model ? </p>",
          "rawMarkdown": "Awaresome, is it single model ? "
        },
        {
          "id": 311668,
          "postDate": "2018-04-10T13:13:59.707Z",
          "content": "<p>yes. only by training matterport single model. of course I took time to find the right way to train it</p>",
          "rawMarkdown": "yes. only by training matterport single model. of course I took time to find the right way to train it",
          "votes": 2
        },
        {
          "id": 311670,
          "postDate": "2018-04-10T13:17:33.073Z",
          "content": "<p>Do you have any tips you would like to share? </p>",
          "rawMarkdown": "Do you have any tips you would like to share? "
        },
        {
          "id": 311739,
          "postDate": "2018-04-10T15:29:12.583Z",
          "content": "<p>could you share more detail of your training?</p>",
          "rawMarkdown": "could you share more detail of your training?"
        },
        {
          "id": 311958,
          "postDate": "2018-04-11T01:30:32.950Z",
          "content": "<p>@AviWolfson What do you mean by the right way to train? Could you elaborate a bit?</p>",
          "rawMarkdown": "@AviWolfson What do you mean by the right way to train? Could you elaborate a bit?"
        },
        {
          "id": 311973,
          "postDate": "2018-04-11T02:16:23.527Z",
          "content": "<p>could you share some idea or config setup?</p>",
          "rawMarkdown": "could you share some idea or config setup?"
        },
        {
          "id": 312073,
          "postDate": "2018-04-11T06:14:52.360Z",
          "content": "<p>I will share it in the end of the competition</p>",
          "rawMarkdown": "I will share it in the end of the competition",
          "votes": 1
        }
      ]
    },
    {
      "id": 311203,
      "postDate": "2018-04-09T15:56:23.247Z",
      "content": "<p>Thanks for sharing! I used your code and actually the pretrain resnet 101 coco model is also a good choice.</p>",
      "rawMarkdown": "Thanks for sharing! I used your code and actually the pretrain resnet 101 coco model is also a good choice.",
      "votes": 1,
      "replies": [
        {
          "id": 312510,
          "postDate": "2018-04-11T21:56:55.620Z",
          "content": "<p>Did you try both 101 and 50? \nHow much additional training did you do on the pre-existing model?</p>",
          "rawMarkdown": "Did you try both 101 and 50? \nHow much additional training did you do on the pre-existing model?"
        }
      ]
    },
    {
      "id": 315280,
      "postDate": "2018-04-17T00:38:53.543Z",
      "content": "<p>Thanks for sharing!  I used resnet 50 coco model  and swish activation instead of relu activation .  Trained head network 20 epoches(val loss 0.89), then got 0.477 score.  Again trained the all layers 20 epoches(val loss 0.75),then got 0.48 score.  Matterport Mask-RCNN is very good! </p>",
      "rawMarkdown": "Thanks for sharing!  I used resnet 50 coco model  and swish activation instead of relu activation .  Trained head network 20 epoches(val loss 0.89), then got 0.477 score.  Again trained the all layers 20 epoches(val loss 0.75),then got 0.48 score.  Matterport Mask-RCNN is very good! ",
      "votes": 2
    },
    {
      "id": 315194,
      "postDate": "2018-04-16T21:12:06.803Z",
      "content": "<p>Many thanks to Waleed for sharing the solution with us. It's been a steep and painful learning curve for me but it's definitely worth it.</p>\n\n<p>I have encountered a number of difficulties on this journey. Since it's approaching the end of this competition, I would like to start the discussion here and hopefully help myself and others to gain further understanding of the implementation. </p>\n\n<p>For myself, I found the main problem seems to come from black and white images. my models are suffereing from main two main problems: 1) miss cells, and 2) not masking enough area. </p>\n\n<p>I have tried tweaking the parameters in the configurations, for example RPN_TRAIN_ANCHORS_PER_IMAGE, TRAIN_ROIS_PER_IMAGE, MAX_GT_INSTANCES, DETECTION_MAX_INSTANCES, etc. but none of them seems to bring any significant improvement</p>\n\n<p>I have also tried various learning rates, no effect either. I can always achieve an overall all loss between 0.7 ~ 0.8, and an rcnn mask loss of 0.2~0.25. This seems to be inline with what others are getting, but my 1st stage public LB is only 0.36.</p>\n\n<p>Therefore I am asking if anyone has experienced the same issues and if and how you've got around it. </p>\n\n<p>Many thanks in advance!</p>",
      "rawMarkdown": "Many thanks to Waleed for sharing the solution with us. It's been a steep and painful learning curve for me but it's definitely worth it.\n\nI have encountered a number of difficulties on this journey. Since it's approaching the end of this competition, I would like to start the discussion here and hopefully help myself and others to gain further understanding of the implementation. \n\nFor myself, I found the main problem seems to come from black and white images. my models are suffereing from main two main problems: 1) miss cells, and 2) not masking enough area. \n\nI have tried tweaking the parameters in the configurations, for example RPN_TRAIN_ANCHORS_PER_IMAGE, TRAIN_ROIS_PER_IMAGE, MAX_GT_INSTANCES, DETECTION_MAX_INSTANCES, etc. but none of them seems to bring any significant improvement\n\nI have also tried various learning rates, no effect either. I can always achieve an overall all loss between 0.7 ~ 0.8, and an rcnn mask loss of 0.2~0.25. This seems to be inline with what others are getting, but my 1st stage public LB is only 0.36.\n\nTherefore I am asking if anyone has experienced the same issues and if and how you've got around it. \n\nMany thanks in advance!",
      "votes": 2,
      "replies": [
        {
          "id": 315205,
          "postDate": "2018-04-16T21:34:07.063Z",
          "content": "<p>Hi @YL\nYes you are absolutely right! Many thanks to @Waleed for sharing the code! </p>\n\n<p>I used his latest code; the highest i got up to on stage1 was 0.472 with 8 epochs. \nIf you go here you can see my code: <a href=\"https://github.com/mpsampat/dsb_2018\">https://github.com/mpsampat/dsb_2018</a>\nThe main class for training is: \n<a href=\"https://github.com/mpsampat/dsb_2018/blob/master/train_mask_rcnn.py\">https://github.com/mpsampat/dsb_2018/blob/master/train_mask_rcnn.py</a>\n(Sorry it is not very polished ; but you can see the general idea) </p>\n\n<p>For train/validation split i used the code from the neptune github repo\n<a href=\"https://github.com/neptune-ml/open-solution-data-science-bowl-2018\">https://github.com/neptune-ml/open-solution-data-science-bowl-2018</a>\n(that is i run main.py -- prepare_metadata option) </p>",
          "rawMarkdown": "Hi @YL\nYes you are absolutely right! Many thanks to @Waleed for sharing the code! \n\nI used his latest code; the highest i got up to on stage1 was 0.472 with 8 epochs. \nIf you go here you can see my code: https://github.com/mpsampat/dsb_2018\nThe main class for training is: \nhttps://github.com/mpsampat/dsb_2018/blob/master/train_mask_rcnn.py\n(Sorry it is not very polished ; but you can see the general idea) \n\nFor train/validation split i used the code from the neptune github repo\nhttps://github.com/neptune-ml/open-solution-data-science-bowl-2018\n(that is i run main.py -- prepare_metadata option) \n",
          "votes": 3
        },
        {
          "id": 315222,
          "postDate": "2018-04-16T22:18:15.960Z",
          "content": "<p>Hi Mehul</p>\n\n<p>Thanks for the reply.</p>\n\n<p>That is impressive with for just 8 epochs of training. </p>\n\n<p>For me, I found the colour image yielded a better result than grey images.</p>\n\n<p>Also, may I ask what is your criteria for selecting the final epoch. rcnn mask loss? or total val loss.</p>",
          "rawMarkdown": "Hi Mehul\n\nThanks for the reply.\n\nThat is impressive with for just 8 epochs of training. \n\nFor me, I found the colour image yielded a better result than grey images.\n\nAlso, may I ask what is your criteria for selecting the final epoch. rcnn mask loss? or total val loss.\n\n"
        },
        {
          "id": 315227,
          "postDate": "2018-04-16T22:34:18.807Z",
          "content": "<p>val_rcnn_mask_loss was the best one for me. initially i was using val_total_loss; but then i shifted to mask_loss. </p>",
          "rawMarkdown": "val_rcnn_mask_loss was the best one for me. initially i was using val_total_loss; but then i shifted to mask_loss. "
        }
      ]
    },
    {
      "id": 311220,
      "postDate": "2018-04-09T16:21:52.033Z",
      "content": "<p>Thanks ! I'm learning your code deep right now!</p>",
      "rawMarkdown": "Thanks ! I'm learning your code deep right now!",
      "votes": -1
    },
    {
      "id": 885572,
      "postDate": "2020-06-14T10:23:12.797Z",
      "content": "<p>Hii, I am new to these techniques I went through the files provided, but I couldn't really figure out how to proceed if you have your own dataset and also without weights file? A detailed implementation of this would be much appreciated. thanks.</p>",
      "rawMarkdown": "Hii, I am new to these techniques I went through the files provided, but I couldn't really figure out how to proceed if you have your own dataset and also without weights file? A detailed implementation of this would be much appreciated. thanks."
    },
    {
      "id": 808201,
      "postDate": "2020-04-15T07:53:43.443Z",
      "content": "<p><a href=\"/waleedka\">@waleedka</a> hi, thanks for sharing. Query: what else special care do you think should be considered while detecting or localizing such small targets on the large spatial?</p>",
      "rawMarkdown": "@waleedka hi, thanks for sharing. Query: what else special care do you think should be considered while detecting or localizing such small targets on the large spatial?\n"
    },
    {
      "id": 314425,
      "postDate": "2018-04-15T14:44:24.993Z",
      "content": "<p>Is it usual to get <code>*** No instances to display ***</code> in detect process? Does that just mean no region detected? </p>",
      "rawMarkdown": "Is it usual to get `*** No instances to display *** ` in detect process? Does that just mean no region detected? ",
      "replies": [
        {
          "id": 314523,
          "postDate": "2018-04-15T18:28:03.080Z",
          "content": "<p>I guess so. In my results of stage2_test,  346 test images are not been detected(total image number is 3019). Meanwhile, it will generate images in 'results' file and you can check the results of test data. I turned off the 'save image with masks'  because it will occupy my disk. But it is very helpful to check the result and analysis.  It takes me about 9 hours to generate stage2_test submission.</p>",
          "rawMarkdown": "I guess so. In my results of stage2_test,  346 test images are not been detected(total image number is 3019). Meanwhile, it will generate images in 'results' file and you can check the results of test data. I turned off the 'save image with masks'  because it will occupy my disk. But it is very helpful to check the result and analysis.  It takes me about 9 hours to generate stage2_test submission.",
          "votes": 2
        }
      ]
    },
    {
      "id": 313909,
      "postDate": "2018-04-14T03:56:57.247Z",
      "content": "<p>nucleus.py is not utilizing my GPU</p>\n\n<p>I have a K80 GPU but when running python3 nucleus.py train --dataset=../../../dsbowl/ --subset=train --weights=imagenet, training each epoch is extremely slow, this is my config:\n<code>\nConfigurations:\nBACKBONE                       resnet50\nBACKBONE_STRIDES               [4, 8, 16, 32, 64]\nBATCH_SIZE                     20\nBBOX_STD_DEV                   [0.1 0.1 0.2 0.2]\nDETECTION_MAX_INSTANCES        400\nDETECTION_MIN_CONFIDENCE       0\nDETECTION_NMS_THRESHOLD        0.3\nGPU_COUNT                      2\nGRADIENT_CLIP_NORM             5.0\nIMAGES_PER_GPU                 10\nIMAGE_MAX_DIM                  512\nIMAGE_META_SIZE                14\nIMAGE_MIN_DIM                  512\nIMAGE_MIN_SCALE                2.0\nIMAGE_RESIZE_MODE              crop\nIMAGE_SHAPE                    [512 512   3]\nLEARNING_MOMENTUM              0.9\nLEARNING_RATE                  0.001\nMASK_POOL_SIZE                 14\nMASK_SHAPE                     [28, 28]\nMAX_GT_INSTANCES               200\nMEAN_PIXEL                     [43.53 39.56 48.22]\nMINI_MASK_SHAPE                (56, 56)\nNAME                           nucleus\nNUM_CLASSES                    2\nPOOL_SIZE                      7\nPOST_NMS_ROIS_INFERENCE        2000\nPOST_NMS_ROIS_TRAINING         1000\nROI_POSITIVE_RATIO             0.33\nRPN_ANCHOR_RATIOS              [0.5, 1, 2]\nRPN_ANCHOR_SCALES              (8, 16, 32, 64, 128)\nRPN_ANCHOR_STRIDE              1\nRPN_BBOX_STD_DEV               [0.1 0.1 0.2 0.2]\nRPN_NMS_THRESHOLD              0.9\nRPN_TRAIN_ANCHORS_PER_IMAGE    64\nSTEPS_PER_EPOCH                63\nTRAIN_BN                       False\nTRAIN_ROIS_PER_IMAGE           128\nUSE_MINI_MASK                  True\nUSE_RPN_ROIS                   True\nVALIDATION_STEPS               2\nWEIGHT_DECAY                   0.0001\n</code></p>",
      "rawMarkdown": "nucleus.py is not utilizing my GPU\n\nI have a K80 GPU but when running python3 nucleus.py train --dataset=../../../dsbowl/ --subset=train --weights=imagenet, training each epoch is extremely slow, this is my config:\n```\nConfigurations:\nBACKBONE                       resnet50\nBACKBONE_STRIDES               [4, 8, 16, 32, 64]\nBATCH_SIZE                     20\nBBOX_STD_DEV                   [0.1 0.1 0.2 0.2]\nDETECTION_MAX_INSTANCES        400\nDETECTION_MIN_CONFIDENCE       0\nDETECTION_NMS_THRESHOLD        0.3\nGPU_COUNT                      2\nGRADIENT_CLIP_NORM             5.0\nIMAGES_PER_GPU                 10\nIMAGE_MAX_DIM                  512\nIMAGE_META_SIZE                14\nIMAGE_MIN_DIM                  512\nIMAGE_MIN_SCALE                2.0\nIMAGE_RESIZE_MODE              crop\nIMAGE_SHAPE                    [512 512   3]\nLEARNING_MOMENTUM              0.9\nLEARNING_RATE                  0.001\nMASK_POOL_SIZE                 14\nMASK_SHAPE                     [28, 28]\nMAX_GT_INSTANCES               200\nMEAN_PIXEL                     [43.53 39.56 48.22]\nMINI_MASK_SHAPE                (56, 56)\nNAME                           nucleus\nNUM_CLASSES                    2\nPOOL_SIZE                      7\nPOST_NMS_ROIS_INFERENCE        2000\nPOST_NMS_ROIS_TRAINING         1000\nROI_POSITIVE_RATIO             0.33\nRPN_ANCHOR_RATIOS              [0.5, 1, 2]\nRPN_ANCHOR_SCALES              (8, 16, 32, 64, 128)\nRPN_ANCHOR_STRIDE              1\nRPN_BBOX_STD_DEV               [0.1 0.1 0.2 0.2]\nRPN_NMS_THRESHOLD              0.9\nRPN_TRAIN_ANCHORS_PER_IMAGE    64\nSTEPS_PER_EPOCH                63\nTRAIN_BN                       False\nTRAIN_ROIS_PER_IMAGE           128\nUSE_MINI_MASK                  True\nUSE_RPN_ROIS                   True\nVALIDATION_STEPS               2\nWEIGHT_DECAY                   0.0001\n```",
      "replies": [
        {
          "id": 313963,
          "postDate": "2018-04-14T07:15:28.230Z",
          "content": "<p>Are you using Google Colab?\nYour config says GPU_COUNT 2! Do you have 2 GPUs?</p>",
          "rawMarkdown": "Are you using Google Colab?\nYour config says GPU_COUNT 2! Do you have 2 GPUs?"
        },
        {
          "id": 314147,
          "postDate": "2018-04-14T18:24:43.503Z",
          "content": "<p>In mrcnn it says # NUMBER OF GPUs to use. For CPU training, use 1 though \n<a href=\"https://github.com/matterport/Mask_RCNN/blob/ba0c8ba3a22b235101bcd4a9441f7b2f603a8b7d/mrcnn/config.py#L28\">https://github.com/matterport/Mask_RCNN/blob/ba0c8ba3a22b235101bcd4a9441f7b2f603a8b7d/mrcnn/config.py#L28</a></p>\n\n<p>and in <a href=\"https://github.com/matterport/Mask_RCNN/blob/512921dde25ec07c8db373f0457da8d58fff0735/mrcnn/parallel_model.py#L33\">https://github.com/matterport/Mask_RCNN/blob/512921dde25ec07c8db373f0457da8d58fff0735/mrcnn/parallel_model.py#L33</a>\nit says gpu_count: Number of GPUs. Must be &gt; 1</p>\n\n<p>Even if I changed it back to 1, it's still the same</p>",
          "rawMarkdown": "In mrcnn it says # NUMBER OF GPUs to use. For CPU training, use 1 though \nhttps://github.com/matterport/Mask_RCNN/blob/ba0c8ba3a22b235101bcd4a9441f7b2f603a8b7d/mrcnn/config.py#L28\n\nand in https://github.com/matterport/Mask_RCNN/blob/512921dde25ec07c8db373f0457da8d58fff0735/mrcnn/parallel_model.py#L33\nit says gpu_count: Number of GPUs. Must be &gt; 1\n\nEven if I changed it back to 1, it's still the same"
        },
        {
          "id": 314607,
          "postDate": "2018-04-15T23:36:00.043Z",
          "content": "<p>Both comments are correct: the first is about the config setting, which you should set to the number of GPUs (or 1 if you're training on a CPU). The second describes a parameter passed to the ParallelModel class, which is never called unless you have more than one GPU. </p>",
          "rawMarkdown": "Both comments are correct: the first is about the config setting, which you should set to the number of GPUs (or 1 if you're training on a CPU). The second describes a parameter passed to the ParallelModel class, which is never called unless you have more than one GPU. "
        },
        {
          "id": 314631,
          "postDate": "2018-04-16T01:18:18.030Z",
          "content": "<p>I see, thanks :)</p>",
          "rawMarkdown": "I see, thanks :)"
        }
      ]
    },
    {
      "id": 313869,
      "postDate": "2018-04-14T01:19:23.027Z",
      "content": "<p>@Waleed, did you try and retrain using stage1_train + stage1_test ? I am trying this; Interesting after 10 epochs my val_loss is much higher (in the range of 2.5 whereas with only stage1_train data it was in 0.7 range</p>",
      "rawMarkdown": "@Waleed, did you try and retrain using stage1_train + stage1_test ? I am trying this; Interesting after 10 epochs my val_loss is much higher (in the range of 2.5 whereas with only stage1_train data it was in 0.7 range\n",
      "replies": [
        {
          "id": 314605,
          "postDate": "2018-04-15T23:32:25.020Z",
          "content": "<p>I haven't tried yet. But 2.5 val loss seems high. Sure you don't have a bug in loading the stage 1 test data?</p>",
          "rawMarkdown": "I haven't tried yet. But 2.5 val loss seems high. Sure you don't have a bug in loading the stage 1 test data?"
        }
      ]
    },
    {
      "id": 312687,
      "postDate": "2018-04-12T06:37:29.363Z",
      "content": "<p>hi,could show your config ? caus for training_data my loss is 0.66,val_loss 0.7,but detection performence is really bad , AND only get LB0.224</p>",
      "rawMarkdown": "hi,could show your config ? caus for training_data my loss is 0.66,val_loss 0.7,but detection performence is really bad , AND only get LB0.224"
    },
    {
      "id": 312649,
      "postDate": "2018-04-12T05:04:12.047Z",
      "content": "<p>can you share little more detail of your training set?</p>",
      "rawMarkdown": "can you share little more detail of your training set?"
    },
    {
      "id": 312588,
      "postDate": "2018-04-12T02:25:11.507Z",
      "content": "<p>hi,  I got the error as bellow  and  i have no idea why this will happen</p>\n\n<p>Running on /content/.kaggle/competitions/data-science-bowl-2018/\nTraceback (most recent call last):\n  File \"nucleus.py\", line 486, in \n    detect(model, args.dataset, args.subset)\n  File \"nucleus.py\", line 383, in detect\n    rle = mask_to_rle(source_id, r[\"masks\"], r[\"scores\"])\n  File \"nucleus.py\", line 342, in mask_to_rle\n    mask = np.max(mask * np.reshape(order, [1, 1, -1]), -1)\nValueError: operands could not be broadcast together with shapes (0,28,28) (1,1,0)</p>",
      "rawMarkdown": "hi,  I got the error as bellow  and  i have no idea why this will happen\n\nRunning on /content/.kaggle/competitions/data-science-bowl-2018/\nTraceback (most recent call last):\n  File \"nucleus.py\", line 486, in \n    detect(model, args.dataset, args.subset)\n  File \"nucleus.py\", line 383, in detect\n    rle = mask_to_rle(source_id, r[\"masks\"], r[\"scores\"])\n  File \"nucleus.py\", line 342, in mask_to_rle\n    mask = np.max(mask * np.reshape(order, [1, 1, -1]), -1)\nValueError: operands could not be broadcast together with shapes (0,28,28) (1,1,0)",
      "replies": [
        {
          "id": 312593,
          "postDate": "2018-04-12T02:39:51.497Z",
          "content": "<p>There are several garbage images in the stage 2 data. (for example 223fcf1a3652bb711ab3b4f3d160938022df2a31dd39b46e2a5c592e333dd21c). We will have to change the code to handle those. I just ignored all the images with mask shape (0, X, X) when calculating rle.</p>",
          "rawMarkdown": "There are several garbage images in the stage 2 data. (for example 223fcf1a3652bb711ab3b4f3d160938022df2a31dd39b46e2a5c592e333dd21c). We will have to change the code to handle those. I just ignored all the images with mask shape (0, X, X) when calculating rle.",
          "votes": 3
        },
        {
          "id": 312602,
          "postDate": "2018-04-12T02:59:53.243Z",
          "content": "<p>I tried! works Great! thanks!</p>",
          "rawMarkdown": "I tried! works Great! thanks!"
        },
        {
          "id": 313419,
          "postDate": "2018-04-13T08:20:02.780Z",
          "content": "<p>I pushed a fix to handle this edge case. </p>",
          "rawMarkdown": "I pushed a fix to handle this edge case. ",
          "votes": 1
        },
        {
          "id": 313685,
          "postDate": "2018-04-13T17:36:53.483Z",
          "content": "<p>thanks! it makes more sense. i found the generated predictions contain a lot of overlap masks. Is that normal?</p>",
          "rawMarkdown": "thanks! it makes more sense. i found the generated predictions contain a lot of overlap masks. Is that normal?"
        }
      ]
    },
    {
      "id": 312473,
      "postDate": "2018-04-11T20:13:13.140Z",
      "content": "<p>@Waleed Hi, is the implementation correct?  I see the validation loss fluctuating a lot but not decreasing.</p>",
      "rawMarkdown": "@Waleed Hi, is the implementation correct?  I see the validation loss fluctuating a lot but not decreasing.\n",
      "replies": [
        {
          "id": 312485,
          "postDate": "2018-04-11T20:29:54.300Z",
          "content": "<p>The fluctuations are normal because the validation dataset is so small. I did get the val loss to go down to 0.75~0.8, though. Maybe your config parameters are slightly different?</p>",
          "rawMarkdown": "The fluctuations are normal because the validation dataset is so small. I did get the val loss to go down to 0.75~0.8, though. Maybe your config parameters are slightly different?"
        },
        {
          "id": 312507,
          "postDate": "2018-04-11T21:47:04.530Z",
          "content": "<p>What are your configs? I tried to follow what you said in a previous thread increasing the number of max detections in image since there are many nuclei, etc., but still can't get 0.75. Did you achieve that with the same validation dataset and were the configs the same as the ones in the repo? Thanks!</p>",
          "rawMarkdown": "What are your configs? I tried to follow what you said in a previous thread increasing the number of max detections in image since there are many nuclei, etc., but still can't get 0.75. Did you achieve that with the same validation dataset and were the configs the same as the ones in the repo? Thanks!"
        },
        {
          "id": 312515,
          "postDate": "2018-04-11T22:06:02.087Z",
          "content": "<p>Yes, same as in the repo except for two things I mentioned above. \n1. I changed the mask threshold to 0.4 in the unmold_mask function\n2. My training schedule was a bit random because in every experiment I simply started from the weights of the last experiment for speed. </p>\n\n<p>I don't know if #2 has any effect on the result. I doubt it, but we're dealing with a small dataset so every little variation can have a big effect. Try learning rate cycling and see if that helps. As in, let it converge, then raise the learning rate for a bit and drop it again, and so on. </p>",
          "rawMarkdown": "Yes, same as in the repo except for two things I mentioned above. \n1. I changed the mask threshold to 0.4 in the unmold_mask function\n2. My training schedule was a bit random because in every experiment I simply started from the weights of the last experiment for speed. \n\nI don't know if #2 has any effect on the result. I doubt it, but we're dealing with a small dataset so every little variation can have a big effect. Try learning rate cycling and see if that helps. As in, let it converge, then raise the learning rate for a bit and drop it again, and so on. "
        },
        {
          "id": 312548,
          "postDate": "2018-04-12T01:10:33.753Z",
          "content": "<p>I believe that most of us start from weights=last, so I don't think its #2. I'll try with mask threshold 0.4 and report back. Thanks! </p>",
          "rawMarkdown": "I believe that most of us start from weights=last, so I don't think its #2. I'll try with mask threshold 0.4 and report back. Thanks! "
        },
        {
          "id": 313977,
          "postDate": "2018-04-14T08:38:50.877Z",
          "content": "<p>Thank you! Is it needed to rerun <code>python3 setup.py install</code> after modifying <code>unmold_mask</code>?</p>",
          "rawMarkdown": "Thank you! Is it needed to rerun `python3 setup.py install` after modifying `unmold_mask `?"
        }
      ]
    },
    {
      "id": 312308,
      "postDate": "2018-04-11T14:46:55.980Z",
      "content": "<p>Thank you so much for sharing! @Waleed, I am sorry that I got a bug during implementation,\n ipykernel_launcher.py: error: the following arguments are required: --weights\nAn exception has occurred, use %tb to see the full traceback.\nHow can I solve this problem?</p>",
      "rawMarkdown": "Thank you so much for sharing! @Waleed, I am sorry that I got a bug during implementation,\n ipykernel_launcher.py: error: the following arguments are required: --weights\nAn exception has occurred, use %tb to see the full traceback.\nHow can I solve this problem?",
      "replies": [
        {
          "id": 312409,
          "postDate": "2018-04-11T17:41:34.693Z",
          "content": "<p>Try adding <code>--weights=imagenet</code> to your arguments.</p>",
          "rawMarkdown": "Try adding `--weights=imagenet` to your arguments."
        }
      ]
    },
    {
      "id": 312197,
      "postDate": "2018-04-11T11:06:05.437Z",
      "content": "<p>Thank you for the code! However I get the following error when trying to train (using Spyder IDE, on Windows).  </p>\n\n<p>Any suggestions welcome.</p>\n\n<p>Traceback (most recent call last):</p>\n\n<p>File \"\", line 1, in \n    train(model)</p>\n\n<p>File \"\", line 34, in train\n    layers='heads')</p>\n\n<p>File \"C:/Users/Ioannis/GitHub/Mask_RCNN\\mrcnn\\model.py\", line 2317, in train\n    use_multiprocessing=True,</p>\n\n<p>File \"C:\\Users\\Ioannis\\Anaconda3\\lib\\site-packages\\keras\\legacy\\interfaces.py\", line 87, in wrapper\n    return func(*args, **kwargs)</p>\n\n<p>File \"C:\\Users\\Ioannis\\Anaconda3\\lib\\site-packages\\keras\\engine\\training.py\", line 2046, in fit_generator\n    generator_output = next(output_generator)</p>\n\n<p>File \"C:\\Users\\Ioannis\\Anaconda3\\lib\\site-packages\\keras\\utils\\data_utils.py\", line 659, in get\n    raise StopIteration()</p>\n\n<p>StopIteration</p>",
      "rawMarkdown": "Thank you for the code! However I get the following error when trying to train (using Spyder IDE, on Windows).  \n\nAny suggestions welcome.\n\nTraceback (most recent call last):\n\n  File \"",
      "replies": [
        {
          "id": 312201,
          "postDate": "2018-04-11T11:17:15.643Z",
          "content": "<p>Hi Ioannis, look at my comment above, I am quite certain that one of your folders have name 'images', check if you do, and rename them if needed. I was getting the same StopIteration errors.</p>",
          "rawMarkdown": "Hi Ioannis, look at my comment above, I am quite certain that one of your folders have name 'images', check if you do, and rename them if needed. I was getting the same StopIteration errors."
        },
        {
          "id": 312669,
          "postDate": "2018-04-12T05:41:47.840Z",
          "content": "<p>Thanks Dima, unfortunately this was not the case for me. Will debug this over the weekend if I find some time...</p>",
          "rawMarkdown": "Thanks Dima, unfortunately this was not the case for me. Will debug this over the weekend if I find some time..."
        },
        {
          "id": 313643,
          "postDate": "2018-04-13T16:09:13.553Z",
          "content": "<p>As somebody else suggested here <a href=\"https://www.kaggle.com/c/data-science-bowl-2018/discussion/50903#294190\">https://www.kaggle.com/c/data-science-bowl-2018/discussion/50903#294190</a>, I updated Keras and problem was solved. </p>",
          "rawMarkdown": "As somebody else suggested here https://www.kaggle.com/c/data-science-bowl-2018/discussion/50903#294190, I updated Keras and problem was solved. "
        }
      ]
    },
    {
      "id": 312186,
      "postDate": "2018-04-11T10:46:34.010Z",
      "content": "<p>Great job !</p>",
      "rawMarkdown": "Great job !"
    },
    {
      "id": 312131,
      "postDate": "2018-04-11T08:47:36.803Z",
      "content": "<p>I have a question. How to give a weighing for every image?</p>",
      "rawMarkdown": "I have a question. How to give a weighing for every image?"
    },
    {
      "id": 312042,
      "postDate": "2018-04-11T05:09:31.163Z",
      "content": "<p>can I use the GPU when running nucleus.py? The CPU version is so slow ......</p>",
      "rawMarkdown": "can I use the GPU when running nucleus.py? The CPU version is so slow ......",
      "replies": [
        {
          "id": 312452,
          "postDate": "2018-04-11T19:22:30.183Z",
          "content": "<p>bumped into this as well, setting GPU_COUNT=2 results in error.</p>",
          "rawMarkdown": "bumped into this as well, setting GPU_COUNT=2 results in error."
        },
        {
          "id": 312484,
          "postDate": "2018-04-11T20:25:05.303Z",
          "content": "<p>The latest version fixes that</p>",
          "rawMarkdown": "The latest version fixes that"
        }
      ]
    },
    {
      "id": 311595,
      "postDate": "2018-04-10T10:33:34.183Z",
      "content": "<p>Thank you @Waleed for sharing this, also for the original re-implementation of Mask R-CNN, it was very useful. I have found a small bug/issue with this pipeline - you use .split(\"/images/\") in your code (nucleus.py, 229L) in order to derive path to masks, but it might be faulty in case someone would have name \"images\" in their path e.g. in our case /Kaggle/spotNuclei/images/raw_fixed/stage1_train/img1/images/img1.png. I am not a big Python expert here, but this line <code>mask_dir = \"/\" + os.path.join(*(os.path.join(info[\"path\"]).split(\"/\")[:-2])) + \"/masks/\"</code> looks more robust (probable there is more elegant solution). Can do a PR if this sounds meaningful. </p>",
      "rawMarkdown": "Thank you @Waleed for sharing this, also for the original re-implementation of Mask R-CNN, it was very useful. I have found a small bug/issue with this pipeline - you use .split(\"/images/\") in your code (nucleus.py, 229L) in order to derive path to masks, but it might be faulty in case someone would have name \"images\" in their path e.g. in our case /Kaggle/spotNuclei/images/raw_fixed/stage1_train/img1/images/img1.png. I am not a big Python expert here, but this line `mask_dir = \"/\" + os.path.join(*(os.path.join(info[\"path\"]).split(\"/\")[:-2])) + \"/masks/\"` looks more robust (probable there is more elegant solution). Can do a PR if this sounds meaningful. ",
      "replies": [
        {
          "id": 311921,
          "postDate": "2018-04-10T22:55:38.277Z",
          "content": "<p>Good point. Just pushed a fix.</p>",
          "rawMarkdown": "Good point. Just pushed a fix.",
          "votes": 1
        }
      ]
    },
    {
      "id": 311435,
      "postDate": "2018-04-10T03:55:32.210Z",
      "content": "<p>Hi, can you share  your training schedule , As I only get 0.356 with the default traing schedule,the only thing I modified is when a I train \"all\" I set the batch size to 4 due to OOM. by the way after I finish 40 epoch training  I get a total loss around 0.75</p>",
      "rawMarkdown": "Hi, can you share  your training schedule , As I only get 0.356 with the default traing schedule,the only thing I modified is when a I train \"all\" I set the batch size to 4 due to OOM. by the way after I finish 40 epoch training  I get a total loss around 0.75",
      "replies": [
        {
          "id": 311478,
          "postDate": "2018-04-10T06:07:48.010Z",
          "content": "<p>My val loss was around 0.75 as well, but the training loss was lower. </p>\n\n<p>Every time I make a change, I train from the last trained model because it's faster than starting from imagenet all over again, so I don't know exactly how many epochs it would take to do it in one stretch from imagenet. But, even early on when I did start with imagenet, it got more than 0.4. Maybe you haven't trained it long enough yet. Or maybe reducing the batch size is the issue. If so, try training longer and reduce the learning rate. Also, verify that you're training with the cleaned up dataset.</p>",
          "rawMarkdown": "My val loss was around 0.75 as well, but the training loss was lower. \n\nEvery time I make a change, I train from the last trained model because it's faster than starting from imagenet all over again, so I don't know exactly how many epochs it would take to do it in one stretch from imagenet. But, even early on when I did start with imagenet, it got more than 0.4. Maybe you haven't trained it long enough yet. Or maybe reducing the batch size is the issue. If so, try training longer and reduce the learning rate. Also, verify that you're training with the cleaned up dataset."
        },
        {
          "id": 311503,
          "postDate": "2018-04-10T06:59:38.140Z",
          "content": "<p>thank you, I guess the the problem was not enough training time. maybe as we are using a relative small batch size, so we always end up traning too early just because the  loss won't go down. but in fact the network just not learned enough.</p>",
          "rawMarkdown": "thank you, I guess the the problem was not enough training time. maybe as we are using a relative small batch size, so we always end up traning too early just because the  loss won't go down. but in fact the network just not learned enough."
        },
        {
          "id": 311563,
          "postDate": "2018-04-10T08:48:11.780Z",
          "content": "<p>I was trying to do k fold cross validation and and I found that for each fold the validation score reaches min  normally after 10 epochs at lr of 0.001 (I have included external data), and I then used a small learning rate but this will give me another min in 2-3 epochs.</p>\n\n<p>but even with this the best score i get is only .35</p>\n\n<p>therefore i am really puzzle.  cross validation score should really be used to guide the training no?   or image process is an entirely different planet?</p>",
          "rawMarkdown": "I was trying to do k fold cross validation and and I found that for each fold the validation score reaches min  normally after 10 epochs at lr of 0.001 (I have included external data), and I then used a small learning rate but this will give me another min in 2-3 epochs.\n\nbut even with this the best score i get is only .35\n\ntherefore i am really puzzle.  cross validation score should really be used to guide the training no?   or image process is an entirely different planet?",
          "votes": 1
        },
        {
          "id": 311630,
          "postDate": "2018-04-10T11:49:14.063Z",
          "content": "<p>@Waleed @YL  well, I tried to train a lot  more epoch and small learning rate. however I never manage to get a val loss lower than 0.95.  maybe there is something missing in the code. or maybe some env thing matter. cause I  aslo didn't get LB0.44 with neptune's edition which is just a modified version of your code.</p>",
          "rawMarkdown": " @Waleed @YL  well, I tried to train a lot  more epoch and small learning rate. however I never manage to get a val loss lower than 0.95.  maybe there is something missing in the code. or maybe some env thing matter. cause I  aslo didn't get LB0.44 with neptune's edition which is just a modified version of your code.",
          "votes": 2
        }
      ]
    },
    {
      "id": 311404,
      "postDate": "2018-04-10T01:57:36.380Z",
      "content": "<p>Thanks for sharing.\nI when to train the model with two GPUs.I add to the NucleusConfig class \"GPU_COUNT = 2\".\nI get the following error when I run python3 nucleus.py train --dataset=/path/to/dataset --subset=train --weights=imagenet in multi-GPU:\nTraceback (most recent call last):\n  File \"/home/PycharmProjects/Mask_RCNN/mrcnn/model.py\", line 2039, in build\n    model = ParallelModel(model, config.GPU_COUNT)\n  File \"/home/PycharmProjects/Mask_RCNN/mrcnn/parallel_model.py\", line 37, in <strong>init</strong>\n    merged_outputs = self.make_parallel()\n  File \"/home/PycharmProjects/Mask_RCNN/mrcnn/parallel_model.py\", line 81, in make_parallel\n    outputs = self.inner_model(inputs)\n  File \"/home/panotech/PycharmProjects/Mask_RCNN/mrcnn/model.py\", line 1913, in \n    anchors = KL.Lambda(lambda x: tf.constant(anchors), name=\"anchors\")(input_image)\nTypeError: List of Tensors when single Tensor expected</p>\n\n<p>Is it not supportted the Multi-GPU training yet?</p>",
      "rawMarkdown": "Thanks for sharing.\nI when to train the model with two GPUs.I add to the NucleusConfig class \"GPU_COUNT = 2\".\nI get the following error when I run python3 nucleus.py train --dataset=/path/to/dataset --subset=train --weights=imagenet in multi-GPU:\nTraceback (most recent call last):\n  File \"/home/PycharmProjects/Mask_RCNN/mrcnn/model.py\", line 2039, in build\n    model = ParallelModel(model, config.GPU_COUNT)\n  File \"/home/PycharmProjects/Mask_RCNN/mrcnn/parallel_model.py\", line 37, in __init__\n    merged_outputs = self.make_parallel()\n  File \"/home/PycharmProjects/Mask_RCNN/mrcnn/parallel_model.py\", line 81, in make_parallel\n    outputs = self.inner_model(inputs)\n  File \"/home/panotech/PycharmProjects/Mask_RCNN/mrcnn/model.py\", line 1913, in ",
      "replies": [
        {
          "id": 311487,
          "postDate": "2018-04-10T06:20:59.003Z",
          "content": "<p>Indeed, it seems there is a bug with multi-GPU support. A work-around here: <a href=\"https://github.com/matterport/Mask_RCNN/issues/423\">https://github.com/matterport/Mask_RCNN/issues/423</a></p>",
          "rawMarkdown": "Indeed, it seems there is a bug with multi-GPU support. A work-around here: https://github.com/matterport/Mask_RCNN/issues/423"
        }
      ]
    },
    {
      "id": 311367,
      "postDate": "2018-04-09T23:34:26.403Z",
      "content": "<p>Hi @Waleed, I get the following error when I run in class NucleusConfig(Config):</p>\n\n<blockquote>\n  <p>TypeError                                 Traceback (most recent call last)\n   in ()\n        1 \n  ----&gt; 2 class NucleusConfig(Config):\n        3     \"\"\"Configuration for training on the toy  dataset.\n        4     Derives from the base Config class and overrides some values.\n        5     \"\"\"\n  TypeError: module.<strong>init</strong>() takes at most 2 arguments (3 given)</p>\n</blockquote>\n\n<p>I am using it in a notebook if that helps.</p>",
      "rawMarkdown": "Hi @Waleed, I get the following error when I run in class NucleusConfig(Config):\n\n&gt; TypeError                                 Traceback (most recent call last)\n",
      "replies": [
        {
          "id": 311395,
          "postDate": "2018-04-10T01:22:02.647Z",
          "content": "<p>Do the provided notebooks work for you?  </p>",
          "rawMarkdown": "Do the provided notebooks work for you?  "
        },
        {
          "id": 311584,
          "postDate": "2018-04-10T09:43:51.733Z",
          "content": "<p>@Waleed yes I am able to run both notebooks in samples/nucleus successfully. But when I run the NucleusConfig(Config) class I still get that error. </p>",
          "rawMarkdown": "@Waleed yes I am able to run both notebooks in samples/nucleus successfully. But when I run the NucleusConfig(Config) class I still get that error. "
        },
        {
          "id": 311922,
          "postDate": "2018-04-10T22:57:50.853Z",
          "content": "<p>Okay, so if the notebooks work then at least we know there isn't a bug in the code. I'm confused by your statement, though: \"when I run the NucleusConfig(Config) class\". What do you mean by running the class? Maybe open an issue on the github repo and post your code.</p>",
          "rawMarkdown": "Okay, so if the notebooks work then at least we know there isn't a bug in the code. I'm confused by your statement, though: \"when I run the NucleusConfig(Config) class\". What do you mean by running the class? Maybe open an issue on the github repo and post your code."
        },
        {
          "id": 312010,
          "postDate": "2018-04-11T03:45:57.453Z",
          "content": "<p>@Waleed, let me clarify. I am running Mask RCNN on Google colab. So I copy all the necessary files over create a notebook with all the functions you have in nucleus.py as cells in the notebook. That is how I have been using it all along. I just could not make the \"NucleusConfig(Config):\" class to work with your current modifications although I have changed my setup to follow your directory structure. That is why I am able to run your 2 notebooks because the setup is correct.</p>",
          "rawMarkdown": "@Waleed, let me clarify. I am running Mask RCNN on Google colab. So I copy all the necessary files over create a notebook with all the functions you have in nucleus.py as cells in the notebook. That is how I have been using it all along. I just could not make the \"NucleusConfig(Config):\" class to work with your current modifications although I have changed my setup to follow your directory structure. That is why I am able to run your 2 notebooks because the setup is correct."
        },
        {
          "id": 313973,
          "postDate": "2018-04-14T08:21:51.790Z",
          "content": "<p>Hi Waleed do you have any thoughts on why I get that error?</p>",
          "rawMarkdown": "Hi Waleed do you have any thoughts on why I get that error?"
        },
        {
          "id": 314608,
          "postDate": "2018-04-15T23:39:28.270Z",
          "content": "<p>No, sorry, I don't know why you're getting this error. It's clearly complaining that you're passing 3 parameters when you should be passing two, but without seeing your code it's hard to guess. </p>",
          "rawMarkdown": "No, sorry, I don't know why you're getting this error. It's clearly complaining that you're passing 3 parameters when you should be passing two, but without seeing your code it's hard to guess. "
        }
      ]
    },
    {
      "id": 311352,
      "postDate": "2018-04-09T22:36:39.233Z",
      "content": "<p>Thanks~!!! I got 0.376 LB score from original code.</p>",
      "rawMarkdown": "Thanks~!!! I got 0.376 LB score from original code."
    },
    {
      "id": 311332,
      "postDate": "2018-04-09T20:56:54.937Z",
      "content": "<p>This is awesome Waleed! thanks for sharing it with the community! </p>",
      "rawMarkdown": "This is awesome Waleed! thanks for sharing it with the community! "
    },
    {
      "id": 311269,
      "postDate": "2018-04-09T18:13:27.643Z",
      "content": "<p>Should we add the mask binarization threshold in model or in the config?  How many epochs do you your model? </p>",
      "rawMarkdown": "Should we add the mask binarization threshold in model or in the config?  How many epochs do you your model? ",
      "replies": [
        {
          "id": 311313,
          "postDate": "2018-04-09T20:11:30.797Z",
          "content": "<p>Mask binarization code is already there. I just changed the threshold value in the <code>unmold_mask()</code> function. This may or may not help your results, so try without it first. </p>\n\n<p>I can't give an exact epoch count because every time I make a change in the code I usually start from the last weights because it's faster. I don't start from imagenet every time. I put my best guess-estimate in the training code. The rule of thumb is to watch the validation loss and when it stops improving you stop the training.</p>",
          "rawMarkdown": "Mask binarization code is already there. I just changed the threshold value in the `unmold_mask()` function. This may or may not help your results, so try without it first. \n\nI can't give an exact epoch count because every time I make a change in the code I usually start from the last weights because it's faster. I don't start from imagenet every time. I put my best guess-estimate in the training code. The rule of thumb is to watch the validation loss and when it stops improving you stop the training."
        },
        {
          "id": 311323,
          "postDate": "2018-04-09T20:41:04.850Z",
          "content": "<p>Thank you!  I appreciate your help and expertise. :)</p>",
          "rawMarkdown": "Thank you!  I appreciate your help and expertise. :)"
        },
        {
          "id": 311403,
          "postDate": "2018-04-10T01:52:12.240Z",
          "content": "<p>What was your validation loss for the 0.476 submission?</p>",
          "rawMarkdown": "What was your validation loss for the 0.476 submission?"
        },
        {
          "id": 311483,
          "postDate": "2018-04-10T06:15:28.993Z",
          "content": "<p>Val loss varied between 0.85 and 0.75. Don't remember the exact value for the one I submitted, but I recall it wasn't the lowest. In other words, since the val dataset is so small, the correlation between loss value and LB score is not very reliable. </p>",
          "rawMarkdown": "Val loss varied between 0.85 and 0.75. Don't remember the exact value for the one I submitted, but I recall it wasn't the lowest. In other words, since the val dataset is so small, the correlation between loss value and LB score is not very reliable. ",
          "votes": 1
        },
        {
          "id": 311564,
          "postDate": "2018-04-10T08:51:05.617Z",
          "content": "<p>Thank you.</p>",
          "rawMarkdown": "Thank you."
        },
        {
          "id": 311663,
          "postDate": "2018-04-10T12:59:44.633Z",
          "content": "<p>@Waleed I got .394 after 83 epochs (validation loss  and training loss are is in range of 1.00-1.25 and 0.70-0.74).</p>\n\n<p>Here is what I did</p>\n\n<ol>\n<li>I used the cleaned up data posted on the githup</li>\n<li>epochs 0-20 heads with default learning rate given in your code\nepochs 20-40 all with default learning rate\nepochs 40-60 all layers with default learning rate/10\nepochs 60-83 all layers with default learning rate/100</li>\n<li>I have a single gpu and I am using IMAGES_PER_GPU = 8</li>\n<li>I used imagenet weight </li>\n<li>no pre or post processing</li>\n<li>no change in binarization threshold in unmold_mask</li>\n</ol>\n\n<p>I am training now from epochs 83 onwards with default learning rate/1000 currently its on 106th epochs with validation loss 1.05 and training loss 0.74 </p>\n\n<p>Clearly no improvement in training and validation loss. Do you have any suggestion how to reduce the validation and training loss.</p>",
          "rawMarkdown": "@Waleed I got .394 after 83 epochs (validation loss  and training loss are is in range of 1.00-1.25 and 0.70-0.74).\n\nHere is what I did\n\n1. I used the cleaned up data posted on the githup\n2. epochs 0-20 heads with default learning rate given in your code\n    epochs 20-40 all with default learning rate\n    epochs 40-60 all layers with default learning rate/10\n    epochs 60-83 all layers with default learning rate/100\n3. I have a single gpu and I am using IMAGES_PER_GPU = 8\n4. I used imagenet weight \n5. no pre or post processing\n6. no change in binarization threshold in unmold_mask\n\nI am training now from epochs 83 onwards with default learning rate/1000 currently its on 106th epochs with validation loss 1.05 and training loss 0.74 \n\nClearly no improvement in training and validation loss. Do you have any suggestion how to reduce the validation and training loss.",
          "votes": 1
        },
        {
          "id": 311908,
          "postDate": "2018-04-10T22:04:14.150Z",
          "content": "<p>Given the small dataset, I think long training, especially with small learning rate is more likely to cause overfitting than to help. I only used the base learning rate, not even / 10. Ignore the training loss and just keep an eye on the validation loss. When the validation loss stops going down stop the training.</p>",
          "rawMarkdown": "Given the small dataset, I think long training, especially with small learning rate is more likely to cause overfitting than to help. I only used the base learning rate, not even / 10. Ignore the training loss and just keep an eye on the validation loss. When the validation loss stops going down stop the training.",
          "votes": 1
        }
      ]
    },
    {
      "id": 312467,
      "postDate": "2018-04-11T19:49:11.800Z",
      "rawMarkdown": "",
      "isDeleted": true
    },
    {
      "id": 316132,
      "postDate": "2018-04-18T08:30:59.427Z",
      "content": "<p>Thank you</p>",
      "rawMarkdown": "Thank you"
    },
    {
      "id": 312471,
      "postDate": "2018-04-11T20:04:40.280Z",
      "content": "<p>Thanks for sharing!</p>",
      "rawMarkdown": "Thanks for sharing!"
    },
    {
      "id": 312080,
      "postDate": "2018-04-11T06:48:56.357Z",
      "content": "<p>Thank you for the code !</p>",
      "rawMarkdown": "Thank you for the code !"
    },
    {
      "id": 311359,
      "postDate": "2018-04-09T23:09:41.387Z",
      "content": "<p>@Waleed, thanks so much for sharing.</p>",
      "rawMarkdown": "@Waleed, thanks so much for sharing."
    },
    {
      "id": 311280,
      "postDate": "2018-04-09T18:32:11.150Z",
      "content": "<p>Thanks a lot!</p>",
      "rawMarkdown": "Thanks a lot!"
    },
    {
      "id": 311249,
      "postDate": "2018-04-09T17:28:12.137Z",
      "content": "<p>Thank you for your code!</p>",
      "rawMarkdown": "Thank you for your code!"
    },
    {
      "id": 311230,
      "postDate": "2018-04-09T16:43:29.753Z",
      "content": "<p>Awesome! Thank you. </p>",
      "rawMarkdown": "Awesome! Thank you. "
    },
    {
      "id": 311217,
      "postDate": "2018-04-09T16:18:16.027Z",
      "content": "<p>Awesome! Thank you</p>",
      "rawMarkdown": "Awesome! Thank you"
    }
  ],
  "comments": [
    {
      "id": 315746,
      "author_name": "AviWolfson",
      "author_url": "",
      "post_date": "2018-04-17T14:38:11.630000",
      "content": "<p>we used matter port and like I said it gave us in stage one 0.532 only the model. </p>\n\n<p>our config was - </p>\n\n<pre><code>IMAGE_MAX_DIM    =  1024\nIMAGE_MIN_DIM    = 512\nRPN_ANCHOR_SCALES   =    (8,16,32,64,128)\nRPN_ANCHOR_RATIOS =[0.5,1,2]   \nRPN_ANCHOR_STRIDE=1\n\nDETECTION_MAX_INSTANCES=500\nRPN_TRAIN_ANCHORS_PER_IMAGE=250\nTRAIN_ROIS_PER_IMAGE = 500\nLEARNING_RATE = 0.01 \n#USE_MINI_MASK = False       \n\n# Image mean (RGB)\nMEAN_PIXEL = np.array([123.7, 116.8, 103.9])\nDETECTION_MAX_INSTANCES=500\nMAX_GT_INSTANCES=500\n</code></pre>\n\n<p>going to 1024 from 256 got us better result. </p>\n\n<p>what was really meaningful is training with coco pertained model.  training only heads got us to 0.504 after 8 epochs\nafter that we trained more heads and 0.2 extra points was training 3+ for more epochs. using smaller lr</p>\n\n<p>I trained on lr 0.002 and tuning 0.0005. </p>\n\n<p>detecting with 0.8 confidence and 0.3 mms gave best results. </p>\n\n<p>we used of course many basic augmentation like rotate and zoom and noise. \nwe excluded masks that where empty after the augmentation.</p>",
      "votes": 8,
      "replies": [
        {
          "id": 315791,
          "author_name": "ls",
          "author_url": "",
          "post_date": "2018-04-17T15:56:05.187000",
          "content": "<p>I used size 512, I tried 1024 and didn't see much improvement, perhaps I messed up the config. Thanks for sharing this. </p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 315795,
          "author_name": "Dhaval Mayatra",
          "author_url": "",
          "post_date": "2018-04-17T16:00:40.133000",
          "content": "<p>Thanks for sharing your config.\nI used 512 and got about 0.44. I used model pre-trained on COCO.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 315975,
          "author_name": "YaGana Sheriff-Hussaini",
          "author_url": "",
          "post_date": "2018-04-17T23:11:42.867000",
          "content": "<p>@AviWolfson thanks for sharing. </p>\n\n<p>A quick question, did you use the latest matterport code or the one before his recent updates as from early April? I get different results between the 2 versions. Better LB with the older code.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 316060,
          "author_name": "AviWolfson",
          "author_url": "",
          "post_date": "2018-04-18T05:35:08.487000",
          "content": "<p>the oldest one</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 316061,
          "author_name": "AviWolfson",
          "author_url": "",
          "post_date": "2018-04-18T05:35:49.540000",
          "content": "<p>have u done rotating augmentation? I am sure all of the augmentation we did contrib too</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 316076,
          "author_name": "YaGana Sheriff-Hussaini",
          "author_url": "",
          "post_date": "2018-04-18T06:21:51.723000",
          "content": "<p>@AviWolfson, augmentation made both val_loss and LB scores worse when I used it with my UNET model. So when I later used mask RCNN, I did not try it.</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 316700,
          "author_name": "Mehul Sampat",
          "author_url": "",
          "post_date": "2018-04-19T17:37:01.573000",
          "content": "<p>@AviWolfson! Thanks for sharing the parameters. I made this doc to compare parameters across contestants.\n<a href=\"https://github.com/mpsampat/DSB_2018_Parameter_Selection_For_Matterport_Mask_RCNN/blob/master/comparison_of_Matterport_Mask_RCNN_parameters.md\">https://github.com/mpsampat/DSB_2018_Parameter_Selection_For_Matterport_Mask_RCNN/blob/master/comparison_of_Matterport_Mask_RCNN_parameters.md</a>\nIf you have time, could you send me your missing parameters ? \nAlso did you use this Mask_RCNN code base \n <a href=\"https://github.com/killthekitten/kaggle-ds-bowl-2018-baseline\">https://github.com/killthekitten/kaggle-ds-bowl-2018-baseline</a></p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 311650,
      "author_name": "AviWolfson",
      "author_url": "",
      "post_date": "2018-04-10T12:32:52.633000",
      "content": "<p>I got with matterport 0.532</p>",
      "votes": 5,
      "replies": [
        {
          "id": 311653,
          "author_name": "gezi",
          "author_url": "",
          "post_date": "2018-04-10T12:39:43.203000",
          "content": "<p>Awaresome, is it single model ? </p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 311668,
          "author_name": "AviWolfson",
          "author_url": "",
          "post_date": "2018-04-10T13:13:59.707000",
          "content": "<p>yes. only by training matterport single model. of course I took time to find the right way to train it</p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 311670,
          "author_name": "William Green",
          "author_url": "",
          "post_date": "2018-04-10T13:17:33.073000",
          "content": "<p>Do you have any tips you would like to share? </p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 311739,
          "author_name": "nino",
          "author_url": "",
          "post_date": "2018-04-10T15:29:12.583000",
          "content": "<p>could you share more detail of your training?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 311958,
          "author_name": "kirk",
          "author_url": "",
          "post_date": "2018-04-11T01:30:32.950000",
          "content": "<p>@AviWolfson What do you mean by the right way to train? Could you elaborate a bit?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 311973,
          "author_name": "dingxianghu",
          "author_url": "",
          "post_date": "2018-04-11T02:16:23.527000",
          "content": "<p>could you share some idea or config setup?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 312073,
          "author_name": "AviWolfson",
          "author_url": "",
          "post_date": "2018-04-11T06:14:52.360000",
          "content": "<p>I will share it in the end of the competition</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 311203,
      "author_name": "gezi",
      "author_url": "",
      "post_date": "2018-04-09T15:56:23.247000",
      "content": "<p>Thanks for sharing! I used your code and actually the pretrain resnet 101 coco model is also a good choice.</p>",
      "votes": 1,
      "replies": [
        {
          "id": 312510,
          "author_name": "Alvis Wong",
          "author_url": "",
          "post_date": "2018-04-11T21:56:55.620000",
          "content": "<p>Did you try both 101 and 50? \nHow much additional training did you do on the pre-existing model?</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 315280,
      "author_name": "huiqin",
      "author_url": "",
      "post_date": "2018-04-17T00:38:53.543000",
      "content": "<p>Thanks for sharing!  I used resnet 50 coco model  and swish activation instead of relu activation .  Trained head network 20 epoches(val loss 0.89), then got 0.477 score.  Again trained the all layers 20 epoches(val loss 0.75),then got 0.48 score.  Matterport Mask-RCNN is very good! </p>",
      "votes": 2,
      "replies": []
    },
    {
      "id": 315194,
      "author_name": "YL",
      "author_url": "",
      "post_date": "2018-04-16T21:12:06.803000",
      "content": "<p>Many thanks to Waleed for sharing the solution with us. It's been a steep and painful learning curve for me but it's definitely worth it.</p>\n\n<p>I have encountered a number of difficulties on this journey. Since it's approaching the end of this competition, I would like to start the discussion here and hopefully help myself and others to gain further understanding of the implementation. </p>\n\n<p>For myself, I found the main problem seems to come from black and white images. my models are suffereing from main two main problems: 1) miss cells, and 2) not masking enough area. </p>\n\n<p>I have tried tweaking the parameters in the configurations, for example RPN_TRAIN_ANCHORS_PER_IMAGE, TRAIN_ROIS_PER_IMAGE, MAX_GT_INSTANCES, DETECTION_MAX_INSTANCES, etc. but none of them seems to bring any significant improvement</p>\n\n<p>I have also tried various learning rates, no effect either. I can always achieve an overall all loss between 0.7 ~ 0.8, and an rcnn mask loss of 0.2~0.25. This seems to be inline with what others are getting, but my 1st stage public LB is only 0.36.</p>\n\n<p>Therefore I am asking if anyone has experienced the same issues and if and how you've got around it. </p>\n\n<p>Many thanks in advance!</p>",
      "votes": 2,
      "replies": [
        {
          "id": 315205,
          "author_name": "Mehul Sampat",
          "author_url": "",
          "post_date": "2018-04-16T21:34:07.063000",
          "content": "<p>Hi @YL\nYes you are absolutely right! Many thanks to @Waleed for sharing the code! </p>\n\n<p>I used his latest code; the highest i got up to on stage1 was 0.472 with 8 epochs. \nIf you go here you can see my code: <a href=\"https://github.com/mpsampat/dsb_2018\">https://github.com/mpsampat/dsb_2018</a>\nThe main class for training is: \n<a href=\"https://github.com/mpsampat/dsb_2018/blob/master/train_mask_rcnn.py\">https://github.com/mpsampat/dsb_2018/blob/master/train_mask_rcnn.py</a>\n(Sorry it is not very polished ; but you can see the general idea) </p>\n\n<p>For train/validation split i used the code from the neptune github repo\n<a href=\"https://github.com/neptune-ml/open-solution-data-science-bowl-2018\">https://github.com/neptune-ml/open-solution-data-science-bowl-2018</a>\n(that is i run main.py -- prepare_metadata option) </p>",
          "votes": 3,
          "replies": []
        },
        {
          "id": 315222,
          "author_name": "YL",
          "author_url": "",
          "post_date": "2018-04-16T22:18:15.960000",
          "content": "<p>Hi Mehul</p>\n\n<p>Thanks for the reply.</p>\n\n<p>That is impressive with for just 8 epochs of training. </p>\n\n<p>For me, I found the colour image yielded a better result than grey images.</p>\n\n<p>Also, may I ask what is your criteria for selecting the final epoch. rcnn mask loss? or total val loss.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 315227,
          "author_name": "Mehul Sampat",
          "author_url": "",
          "post_date": "2018-04-16T22:34:18.807000",
          "content": "<p>val_rcnn_mask_loss was the best one for me. initially i was using val_total_loss; but then i shifted to mask_loss. </p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 311220,
      "author_name": "Xiang Zhang",
      "author_url": "",
      "post_date": "2018-04-09T16:21:52.033000",
      "content": "<p>Thanks ! I'm learning your code deep right now!</p>",
      "votes": -1,
      "replies": []
    },
    {
      "id": 885572,
      "author_name": "Shubham Gujar",
      "author_url": "",
      "post_date": "2020-06-14T10:23:12.797000",
      "content": "<p>Hii, I am new to these techniques I went through the files provided, but I couldn't really figure out how to proceed if you have your own dataset and also without weights file? A detailed implementation of this would be much appreciated. thanks.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 808201,
      "author_name": "Innat",
      "author_url": "",
      "post_date": "2020-04-15T07:53:43.443000",
      "content": "<p><a href=\"/waleedka\">@waleedka</a> hi, thanks for sharing. Query: what else special care do you think should be considered while detecting or localizing such small targets on the large spatial?</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 314425,
      "author_name": "Shitian Ni",
      "author_url": "",
      "post_date": "2018-04-15T14:44:24.993000",
      "content": "<p>Is it usual to get <code>*** No instances to display ***</code> in detect process? Does that just mean no region detected? </p>",
      "votes": 0,
      "replies": [
        {
          "id": 314523,
          "author_name": "dingyan",
          "author_url": "",
          "post_date": "2018-04-15T18:28:03.080000",
          "content": "<p>I guess so. In my results of stage2_test,  346 test images are not been detected(total image number is 3019). Meanwhile, it will generate images in 'results' file and you can check the results of test data. I turned off the 'save image with masks'  because it will occupy my disk. But it is very helpful to check the result and analysis.  It takes me about 9 hours to generate stage2_test submission.</p>",
          "votes": 2,
          "replies": []
        }
      ]
    },
    {
      "id": 313909,
      "author_name": "Alvis Wong",
      "author_url": "",
      "post_date": "2018-04-14T03:56:57.247000",
      "content": "<p>nucleus.py is not utilizing my GPU</p>\n\n<p>I have a K80 GPU but when running python3 nucleus.py train --dataset=../../../dsbowl/ --subset=train --weights=imagenet, training each epoch is extremely slow, this is my config:\n<code>\nConfigurations:\nBACKBONE                       resnet50\nBACKBONE_STRIDES               [4, 8, 16, 32, 64]\nBATCH_SIZE                     20\nBBOX_STD_DEV                   [0.1 0.1 0.2 0.2]\nDETECTION_MAX_INSTANCES        400\nDETECTION_MIN_CONFIDENCE       0\nDETECTION_NMS_THRESHOLD        0.3\nGPU_COUNT                      2\nGRADIENT_CLIP_NORM             5.0\nIMAGES_PER_GPU                 10\nIMAGE_MAX_DIM                  512\nIMAGE_META_SIZE                14\nIMAGE_MIN_DIM                  512\nIMAGE_MIN_SCALE                2.0\nIMAGE_RESIZE_MODE              crop\nIMAGE_SHAPE                    [512 512   3]\nLEARNING_MOMENTUM              0.9\nLEARNING_RATE                  0.001\nMASK_POOL_SIZE                 14\nMASK_SHAPE                     [28, 28]\nMAX_GT_INSTANCES               200\nMEAN_PIXEL                     [43.53 39.56 48.22]\nMINI_MASK_SHAPE                (56, 56)\nNAME                           nucleus\nNUM_CLASSES                    2\nPOOL_SIZE                      7\nPOST_NMS_ROIS_INFERENCE        2000\nPOST_NMS_ROIS_TRAINING         1000\nROI_POSITIVE_RATIO             0.33\nRPN_ANCHOR_RATIOS              [0.5, 1, 2]\nRPN_ANCHOR_SCALES              (8, 16, 32, 64, 128)\nRPN_ANCHOR_STRIDE              1\nRPN_BBOX_STD_DEV               [0.1 0.1 0.2 0.2]\nRPN_NMS_THRESHOLD              0.9\nRPN_TRAIN_ANCHORS_PER_IMAGE    64\nSTEPS_PER_EPOCH                63\nTRAIN_BN                       False\nTRAIN_ROIS_PER_IMAGE           128\nUSE_MINI_MASK                  True\nUSE_RPN_ROIS                   True\nVALIDATION_STEPS               2\nWEIGHT_DECAY                   0.0001\n</code></p>",
      "votes": 0,
      "replies": [
        {
          "id": 313963,
          "author_name": "Dhaval Mayatra",
          "author_url": "",
          "post_date": "2018-04-14T07:15:28.230000",
          "content": "<p>Are you using Google Colab?\nYour config says GPU_COUNT 2! Do you have 2 GPUs?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 314147,
          "author_name": "Alvis Wong",
          "author_url": "",
          "post_date": "2018-04-14T18:24:43.503000",
          "content": "<p>In mrcnn it says # NUMBER OF GPUs to use. For CPU training, use 1 though \n<a href=\"https://github.com/matterport/Mask_RCNN/blob/ba0c8ba3a22b235101bcd4a9441f7b2f603a8b7d/mrcnn/config.py#L28\">https://github.com/matterport/Mask_RCNN/blob/ba0c8ba3a22b235101bcd4a9441f7b2f603a8b7d/mrcnn/config.py#L28</a></p>\n\n<p>and in <a href=\"https://github.com/matterport/Mask_RCNN/blob/512921dde25ec07c8db373f0457da8d58fff0735/mrcnn/parallel_model.py#L33\">https://github.com/matterport/Mask_RCNN/blob/512921dde25ec07c8db373f0457da8d58fff0735/mrcnn/parallel_model.py#L33</a>\nit says gpu_count: Number of GPUs. Must be &gt; 1</p>\n\n<p>Even if I changed it back to 1, it's still the same</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 314607,
          "author_name": "Waleed",
          "author_url": "",
          "post_date": "2018-04-15T23:36:00.043000",
          "content": "<p>Both comments are correct: the first is about the config setting, which you should set to the number of GPUs (or 1 if you're training on a CPU). The second describes a parameter passed to the ParallelModel class, which is never called unless you have more than one GPU. </p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 314631,
          "author_name": "Alvis Wong",
          "author_url": "",
          "post_date": "2018-04-16T01:18:18.030000",
          "content": "<p>I see, thanks :)</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 313869,
      "author_name": "Mehul Sampat",
      "author_url": "",
      "post_date": "2018-04-14T01:19:23.027000",
      "content": "<p>@Waleed, did you try and retrain using stage1_train + stage1_test ? I am trying this; Interesting after 10 epochs my val_loss is much higher (in the range of 2.5 whereas with only stage1_train data it was in 0.7 range</p>",
      "votes": 0,
      "replies": [
        {
          "id": 314605,
          "author_name": "Waleed",
          "author_url": "",
          "post_date": "2018-04-15T23:32:25.020000",
          "content": "<p>I haven't tried yet. But 2.5 val loss seems high. Sure you don't have a bug in loading the stage 1 test data?</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 312687,
      "author_name": "dingxianghu",
      "author_url": "",
      "post_date": "2018-04-12T06:37:29.363000",
      "content": "<p>hi,could show your config ? caus for training_data my loss is 0.66,val_loss 0.7,but detection performence is really bad , AND only get LB0.224</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 312649,
      "author_name": "Iswariya Ravi",
      "author_url": "",
      "post_date": "2018-04-12T05:04:12.047000",
      "content": "<p>can you share little more detail of your training set?</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 312588,
      "author_name": "CrazyBug_ZhangAY2018",
      "author_url": "",
      "post_date": "2018-04-12T02:25:11.507000",
      "content": "<p>hi,  I got the error as bellow  and  i have no idea why this will happen</p>\n\n<p>Running on /content/.kaggle/competitions/data-science-bowl-2018/\nTraceback (most recent call last):\n  File \"nucleus.py\", line 486, in \n    detect(model, args.dataset, args.subset)\n  File \"nucleus.py\", line 383, in detect\n    rle = mask_to_rle(source_id, r[\"masks\"], r[\"scores\"])\n  File \"nucleus.py\", line 342, in mask_to_rle\n    mask = np.max(mask * np.reshape(order, [1, 1, -1]), -1)\nValueError: operands could not be broadcast together with shapes (0,28,28) (1,1,0)</p>",
      "votes": 0,
      "replies": [
        {
          "id": 312593,
          "author_name": "Akila Wajirasena",
          "author_url": "",
          "post_date": "2018-04-12T02:39:51.497000",
          "content": "<p>There are several garbage images in the stage 2 data. (for example 223fcf1a3652bb711ab3b4f3d160938022df2a31dd39b46e2a5c592e333dd21c). We will have to change the code to handle those. I just ignored all the images with mask shape (0, X, X) when calculating rle.</p>",
          "votes": 3,
          "replies": []
        },
        {
          "id": 312602,
          "author_name": "CrazyBug_ZhangAY2018",
          "author_url": "",
          "post_date": "2018-04-12T02:59:53.243000",
          "content": "<p>I tried! works Great! thanks!</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 313419,
          "author_name": "Waleed",
          "author_url": "",
          "post_date": "2018-04-13T08:20:02.780000",
          "content": "<p>I pushed a fix to handle this edge case. </p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 313685,
          "author_name": "CrazyBug_ZhangAY2018",
          "author_url": "",
          "post_date": "2018-04-13T17:36:53.483000",
          "content": "<p>thanks! it makes more sense. i found the generated predictions contain a lot of overlap masks. Is that normal?</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 312473,
      "author_name": "kirk",
      "author_url": "",
      "post_date": "2018-04-11T20:13:13.140000",
      "content": "<p>@Waleed Hi, is the implementation correct?  I see the validation loss fluctuating a lot but not decreasing.</p>",
      "votes": 0,
      "replies": [
        {
          "id": 312485,
          "author_name": "Waleed",
          "author_url": "",
          "post_date": "2018-04-11T20:29:54.300000",
          "content": "<p>The fluctuations are normal because the validation dataset is so small. I did get the val loss to go down to 0.75~0.8, though. Maybe your config parameters are slightly different?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 312507,
          "author_name": "kirk",
          "author_url": "",
          "post_date": "2018-04-11T21:47:04.530000",
          "content": "<p>What are your configs? I tried to follow what you said in a previous thread increasing the number of max detections in image since there are many nuclei, etc., but still can't get 0.75. Did you achieve that with the same validation dataset and were the configs the same as the ones in the repo? Thanks!</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 312515,
          "author_name": "Waleed",
          "author_url": "",
          "post_date": "2018-04-11T22:06:02.087000",
          "content": "<p>Yes, same as in the repo except for two things I mentioned above. \n1. I changed the mask threshold to 0.4 in the unmold_mask function\n2. My training schedule was a bit random because in every experiment I simply started from the weights of the last experiment for speed. </p>\n\n<p>I don't know if #2 has any effect on the result. I doubt it, but we're dealing with a small dataset so every little variation can have a big effect. Try learning rate cycling and see if that helps. As in, let it converge, then raise the learning rate for a bit and drop it again, and so on. </p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 312548,
          "author_name": "kirk",
          "author_url": "",
          "post_date": "2018-04-12T01:10:33.753000",
          "content": "<p>I believe that most of us start from weights=last, so I don't think its #2. I'll try with mask threshold 0.4 and report back. Thanks! </p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 313977,
          "author_name": "Shitian Ni",
          "author_url": "",
          "post_date": "2018-04-14T08:38:50.877000",
          "content": "<p>Thank you! Is it needed to rerun <code>python3 setup.py install</code> after modifying <code>unmold_mask</code>?</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 312308,
      "author_name": "Comp_Rice_xg21_xy25",
      "author_url": "",
      "post_date": "2018-04-11T14:46:55.980000",
      "content": "<p>Thank you so much for sharing! @Waleed, I am sorry that I got a bug during implementation,\n ipykernel_launcher.py: error: the following arguments are required: --weights\nAn exception has occurred, use %tb to see the full traceback.\nHow can I solve this problem?</p>",
      "votes": 0,
      "replies": [
        {
          "id": 312409,
          "author_name": "Dhaval Mayatra",
          "author_url": "",
          "post_date": "2018-04-11T17:41:34.693000",
          "content": "<p>Try adding <code>--weights=imagenet</code> to your arguments.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 312197,
      "author_name": "Ioannis",
      "author_url": "",
      "post_date": "2018-04-11T11:06:05.437000",
      "content": "<p>Thank you for the code! However I get the following error when trying to train (using Spyder IDE, on Windows).  </p>\n\n<p>Any suggestions welcome.</p>\n\n<p>Traceback (most recent call last):</p>\n\n<p>File \"\", line 1, in \n    train(model)</p>\n\n<p>File \"\", line 34, in train\n    layers='heads')</p>\n\n<p>File \"C:/Users/Ioannis/GitHub/Mask_RCNN\\mrcnn\\model.py\", line 2317, in train\n    use_multiprocessing=True,</p>\n\n<p>File \"C:\\Users\\Ioannis\\Anaconda3\\lib\\site-packages\\keras\\legacy\\interfaces.py\", line 87, in wrapper\n    return func(*args, **kwargs)</p>\n\n<p>File \"C:\\Users\\Ioannis\\Anaconda3\\lib\\site-packages\\keras\\engine\\training.py\", line 2046, in fit_generator\n    generator_output = next(output_generator)</p>\n\n<p>File \"C:\\Users\\Ioannis\\Anaconda3\\lib\\site-packages\\keras\\utils\\data_utils.py\", line 659, in get\n    raise StopIteration()</p>\n\n<p>StopIteration</p>",
      "votes": 0,
      "replies": [
        {
          "id": 312201,
          "author_name": "Dmytro Fishman",
          "author_url": "",
          "post_date": "2018-04-11T11:17:15.643000",
          "content": "<p>Hi Ioannis, look at my comment above, I am quite certain that one of your folders have name 'images', check if you do, and rename them if needed. I was getting the same StopIteration errors.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 312669,
          "author_name": "Ioannis",
          "author_url": "",
          "post_date": "2018-04-12T05:41:47.840000",
          "content": "<p>Thanks Dima, unfortunately this was not the case for me. Will debug this over the weekend if I find some time...</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 313643,
          "author_name": "Ioannis",
          "author_url": "",
          "post_date": "2018-04-13T16:09:13.553000",
          "content": "<p>As somebody else suggested here <a href=\"https://www.kaggle.com/c/data-science-bowl-2018/discussion/50903#294190\">https://www.kaggle.com/c/data-science-bowl-2018/discussion/50903#294190</a>, I updated Keras and problem was solved. </p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 312186,
      "author_name": "Julien Angeloni",
      "author_url": "",
      "post_date": "2018-04-11T10:46:34.010000",
      "content": "<p>Great job !</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 312131,
      "author_name": "zhangqiang",
      "author_url": "",
      "post_date": "2018-04-11T08:47:36.803000",
      "content": "<p>I have a question. How to give a weighing for every image?</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 312042,
      "author_name": "Sine ZHENG",
      "author_url": "",
      "post_date": "2018-04-11T05:09:31.163000",
      "content": "<p>can I use the GPU when running nucleus.py? The CPU version is so slow ......</p>",
      "votes": 0,
      "replies": [
        {
          "id": 312452,
          "author_name": "Andrew Yip",
          "author_url": "",
          "post_date": "2018-04-11T19:22:30.183000",
          "content": "<p>bumped into this as well, setting GPU_COUNT=2 results in error.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 312484,
          "author_name": "Waleed",
          "author_url": "",
          "post_date": "2018-04-11T20:25:05.303000",
          "content": "<p>The latest version fixes that</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 311595,
      "author_name": "Dmytro Fishman",
      "author_url": "",
      "post_date": "2018-04-10T10:33:34.183000",
      "content": "<p>Thank you @Waleed for sharing this, also for the original re-implementation of Mask R-CNN, it was very useful. I have found a small bug/issue with this pipeline - you use .split(\"/images/\") in your code (nucleus.py, 229L) in order to derive path to masks, but it might be faulty in case someone would have name \"images\" in their path e.g. in our case /Kaggle/spotNuclei/images/raw_fixed/stage1_train/img1/images/img1.png. I am not a big Python expert here, but this line <code>mask_dir = \"/\" + os.path.join(*(os.path.join(info[\"path\"]).split(\"/\")[:-2])) + \"/masks/\"</code> looks more robust (probable there is more elegant solution). Can do a PR if this sounds meaningful. </p>",
      "votes": 0,
      "replies": [
        {
          "id": 311921,
          "author_name": "Waleed",
          "author_url": "",
          "post_date": "2018-04-10T22:55:38.277000",
          "content": "<p>Good point. Just pushed a fix.</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 311435,
      "author_name": "notbad",
      "author_url": "",
      "post_date": "2018-04-10T03:55:32.210000",
      "content": "<p>Hi, can you share  your training schedule , As I only get 0.356 with the default traing schedule,the only thing I modified is when a I train \"all\" I set the batch size to 4 due to OOM. by the way after I finish 40 epoch training  I get a total loss around 0.75</p>",
      "votes": 0,
      "replies": [
        {
          "id": 311478,
          "author_name": "Waleed",
          "author_url": "",
          "post_date": "2018-04-10T06:07:48.010000",
          "content": "<p>My val loss was around 0.75 as well, but the training loss was lower. </p>\n\n<p>Every time I make a change, I train from the last trained model because it's faster than starting from imagenet all over again, so I don't know exactly how many epochs it would take to do it in one stretch from imagenet. But, even early on when I did start with imagenet, it got more than 0.4. Maybe you haven't trained it long enough yet. Or maybe reducing the batch size is the issue. If so, try training longer and reduce the learning rate. Also, verify that you're training with the cleaned up dataset.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 311503,
          "author_name": "notbad",
          "author_url": "",
          "post_date": "2018-04-10T06:59:38.140000",
          "content": "<p>thank you, I guess the the problem was not enough training time. maybe as we are using a relative small batch size, so we always end up traning too early just because the  loss won't go down. but in fact the network just not learned enough.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 311563,
          "author_name": "YL",
          "author_url": "",
          "post_date": "2018-04-10T08:48:11.780000",
          "content": "<p>I was trying to do k fold cross validation and and I found that for each fold the validation score reaches min  normally after 10 epochs at lr of 0.001 (I have included external data), and I then used a small learning rate but this will give me another min in 2-3 epochs.</p>\n\n<p>but even with this the best score i get is only .35</p>\n\n<p>therefore i am really puzzle.  cross validation score should really be used to guide the training no?   or image process is an entirely different planet?</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 311630,
          "author_name": "notbad",
          "author_url": "",
          "post_date": "2018-04-10T11:49:14.063000",
          "content": "<p>@Waleed @YL  well, I tried to train a lot  more epoch and small learning rate. however I never manage to get a val loss lower than 0.95.  maybe there is something missing in the code. or maybe some env thing matter. cause I  aslo didn't get LB0.44 with neptune's edition which is just a modified version of your code.</p>",
          "votes": 2,
          "replies": []
        }
      ]
    },
    {
      "id": 311404,
      "author_name": "zhousheng",
      "author_url": "",
      "post_date": "2018-04-10T01:57:36.380000",
      "content": "<p>Thanks for sharing.\nI when to train the model with two GPUs.I add to the NucleusConfig class \"GPU_COUNT = 2\".\nI get the following error when I run python3 nucleus.py train --dataset=/path/to/dataset --subset=train --weights=imagenet in multi-GPU:\nTraceback (most recent call last):\n  File \"/home/PycharmProjects/Mask_RCNN/mrcnn/model.py\", line 2039, in build\n    model = ParallelModel(model, config.GPU_COUNT)\n  File \"/home/PycharmProjects/Mask_RCNN/mrcnn/parallel_model.py\", line 37, in <strong>init</strong>\n    merged_outputs = self.make_parallel()\n  File \"/home/PycharmProjects/Mask_RCNN/mrcnn/parallel_model.py\", line 81, in make_parallel\n    outputs = self.inner_model(inputs)\n  File \"/home/panotech/PycharmProjects/Mask_RCNN/mrcnn/model.py\", line 1913, in \n    anchors = KL.Lambda(lambda x: tf.constant(anchors), name=\"anchors\")(input_image)\nTypeError: List of Tensors when single Tensor expected</p>\n\n<p>Is it not supportted the Multi-GPU training yet?</p>",
      "votes": 0,
      "replies": [
        {
          "id": 311487,
          "author_name": "Waleed",
          "author_url": "",
          "post_date": "2018-04-10T06:20:59.003000",
          "content": "<p>Indeed, it seems there is a bug with multi-GPU support. A work-around here: <a href=\"https://github.com/matterport/Mask_RCNN/issues/423\">https://github.com/matterport/Mask_RCNN/issues/423</a></p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 311367,
      "author_name": "YaGana Sheriff-Hussaini",
      "author_url": "",
      "post_date": "2018-04-09T23:34:26.403000",
      "content": "<p>Hi @Waleed, I get the following error when I run in class NucleusConfig(Config):</p>\n\n<blockquote>\n  <p>TypeError                                 Traceback (most recent call last)\n   in ()\n        1 \n  ----&gt; 2 class NucleusConfig(Config):\n        3     \"\"\"Configuration for training on the toy  dataset.\n        4     Derives from the base Config class and overrides some values.\n        5     \"\"\"\n  TypeError: module.<strong>init</strong>() takes at most 2 arguments (3 given)</p>\n</blockquote>\n\n<p>I am using it in a notebook if that helps.</p>",
      "votes": 0,
      "replies": [
        {
          "id": 311395,
          "author_name": "Waleed",
          "author_url": "",
          "post_date": "2018-04-10T01:22:02.647000",
          "content": "<p>Do the provided notebooks work for you?  </p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 311584,
          "author_name": "YaGana Sheriff-Hussaini",
          "author_url": "",
          "post_date": "2018-04-10T09:43:51.733000",
          "content": "<p>@Waleed yes I am able to run both notebooks in samples/nucleus successfully. But when I run the NucleusConfig(Config) class I still get that error. </p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 311922,
          "author_name": "Waleed",
          "author_url": "",
          "post_date": "2018-04-10T22:57:50.853000",
          "content": "<p>Okay, so if the notebooks work then at least we know there isn't a bug in the code. I'm confused by your statement, though: \"when I run the NucleusConfig(Config) class\". What do you mean by running the class? Maybe open an issue on the github repo and post your code.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 312010,
          "author_name": "YaGana Sheriff-Hussaini",
          "author_url": "",
          "post_date": "2018-04-11T03:45:57.453000",
          "content": "<p>@Waleed, let me clarify. I am running Mask RCNN on Google colab. So I copy all the necessary files over create a notebook with all the functions you have in nucleus.py as cells in the notebook. That is how I have been using it all along. I just could not make the \"NucleusConfig(Config):\" class to work with your current modifications although I have changed my setup to follow your directory structure. That is why I am able to run your 2 notebooks because the setup is correct.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 313973,
          "author_name": "YaGana Sheriff-Hussaini",
          "author_url": "",
          "post_date": "2018-04-14T08:21:51.790000",
          "content": "<p>Hi Waleed do you have any thoughts on why I get that error?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 314608,
          "author_name": "Waleed",
          "author_url": "",
          "post_date": "2018-04-15T23:39:28.270000",
          "content": "<p>No, sorry, I don't know why you're getting this error. It's clearly complaining that you're passing 3 parameters when you should be passing two, but without seeing your code it's hard to guess. </p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 311352,
      "author_name": "Deargen",
      "author_url": "",
      "post_date": "2018-04-09T22:36:39.233000",
      "content": "<p>Thanks~!!! I got 0.376 LB score from original code.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 311332,
      "author_name": "Mehul Sampat",
      "author_url": "",
      "post_date": "2018-04-09T20:56:54.937000",
      "content": "<p>This is awesome Waleed! thanks for sharing it with the community! </p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 311269,
      "author_name": "William Green",
      "author_url": "",
      "post_date": "2018-04-09T18:13:27.643000",
      "content": "<p>Should we add the mask binarization threshold in model or in the config?  How many epochs do you your model? </p>",
      "votes": 0,
      "replies": [
        {
          "id": 311313,
          "author_name": "Waleed",
          "author_url": "",
          "post_date": "2018-04-09T20:11:30.797000",
          "content": "<p>Mask binarization code is already there. I just changed the threshold value in the <code>unmold_mask()</code> function. This may or may not help your results, so try without it first. </p>\n\n<p>I can't give an exact epoch count because every time I make a change in the code I usually start from the last weights because it's faster. I don't start from imagenet every time. I put my best guess-estimate in the training code. The rule of thumb is to watch the validation loss and when it stops improving you stop the training.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 311323,
          "author_name": "William Green",
          "author_url": "",
          "post_date": "2018-04-09T20:41:04.850000",
          "content": "<p>Thank you!  I appreciate your help and expertise. :)</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 311403,
          "author_name": "Akila Wajirasena",
          "author_url": "",
          "post_date": "2018-04-10T01:52:12.240000",
          "content": "<p>What was your validation loss for the 0.476 submission?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 311483,
          "author_name": "Waleed",
          "author_url": "",
          "post_date": "2018-04-10T06:15:28.993000",
          "content": "<p>Val loss varied between 0.85 and 0.75. Don't remember the exact value for the one I submitted, but I recall it wasn't the lowest. In other words, since the val dataset is so small, the correlation between loss value and LB score is not very reliable. </p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 311564,
          "author_name": "Akila Wajirasena",
          "author_url": "",
          "post_date": "2018-04-10T08:51:05.617000",
          "content": "<p>Thank you.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 311663,
          "author_name": "Rahul Kumar",
          "author_url": "",
          "post_date": "2018-04-10T12:59:44.633000",
          "content": "<p>@Waleed I got .394 after 83 epochs (validation loss  and training loss are is in range of 1.00-1.25 and 0.70-0.74).</p>\n\n<p>Here is what I did</p>\n\n<ol>\n<li>I used the cleaned up data posted on the githup</li>\n<li>epochs 0-20 heads with default learning rate given in your code\nepochs 20-40 all with default learning rate\nepochs 40-60 all layers with default learning rate/10\nepochs 60-83 all layers with default learning rate/100</li>\n<li>I have a single gpu and I am using IMAGES_PER_GPU = 8</li>\n<li>I used imagenet weight </li>\n<li>no pre or post processing</li>\n<li>no change in binarization threshold in unmold_mask</li>\n</ol>\n\n<p>I am training now from epochs 83 onwards with default learning rate/1000 currently its on 106th epochs with validation loss 1.05 and training loss 0.74 </p>\n\n<p>Clearly no improvement in training and validation loss. Do you have any suggestion how to reduce the validation and training loss.</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 311908,
          "author_name": "Waleed",
          "author_url": "",
          "post_date": "2018-04-10T22:04:14.150000",
          "content": "<p>Given the small dataset, I think long training, especially with small learning rate is more likely to cause overfitting than to help. I only used the base learning rate, not even / 10. Ignore the training loss and just keep an eye on the validation loss. When the validation loss stops going down stop the training.</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 312467,
      "author_name": "",
      "author_url": "",
      "post_date": "2018-04-11T19:49:11.800000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 316132,
      "author_name": "Andrzej",
      "author_url": "",
      "post_date": "2018-04-18T08:30:59.427000",
      "content": "<p>Thank you</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 312471,
      "author_name": "",
      "author_url": "",
      "post_date": "2018-04-11T20:04:40.280000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 312080,
      "author_name": "",
      "author_url": "",
      "post_date": "2018-04-11T06:48:56.357000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 311359,
      "author_name": "",
      "author_url": "",
      "post_date": "2018-04-09T23:09:41.387000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 311280,
      "author_name": "",
      "author_url": "",
      "post_date": "2018-04-09T18:32:11.150000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 311249,
      "author_name": "",
      "author_url": "",
      "post_date": "2018-04-09T17:28:12.137000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 311230,
      "author_name": "",
      "author_url": "",
      "post_date": "2018-04-09T16:43:29.753000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 311217,
      "author_name": "",
      "author_url": "",
      "post_date": "2018-04-09T16:18:16.027000",
      "content": "",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "311157": "I know it's a bit late in the game, but I just got on this competition recently when a friend told me that some people are using our implementation. I just pushed a complete pipeline for this competition that includes training, visualization, and submission. I hope you find it useful. \n\nThe code is in the Matterport [Mask-RCNN repo](https://github.com/matterport/Mask_RCNN) in the `samples/nucleus` directory. It consists of three parts:\n\n1. `nucleus.py` contains the Dataset class, configuration, RLE functions, and submission code. Instructions for using it [here](https://github.com/matterport/Mask_RCNN/tree/master/samples/nucleus). \n\n2. [inspect_nucleus_data.ipynb](https://github.com/matterport/Mask_RCNN/blob/master/samples/nucleus/inspect_nucleus_data.ipynb) Exploratory data analysis, and visualizations to show anchors and their sizes relative to objects.\n\n3. [inspect_nucleus_model.ipynb](https://github.com/matterport/Mask_RCNN/blob/master/samples/nucleus/inspect_nucleus_model.ipynb) Runs the model, computes AP on individual images, and visualizes differences between ground truth and detections.\n\nAnd here are my design choices. They're not ideal by any means. Just what I managed to find in a limited time. You should be able to fine-tune it and get better results.\n\n- The model is based on ResNet50 started with imagenet weights. I chose that, as opposed to ResNet101, because there is only one object type and the image variety is limited. I haven't gotten the chance to try 101 yet.\n- Most objects are small, some are 2x2 pixels. This requires special care. The first two layers of ResNet subsample twice (a conv with stride=2 and a maxpool), so we lose resolution quickly. One way to handle this is to change the network architecture to reduce early subsampling. I chose a different approach, which is to scale up the image x2 instead. It's simpler to implement and does the same thing, mostly.\n- Since images are spatially uniform and objects are small, training with random crops makes sense. I use random crops of 512x512 (effectively 256x256 in image domain due to the upscaling of the image). During inference, though, the network runs on the entire image.\n- No pre-processing or post-processing. If you have experience in that area you can probably improve the results significantly.\n- No external dataset. I used the cleaned up version of the competition dataset (link was posted in the forum somewhere). This is an area where you can probably get a quick win by using more datasets.\n- Many of the network settings can be controlled through the Config class, but not all. One setting I changed, **but is not in the code**, is editing the mask binarization threshold in `unmold_mask`. Default is 0.5, and I changed it to 0.4.\n- Simple image augmentations: LR flip, UD flip, 90-degree rotations, and Gaussian noise.\n\nLet me know if I missed something. And if you have ideas to improve on it, I'd love to hear them as well. ",
    "315746": "we used matter port and like I said it gave us in stage one 0.532 only the model. \n\nour config was - \n\n    IMAGE_MAX_DIM    =  1024\n    IMAGE_MIN_DIM    = 512\n    RPN_ANCHOR_SCALES   =    (8,16,32,64,128)\n    RPN_ANCHOR_RATIOS =[0.5,1,2]   \n    RPN_ANCHOR_STRIDE=1\n  \n    DETECTION_MAX_INSTANCES=500\n    RPN_TRAIN_ANCHORS_PER_IMAGE=250\n    TRAIN_ROIS_PER_IMAGE = 500\n    LEARNING_RATE = 0.01 \n    #USE_MINI_MASK = False       \n    \n    # Image mean (RGB)\n    MEAN_PIXEL = np.array([123.7, 116.8, 103.9])\n    DETECTION_MAX_INSTANCES=500\n    MAX_GT_INSTANCES=500\n\n\ngoing to 1024 from 256 got us better result. \n\nwhat was really meaningful is training with coco pertained model.  training only heads got us to 0.504 after 8 epochs\nafter that we trained more heads and 0.2 extra points was training 3+ for more epochs. using smaller lr\n\nI trained on lr 0.002 and tuning 0.0005. \n\ndetecting with 0.8 confidence and 0.3 mms gave best results. \n\nwe used of course many basic augmentation like rotate and zoom and noise. \nwe excluded masks that where empty after the augmentation.",
    "311650": "I got with matterport 0.532",
    "311203": "Thanks for sharing! I used your code and actually the pretrain resnet 101 coco model is also a good choice.",
    "315280": "Thanks for sharing!  I used resnet 50 coco model  and swish activation instead of relu activation .  Trained head network 20 epoches(val loss 0.89), then got 0.477 score.  Again trained the all layers 20 epoches(val loss 0.75),then got 0.48 score.  Matterport Mask-RCNN is very good! ",
    "315194": "Many thanks to Waleed for sharing the solution with us. It's been a steep and painful learning curve for me but it's definitely worth it.\n\nI have encountered a number of difficulties on this journey. Since it's approaching the end of this competition, I would like to start the discussion here and hopefully help myself and others to gain further understanding of the implementation. \n\nFor myself, I found the main problem seems to come from black and white images. my models are suffereing from main two main problems: 1) miss cells, and 2) not masking enough area. \n\nI have tried tweaking the parameters in the configurations, for example RPN_TRAIN_ANCHORS_PER_IMAGE, TRAIN_ROIS_PER_IMAGE, MAX_GT_INSTANCES, DETECTION_MAX_INSTANCES, etc. but none of them seems to bring any significant improvement\n\nI have also tried various learning rates, no effect either. I can always achieve an overall all loss between 0.7 ~ 0.8, and an rcnn mask loss of 0.2~0.25. This seems to be inline with what others are getting, but my 1st stage public LB is only 0.36.\n\nTherefore I am asking if anyone has experienced the same issues and if and how you've got around it. \n\nMany thanks in advance!",
    "311220": "Thanks ! I'm learning your code deep right now!",
    "885572": "Hii, I am new to these techniques I went through the files provided, but I couldn't really figure out how to proceed if you have your own dataset and also without weights file? A detailed implementation of this would be much appreciated. thanks.",
    "808201": "@waleedka hi, thanks for sharing. Query: what else special care do you think should be considered while detecting or localizing such small targets on the large spatial?\n",
    "314425": "Is it usual to get `*** No instances to display *** ` in detect process? Does that just mean no region detected? ",
    "313909": "nucleus.py is not utilizing my GPU\n\nI have a K80 GPU but when running python3 nucleus.py train --dataset=../../../dsbowl/ --subset=train --weights=imagenet, training each epoch is extremely slow, this is my config:\n```\nConfigurations:\nBACKBONE                       resnet50\nBACKBONE_STRIDES               [4, 8, 16, 32, 64]\nBATCH_SIZE                     20\nBBOX_STD_DEV                   [0.1 0.1 0.2 0.2]\nDETECTION_MAX_INSTANCES        400\nDETECTION_MIN_CONFIDENCE       0\nDETECTION_NMS_THRESHOLD        0.3\nGPU_COUNT                      2\nGRADIENT_CLIP_NORM             5.0\nIMAGES_PER_GPU                 10\nIMAGE_MAX_DIM                  512\nIMAGE_META_SIZE                14\nIMAGE_MIN_DIM                  512\nIMAGE_MIN_SCALE                2.0\nIMAGE_RESIZE_MODE              crop\nIMAGE_SHAPE                    [512 512   3]\nLEARNING_MOMENTUM              0.9\nLEARNING_RATE                  0.001\nMASK_POOL_SIZE                 14\nMASK_SHAPE                     [28, 28]\nMAX_GT_INSTANCES               200\nMEAN_PIXEL                     [43.53 39.56 48.22]\nMINI_MASK_SHAPE                (56, 56)\nNAME                           nucleus\nNUM_CLASSES                    2\nPOOL_SIZE                      7\nPOST_NMS_ROIS_INFERENCE        2000\nPOST_NMS_ROIS_TRAINING         1000\nROI_POSITIVE_RATIO             0.33\nRPN_ANCHOR_RATIOS              [0.5, 1, 2]\nRPN_ANCHOR_SCALES              (8, 16, 32, 64, 128)\nRPN_ANCHOR_STRIDE              1\nRPN_BBOX_STD_DEV               [0.1 0.1 0.2 0.2]\nRPN_NMS_THRESHOLD              0.9\nRPN_TRAIN_ANCHORS_PER_IMAGE    64\nSTEPS_PER_EPOCH                63\nTRAIN_BN                       False\nTRAIN_ROIS_PER_IMAGE           128\nUSE_MINI_MASK                  True\nUSE_RPN_ROIS                   True\nVALIDATION_STEPS               2\nWEIGHT_DECAY                   0.0001\n```",
    "313869": "@Waleed, did you try and retrain using stage1_train + stage1_test ? I am trying this; Interesting after 10 epochs my val_loss is much higher (in the range of 2.5 whereas with only stage1_train data it was in 0.7 range\n",
    "312687": "hi,could show your config ? caus for training_data my loss is 0.66,val_loss 0.7,but detection performence is really bad , AND only get LB0.224",
    "312649": "can you share little more detail of your training set?",
    "312588": "hi,  I got the error as bellow  and  i have no idea why this will happen\n\nRunning on /content/.kaggle/competitions/data-science-bowl-2018/\nTraceback (most recent call last):\n  File \"nucleus.py\", line 486, in \n    detect(model, args.dataset, args.subset)\n  File \"nucleus.py\", line 383, in detect\n    rle = mask_to_rle(source_id, r[\"masks\"], r[\"scores\"])\n  File \"nucleus.py\", line 342, in mask_to_rle\n    mask = np.max(mask * np.reshape(order, [1, 1, -1]), -1)\nValueError: operands could not be broadcast together with shapes (0,28,28) (1,1,0)",
    "312473": "@Waleed Hi, is the implementation correct?  I see the validation loss fluctuating a lot but not decreasing.\n",
    "312308": "Thank you so much for sharing! @Waleed, I am sorry that I got a bug during implementation,\n ipykernel_launcher.py: error: the following arguments are required: --weights\nAn exception has occurred, use %tb to see the full traceback.\nHow can I solve this problem?",
    "312197": "Thank you for the code! However I get the following error when trying to train (using Spyder IDE, on Windows).  \n\nAny suggestions welcome.\n\nTraceback (most recent call last):\n\n  File \"",
    "312186": "Great job !",
    "312131": "I have a question. How to give a weighing for every image?",
    "312042": "can I use the GPU when running nucleus.py? The CPU version is so slow ......",
    "311595": "Thank you @Waleed for sharing this, also for the original re-implementation of Mask R-CNN, it was very useful. I have found a small bug/issue with this pipeline - you use .split(\"/images/\") in your code (nucleus.py, 229L) in order to derive path to masks, but it might be faulty in case someone would have name \"images\" in their path e.g. in our case /Kaggle/spotNuclei/images/raw_fixed/stage1_train/img1/images/img1.png. I am not a big Python expert here, but this line `mask_dir = \"/\" + os.path.join(*(os.path.join(info[\"path\"]).split(\"/\")[:-2])) + \"/masks/\"` looks more robust (probable there is more elegant solution). Can do a PR if this sounds meaningful. ",
    "311435": "Hi, can you share  your training schedule , As I only get 0.356 with the default traing schedule,the only thing I modified is when a I train \"all\" I set the batch size to 4 due to OOM. by the way after I finish 40 epoch training  I get a total loss around 0.75",
    "311404": "Thanks for sharing.\nI when to train the model with two GPUs.I add to the NucleusConfig class \"GPU_COUNT = 2\".\nI get the following error when I run python3 nucleus.py train --dataset=/path/to/dataset --subset=train --weights=imagenet in multi-GPU:\nTraceback (most recent call last):\n  File \"/home/PycharmProjects/Mask_RCNN/mrcnn/model.py\", line 2039, in build\n    model = ParallelModel(model, config.GPU_COUNT)\n  File \"/home/PycharmProjects/Mask_RCNN/mrcnn/parallel_model.py\", line 37, in __init__\n    merged_outputs = self.make_parallel()\n  File \"/home/PycharmProjects/Mask_RCNN/mrcnn/parallel_model.py\", line 81, in make_parallel\n    outputs = self.inner_model(inputs)\n  File \"/home/panotech/PycharmProjects/Mask_RCNN/mrcnn/model.py\", line 1913, in ",
    "311367": "Hi @Waleed, I get the following error when I run in class NucleusConfig(Config):\n\n&gt; TypeError                                 Traceback (most recent call last)\n",
    "311352": "Thanks~!!! I got 0.376 LB score from original code.",
    "311332": "This is awesome Waleed! thanks for sharing it with the community! ",
    "311269": "Should we add the mask binarization threshold in model or in the config?  How many epochs do you your model? ",
    "312467": "",
    "316132": "Thank you",
    "312471": "Thanks for sharing!",
    "312080": "Thank you for the code !",
    "311359": "@Waleed, thanks so much for sharing.",
    "311280": "Thanks a lot!",
    "311249": "Thank you for your code!",
    "311230": "Awesome! Thank you. ",
    "311217": "Awesome! Thank you"
  }
}