{
  "id": 53705,
  "title": "\"Miss-the-target\" issue and ways to improve Mask-RCNN?",
  "url": "/competitions/data-science-bowl-2018/discussion/53705",
  "author_name": "",
  "post_date": "2018-04-03T23:43:29.977896200Z",
  "votes": 10,
  "comment_count": 16,
  "views": 0,
  "content": "<p>Feels like mask-rcnn plays a big role here in this competition, which is also what our team is mainly based on (the Matterport implementation). </p>\n\n<p>We found mask-rcnn often can identify a good mask and separate crowded nuclei, which foreground-background segmentation methods cannot (like naive u-net). </p>\n\n<p>But we also found that with the increase in the number of nuclei in an image, mask-rcnn often just identify a fraction of them (quite perfectly), and completely missed out others, even they are similar to what has been identified in the same image. </p>\n\n<p>I've played around with following parameters and haven't see significant improvement:</p>\n\n<ol>\n<li><p>increase RPN_TRAIN_ANCHORS_PER_IMAGE. When we use 256 or 320, virtually no big difference. When increase it to be 1000, we identify a lot of small noise spot as positive, which make the results bad. </p></li>\n<li><p>Use smaller BACKBONE_STRIDES. Currently we are using [4,8,16,32,64,128], we also used [4,8,16,32,64] before, neither solved this \"miss the target\" issue. When I try to use smaller stride to generate more candidate anchors, such as [2, 4,8,16,32,64], for unknown reason, mask-rcnn generate 0 mask for many images, which I don't really understand. </p></li>\n<li><p>Different TRAIN_ROIS_PER_IMAGE. We didn't purposely adjust this, just uses 600 and 800 in different cases, but neither affect what we see. </p></li>\n</ol>\n\n<p>Has there anyone seen something similar as what we see? Have you figure out how to address it and what config parameter controls it? Is this an implementation specific behavior or general mask-rcnn issue? I just haven't studied mask-rcnn long enough to figure this out.</p>\n\n<p>I hope someone could shed some light on us. Thanks.</p>",
  "messages": [
    {
      "id": "308691",
      "postDate": "04/03/2018 23:43:29",
      "content": "<p>Feels like mask-rcnn plays a big role here in this competition, which is also what our team is mainly based on (the Matterport implementation). </p>\n\n<p>We found mask-rcnn often can identify a good mask and separate crowded nuclei, which foreground-background segmentation methods cannot (like naive u-net). </p>\n\n<p>But we also found that with the increase in the number of nuclei in an image, mask-rcnn often just identify a fraction of them (quite perfectly), and completely missed out others, even they are similar to what has been identified in the same image. </p>\n\n<p>I've played around with following parameters and haven't see significant improvement:</p>\n\n<ol>\n<li><p>increase RPN_TRAIN_ANCHORS_PER_IMAGE. When we use 256 or 320, virtually no big difference. When increase it to be 1000, we identify a lot of small noise spot as positive, which make the results bad. </p></li>\n<li><p>Use smaller BACKBONE_STRIDES. Currently we are using [4,8,16,32,64,128], we also used [4,8,16,32,64] before, neither solved this \"miss the target\" issue. When I try to use smaller stride to generate more candidate anchors, such as [2, 4,8,16,32,64], for unknown reason, mask-rcnn generate 0 mask for many images, which I don't really understand. </p></li>\n<li><p>Different TRAIN_ROIS_PER_IMAGE. We didn't purposely adjust this, just uses 600 and 800 in different cases, but neither affect what we see. </p></li>\n</ol>\n\n<p>Has there anyone seen something similar as what we see? Have you figure out how to address it and what config parameter controls it? Is this an implementation specific behavior or general mask-rcnn issue? I just haven't studied mask-rcnn long enough to figure this out.</p>\n\n<p>I hope someone could shed some light on us. Thanks.</p>",
      "rawMarkdown": "Feels like mask-rcnn plays a big role here in this competition, which is also what our team is mainly based on (the Matterport implementation). \n\nWe found mask-rcnn often can identify a good mask and separate crowded nuclei, which foreground-background segmentation methods cannot (like naive u-net). \n\nBut we also found that with the increase in the number of nuclei in an image, mask-rcnn often just identify a fraction of them (quite perfectly), and completely missed out others, even they are similar to what has been identified in the same image. \n\nI've played around with following parameters and haven't see significant improvement:\n\n1. increase RPN_TRAIN_ANCHORS_PER_IMAGE. When we use 256 or 320, virtually no big difference. When increase it to be 1000, we identify a lot of small noise spot as positive, which make the results bad. \n\n2. Use smaller BACKBONE_STRIDES. Currently we are using [4,8,16,32,64,128], we also used [4,8,16,32,64] before, neither solved this \"miss the target\" issue. When I try to use smaller stride to generate more candidate anchors, such as [2, 4,8,16,32,64], for unknown reason, mask-rcnn generate 0 mask for many images, which I don't really understand. \n\n3. Different TRAIN_ROIS_PER_IMAGE. We didn't purposely adjust this, just uses 600 and 800 in different cases, but neither affect what we see. \n\nHas there anyone seen something similar as what we see? Have you figure out how to address it and what config parameter controls it? Is this an implementation specific behavior or general mask-rcnn issue? I just haven't studied mask-rcnn long enough to figure this out.\n\nI hope someone could shed some light on us. Thanks.",
      "votes": null
    },
    {
      "id": "308797",
      "postDate": "04/04/2018 05:58:39",
      "content": "<p>Hey,</p>\n\n<p>I experienced the same problem and was also unable to find good parameters to solve this. My solution was to divide images with more than fifty found cells, into four or more sub-images and reprocessed them. Even with some minor merge artifacts, it works pretty well. </p>\n\n<p>Has someone a better parameter based solution ? </p>\n\n<p>With kind regards,\nChristian </p>",
      "rawMarkdown": "Hey,\n\nI experienced the same problem and was also unable to find good parameters to solve this. My solution was to divide images with more than fifty found cells, into four or more sub-images and reprocessed them. Even with some minor merge artifacts, it works pretty well. \n\nHas someone a better parameter based solution ? \n\nWith kind regards,\nChristian",
      "votes": null
    },
    {
      "id": "309797",
      "postDate": "04/06/2018 02:06:53",
      "content": "<p>This setting in config controls the max number of detections per image. It defaults to 100. Try to raise that limit since some images have more than 100 objects.</p>\n\n<pre><code>\n    # Max number of final detections\n    DETECTION_MAX_INSTANCES = 100\n</code></pre>",
      "rawMarkdown": "This setting in config controls the max number of detections per image. It defaults to 100. Try to raise that limit since some images have more than 100 objects.\n\n<pre><code>\n    # Max number of final detections\n    DETECTION_MAX_INSTANCES = 100\n</code></pre>",
      "votes": null
    },
    {
      "id": "309803",
      "postDate": "04/06/2018 02:15:19",
      "content": "<p>Thank you , I will try the merge method. </p>",
      "rawMarkdown": "Thank you , I will try the merge method.",
      "votes": null
    },
    {
      "id": "309805",
      "postDate": "04/06/2018 02:16:32",
      "content": "<p>Hi, Waleed, Thanks for the information, I've always set it to be 500. Hopefully that's enough. </p>",
      "rawMarkdown": "Hi, Waleed, Thanks for the information, I've always set it to be 500. Hopefully that's enough.",
      "votes": null
    },
    {
      "id": "309866",
      "postDate": "04/06/2018 05:11:16",
      "content": "<p>Hi,</p>\n\n<p>my default for DETECTION_MAX_INSTANCES  is 512, in my case that was not the solution :( </p>",
      "rawMarkdown": "Hi,\n\nmy default for DETECTION_MAX_INSTANCES  is 512, in my case that was not the solution :(",
      "votes": null
    },
    {
      "id": "310093",
      "postDate": "04/06/2018 15:34:55",
      "content": "<p>How is the result after you changed this?</p>",
      "rawMarkdown": "How is the result after you changed this?",
      "votes": null
    },
    {
      "id": "310148",
      "postDate": "04/06/2018 17:23:55",
      "content": "<p>Hi @ChristianMarzahl \nWhich iamges do you divide? the train images or test images? \nIf I didn't understand it wrong, you means when you do predicting on test images you divided the images which has more than fifty cells? </p>",
      "rawMarkdown": "Hi @ChristianMarzahl \nWhich iamges do you divide? the train images or test images? \nIf I didn't understand it wrong, you means when you do predicting on test images you divided the images which has more than fifty cells?",
      "votes": null
    },
    {
      "id": "310355",
      "postDate": "04/07/2018 08:55:17",
      "content": "<p>Hi,</p>\n\n<p>@Caibimiao correct I divide the test images, after a first iteration of the mask-rcnn. </p>",
      "rawMarkdown": "Hi,\n\n@Caibimiao correct I divide the test images, after a first iteration of the mask-rcnn.",
      "votes": null
    },
    {
      "id": "310360",
      "postDate": "04/07/2018 09:24:13",
      "content": "<p>As of today, the model supports predicting on images of variable size. Use config.IMAGE_RESIZE_MODE = \"pad64\" and it will run on the input image without resizing. If you also provide IMAGE_MIN_DIM, then before padding the image, it scales it (if needed) such that the small side is = IMAGE_MIN_DIM.</p>\n\n<p>This might be an easier solution than dividing the image. I hope it helps.</p>",
      "rawMarkdown": "As of today, the model supports predicting on images of variable size. Use config.IMAGE_RESIZE_MODE = \"pad64\" and it will run on the input image without resizing. If you also provide IMAGE_MIN_DIM, then before padding the image, it scales it (if needed) such that the small side is = IMAGE_MIN_DIM.\n\nThis might be an easier solution than dividing the image. I hope it helps.",
      "votes": null
    },
    {
      "id": "310362",
      "postDate": "04/07/2018 09:28:24",
      "content": "<p>If DETECTION_MAX_INSTANCES is already high enough then check one of these:\n- Is there a pattern for the missed objects? Are they all small or are they all large? That might point to an issue in image size or anchor sizes\n- Make sure DETECTION_MIN_CONFIDENCE is not eliminating too many predictions. Set it to 0 and see if that helps.\n- MAX_GT_INSTANCES controls the max number of instances per image used in training. If it's low, then an image with too many objects might be trained to consider the other objects as background.</p>",
      "rawMarkdown": "If DETECTION_MAX_INSTANCES is already high enough then check one of these:\n- Is there a pattern for the missed objects? Are they all small or are they all large? That might point to an issue in image size or anchor sizes\n- Make sure DETECTION_MIN_CONFIDENCE is not eliminating too many predictions. Set it to 0 and see if that helps.\n- MAX_GT_INSTANCES controls the max number of instances per image used in training. If it's low, then an image with too many objects might be trained to consider the other objects as background.",
      "votes": null
    },
    {
      "id": "310456",
      "postDate": "04/07/2018 15:42:42",
      "content": "<p>My score increased 0.01 after changing this :)</p>",
      "rawMarkdown": "My score increased 0.01 after changing this :)",
      "votes": null
    },
    {
      "id": "310546",
      "postDate": "04/07/2018 22:39:24",
      "content": "<p>@Waleed, thank you for keep updating and making the implementation better. </p>",
      "rawMarkdown": "Waleed, thank you for keep updating and making the implementation better.",
      "votes": null
    },
    {
      "id": "310998",
      "postDate": "04/09/2018 07:04:42",
      "content": "<p>@Waleed That's great, but for me seems after image resize using skimage instead of scipy, I got lower lb.</p>",
      "rawMarkdown": "Waleed That's great, but for me seems after image resize using skimage instead of scipy, I got lower lb.",
      "votes": null
    },
    {
      "id": "311016",
      "postDate": "04/09/2018 07:45:36",
      "content": "<p>Is it a big drop in your score? If it's small then maybe skimage uses a slightly different resizing implementation from Scipy. Anyway, I had to remove scipy because they deprecated their resizing function. Also, it had errors in some edge cases.</p>\n\n<p>And, did you try training using the skimage resizing function, or did you evaluate an already trained model (that was trained on the scipy version)?</p>",
      "rawMarkdown": "Is it a big drop in your score? If it's small then maybe skimage uses a slightly different resizing implementation from Scipy. Anyway, I had to remove scipy because they deprecated their resizing function. Also, it had errors in some edge cases.\n\nAnd, did you try training using the skimage resizing function, or did you evaluate an already trained model (that was trained on the scipy version)?",
      "votes": null
    },
    {
      "id": "311023",
      "postDate": "04/09/2018 08:08:55",
      "content": "<p>@Waleed I have tested it might lower lb 0.002 or 0.003. I have retrain using latest code still I will get better result if inference change to use scipy resize.  I got 0.488 using old code training and inference, 0.485 using new code training new code inference, 0.487 using new code training and inference using scipy resize. Looks like scipy always better for this dataset (train or test)</p>",
      "rawMarkdown": "Waleed I have tested it might lower lb 0.002 or 0.003. I have retrain using latest code still I will get better result if inference change to use scipy resize.  I got 0.488 using old code training and inference, 0.485 using new code training new code inference, 0.487 using new code training and inference using scipy resize. Looks like scipy always better for this dataset (train or test)",
      "votes": null
    },
    {
      "id": "311071",
      "postDate": "04/09/2018 10:06:39",
      "content": "<p>Your Mask-RCNN implementation problem is scale! Check out how it happens.</p>",
      "rawMarkdown": "Your Mask-RCNN implementation problem is scale! Check out how it happens.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 308797,
      "author_name": "christianm",
      "author_url": "",
      "post_date": "04/04/2018 05:58:39",
      "content": "<p>Hey,</p>\n\n<p>I experienced the same problem and was also unable to find good parameters to solve this. My solution was to divide images with more than fifty found cells, into four or more sub-images and reprocessed them. Even with some minor merge artifacts, it works pretty well. </p>\n\n<p>Has someone a better parameter based solution ? </p>\n\n<p>With kind regards,\nChristian </p>",
      "votes": null,
      "replies": [
        {
          "id": 309803,
          "author_name": "ruiforecasting",
          "author_url": "",
          "post_date": "04/06/2018 02:15:19",
          "content": "<p>Thank you , I will try the merge method. </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 310148,
          "author_name": "ermiao",
          "author_url": "",
          "post_date": "04/06/2018 17:23:55",
          "content": "<p>Hi @ChristianMarzahl \nWhich iamges do you divide? the train images or test images? \nIf I didn't understand it wrong, you means when you do predicting on test images you divided the images which has more than fifty cells? </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 310355,
          "author_name": "christianm",
          "author_url": "",
          "post_date": "04/07/2018 08:55:17",
          "content": "<p>Hi,</p>\n\n<p>@Caibimiao correct I divide the test images, after a first iteration of the mask-rcnn. </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 310360,
          "author_name": "waleedka",
          "author_url": "",
          "post_date": "04/07/2018 09:24:13",
          "content": "<p>As of today, the model supports predicting on images of variable size. Use config.IMAGE_RESIZE_MODE = \"pad64\" and it will run on the input image without resizing. If you also provide IMAGE_MIN_DIM, then before padding the image, it scales it (if needed) such that the small side is = IMAGE_MIN_DIM.</p>\n\n<p>This might be an easier solution than dividing the image. I hope it helps.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 310546,
          "author_name": "ruiforecasting",
          "author_url": "",
          "post_date": "04/07/2018 22:39:24",
          "content": "<p>@Waleed, thank you for keep updating and making the implementation better. </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 310998,
          "author_name": "goldenlock",
          "author_url": "",
          "post_date": "04/09/2018 07:04:42",
          "content": "<p>@Waleed That's great, but for me seems after image resize using skimage instead of scipy, I got lower lb.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 311016,
          "author_name": "waleedka",
          "author_url": "",
          "post_date": "04/09/2018 07:45:36",
          "content": "<p>Is it a big drop in your score? If it's small then maybe skimage uses a slightly different resizing implementation from Scipy. Anyway, I had to remove scipy because they deprecated their resizing function. Also, it had errors in some edge cases.</p>\n\n<p>And, did you try training using the skimage resizing function, or did you evaluate an already trained model (that was trained on the scipy version)?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 311023,
          "author_name": "goldenlock",
          "author_url": "",
          "post_date": "04/09/2018 08:08:55",
          "content": "<p>@Waleed I have tested it might lower lb 0.002 or 0.003. I have retrain using latest code still I will get better result if inference change to use scipy resize.  I got 0.488 using old code training and inference, 0.485 using new code training new code inference, 0.487 using new code training and inference using scipy resize. Looks like scipy always better for this dataset (train or test)</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 309797,
      "author_name": "waleedka",
      "author_url": "",
      "post_date": "04/06/2018 02:06:53",
      "content": "<p>This setting in config controls the max number of detections per image. It defaults to 100. Try to raise that limit since some images have more than 100 objects.</p>\n\n<pre><code>\n    # Max number of final detections\n    DETECTION_MAX_INSTANCES = 100\n</code></pre>",
      "votes": null,
      "replies": [
        {
          "id": 309805,
          "author_name": "ruiforecasting",
          "author_url": "",
          "post_date": "04/06/2018 02:16:32",
          "content": "<p>Hi, Waleed, Thanks for the information, I've always set it to be 500. Hopefully that's enough. </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 309866,
          "author_name": "christianm",
          "author_url": "",
          "post_date": "04/06/2018 05:11:16",
          "content": "<p>Hi,</p>\n\n<p>my default for DETECTION_MAX_INSTANCES  is 512, in my case that was not the solution :( </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 310093,
          "author_name": "zhujf553",
          "author_url": "",
          "post_date": "04/06/2018 15:34:55",
          "content": "<p>How is the result after you changed this?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 310362,
          "author_name": "waleedka",
          "author_url": "",
          "post_date": "04/07/2018 09:28:24",
          "content": "<p>If DETECTION_MAX_INSTANCES is already high enough then check one of these:\n- Is there a pattern for the missed objects? Are they all small or are they all large? That might point to an issue in image size or anchor sizes\n- Make sure DETECTION_MIN_CONFIDENCE is not eliminating too many predictions. Set it to 0 and see if that helps.\n- MAX_GT_INSTANCES controls the max number of instances per image used in training. If it's low, then an image with too many objects might be trained to consider the other objects as background.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 310456,
          "author_name": "zhujf553",
          "author_url": "",
          "post_date": "04/07/2018 15:42:42",
          "content": "<p>My score increased 0.01 after changing this :)</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 311071,
      "author_name": "donchuk",
      "author_url": "",
      "post_date": "04/09/2018 10:06:39",
      "content": "<p>Your Mask-RCNN implementation problem is scale! Check out how it happens.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "308691": "Feels like mask-rcnn plays a big role here in this competition, which is also what our team is mainly based on (the Matterport implementation). \n\nWe found mask-rcnn often can identify a good mask and separate crowded nuclei, which foreground-background segmentation methods cannot (like naive u-net). \n\nBut we also found that with the increase in the number of nuclei in an image, mask-rcnn often just identify a fraction of them (quite perfectly), and completely missed out others, even they are similar to what has been identified in the same image. \n\nI've played around with following parameters and haven't see significant improvement:\n\n1. increase RPN_TRAIN_ANCHORS_PER_IMAGE. When we use 256 or 320, virtually no big difference. When increase it to be 1000, we identify a lot of small noise spot as positive, which make the results bad. \n\n2. Use smaller BACKBONE_STRIDES. Currently we are using [4,8,16,32,64,128], we also used [4,8,16,32,64] before, neither solved this \"miss the target\" issue. When I try to use smaller stride to generate more candidate anchors, such as [2, 4,8,16,32,64], for unknown reason, mask-rcnn generate 0 mask for many images, which I don't really understand. \n\n3. Different TRAIN_ROIS_PER_IMAGE. We didn't purposely adjust this, just uses 600 and 800 in different cases, but neither affect what we see. \n\nHas there anyone seen something similar as what we see? Have you figure out how to address it and what config parameter controls it? Is this an implementation specific behavior or general mask-rcnn issue? I just haven't studied mask-rcnn long enough to figure this out.\n\nI hope someone could shed some light on us. Thanks.",
    "308797": "Hey,\n\nI experienced the same problem and was also unable to find good parameters to solve this. My solution was to divide images with more than fifty found cells, into four or more sub-images and reprocessed them. Even with some minor merge artifacts, it works pretty well. \n\nHas someone a better parameter based solution ? \n\nWith kind regards,\nChristian",
    "309797": "This setting in config controls the max number of detections per image. It defaults to 100. Try to raise that limit since some images have more than 100 objects.\n\n<pre><code>\n    # Max number of final detections\n    DETECTION_MAX_INSTANCES = 100\n</code></pre>",
    "309803": "Thank you , I will try the merge method.",
    "309805": "Hi, Waleed, Thanks for the information, I've always set it to be 500. Hopefully that's enough.",
    "309866": "Hi,\n\nmy default for DETECTION_MAX_INSTANCES  is 512, in my case that was not the solution :(",
    "310093": "How is the result after you changed this?",
    "310148": "Hi @ChristianMarzahl \nWhich iamges do you divide? the train images or test images? \nIf I didn't understand it wrong, you means when you do predicting on test images you divided the images which has more than fifty cells?",
    "310355": "Hi,\n\n@Caibimiao correct I divide the test images, after a first iteration of the mask-rcnn.",
    "310360": "As of today, the model supports predicting on images of variable size. Use config.IMAGE_RESIZE_MODE = \"pad64\" and it will run on the input image without resizing. If you also provide IMAGE_MIN_DIM, then before padding the image, it scales it (if needed) such that the small side is = IMAGE_MIN_DIM.\n\nThis might be an easier solution than dividing the image. I hope it helps.",
    "310362": "If DETECTION_MAX_INSTANCES is already high enough then check one of these:\n- Is there a pattern for the missed objects? Are they all small or are they all large? That might point to an issue in image size or anchor sizes\n- Make sure DETECTION_MIN_CONFIDENCE is not eliminating too many predictions. Set it to 0 and see if that helps.\n- MAX_GT_INSTANCES controls the max number of instances per image used in training. If it's low, then an image with too many objects might be trained to consider the other objects as background.",
    "310456": "My score increased 0.01 after changing this :)",
    "310546": "Waleed, thank you for keep updating and making the implementation better.",
    "310998": "Waleed That's great, but for me seems after image resize using skimage instead of scipy, I got lower lb.",
    "311016": "Is it a big drop in your score? If it's small then maybe skimage uses a slightly different resizing implementation from Scipy. Anyway, I had to remove scipy because they deprecated their resizing function. Also, it had errors in some edge cases.\n\nAnd, did you try training using the skimage resizing function, or did you evaluate an already trained model (that was trained on the scipy version)?",
    "311023": "Waleed I have tested it might lower lb 0.002 or 0.003. I have retrain using latest code still I will get better result if inference change to use scipy resize.  I got 0.488 using old code training and inference, 0.485 using new code training new code inference, 0.487 using new code training and inference using scipy resize. Looks like scipy always better for this dataset (train or test)",
    "311071": "Your Mask-RCNN implementation problem is scale! Check out how it happens."
  },
  "source": "meta"
}