{
  "id": 164553,
  "title": "Faster-RCCN: which pre-processing better not to use",
  "url": "/competitions/global-wheat-detection/discussion/164553",
  "author_name": "",
  "post_date": "2020-07-06T18:03:29.050179800Z",
  "votes": 2,
  "comment_count": 5,
  "views": 0,
  "content": "<p>Fellow Farm-Girls and Farm-Boys,\nI checked out Faster-RCCN source code &amp; implementation and found that </p>\n\n<ul>\n<li><p>in the official<a href=\"https://pytorch.org/docs/stable/_modules/torchvision/models/detection/faster_rcnn.html#fasterrcnn_resnet50_fpn\"> pytroch implementation</a>, the minimum image size for FasterRCNN is 800 and the maximum is 1333. So resizing to below 800 (most notebooks use 512 for training) before feeding it in the network is not only unnecessary computational cost, but also decreasing the information contained in the pictures.</p></li>\n<li><p>images should not be standardized during augmentation-process or in your Dataset-class. Subtracting the mean and dividing by std. deviation is automatically done in the <a href=\"https://github.com/pytorch/vision/blob/39021408587eb252ebb842a54195d840d6d76095/torchvision/models/detection/transform.py\">GeneralizedRCNNTransform</a>-Class which is used by the model itself!</p></li>\n</ul>\n\n<p>Did i overlook something? Do you have anything to add?</p>\n\n<p>Some more details and a full augmentation pipeline are explained in my <a href=\"https://www.kaggle.com/chrisden/end2end-object-detection-with-fasterrcnn\">notebook</a>.\nAs this iy my first-ever Pytroch notebook, I am always happy to hear tipps.</p>\n\n<p>Thanks for reading, I hoped it helped!</p>",
  "messages": [
    {
      "id": "917715",
      "postDate": "07/06/2020 18:03:29",
      "content": "<p>Fellow Farm-Girls and Farm-Boys,\nI checked out Faster-RCCN source code &amp; implementation and found that </p>\n\n<ul>\n<li><p>in the official<a href=\"https://pytorch.org/docs/stable/_modules/torchvision/models/detection/faster_rcnn.html#fasterrcnn_resnet50_fpn\"> pytroch implementation</a>, the minimum image size for FasterRCNN is 800 and the maximum is 1333. So resizing to below 800 (most notebooks use 512 for training) before feeding it in the network is not only unnecessary computational cost, but also decreasing the information contained in the pictures.</p></li>\n<li><p>images should not be standardized during augmentation-process or in your Dataset-class. Subtracting the mean and dividing by std. deviation is automatically done in the <a href=\"https://github.com/pytorch/vision/blob/39021408587eb252ebb842a54195d840d6d76095/torchvision/models/detection/transform.py\">GeneralizedRCNNTransform</a>-Class which is used by the model itself!</p></li>\n</ul>\n\n<p>Did i overlook something? Do you have anything to add?</p>\n\n<p>Some more details and a full augmentation pipeline are explained in my <a href=\"https://www.kaggle.com/chrisden/end2end-object-detection-with-fasterrcnn\">notebook</a>.\nAs this iy my first-ever Pytroch notebook, I am always happy to hear tipps.</p>\n\n<p>Thanks for reading, I hoped it helped!</p>",
      "rawMarkdown": "Fellow Farm-Girls and Farm-Boys,\nI checked out Faster-RCCN source code &amp; implementation and found that \n\n- in the official[ pytroch implementation](https://pytorch.org/docs/stable/_modules/torchvision/models/detection/faster_rcnn.html#fasterrcnn_resnet50_fpn), the minimum image size for FasterRCNN is 800 and the maximum is 1333. So resizing to below 800 (most notebooks use 512 for training) before feeding it in the network is not only unnecessary computational cost, but also decreasing the information contained in the pictures.\n\n- images should not be standardized during augmentation-process or in your Dataset-class. Subtracting the mean and dividing by std. deviation is automatically done in the [GeneralizedRCNNTransform](https://github.com/pytorch/vision/blob/39021408587eb252ebb842a54195d840d6d76095/torchvision/models/detection/transform.py)-Class which is used by the model itself!\n\nDid i overlook something? Do you have anything to add?\n\nSome more details and a full augmentation pipeline are explained in my [notebook](https://www.kaggle.com/chrisden/end2end-object-detection-with-fasterrcnn).\nAs this iy my first-ever Pytroch notebook, I am always happy to hear tipps.\n\nThanks for reading, I hoped it helped!",
      "votes": null
    },
    {
      "id": "917718",
      "postDate": "07/06/2020 18:05:29",
      "content": "<p>Dear <a href=\"/pestipeti\">@pestipeti</a>, <a href=\"/tanulsingh077\">@tanulsingh077</a> , did you know?  Was new to me until today.</p>",
      "rawMarkdown": "Dear @pestipeti, @tanulsingh077 , did you know?  Was new to me until today.",
      "votes": null
    },
    {
      "id": "917742",
      "postDate": "07/06/2020 18:19:11",
      "content": "<p>Yes, the default sizes are 800/1333. You can change this by adding <code>min_size</code> and <code>max_size</code> argument to the <code>torchvision.models.detection.fasterrcnn_resnet50_fpn</code> method. You can crop/resize to 512 or 1024 (using Albumentations or your own script), just make sure you set the params above to the right value.</p>\n\n<p>You can also set the <code>image_mean</code> and <code>image_std</code>. You are right, the default implementation will normalize the inputs.</p>",
      "rawMarkdown": "Yes, the default sizes are 800/1333. You can change this by adding `min_size` and `max_size` argument to the `torchvision.models.detection.fasterrcnn_resnet50_fpn` method. You can crop/resize to 512 or 1024 (using Albumentations or your own script), just make sure you set the params above to the right value.\n\nYou can also set the `image_mean` and `image_std`. You are right, the default implementation will normalize the inputs.",
      "votes": null
    },
    {
      "id": "917744",
      "postDate": "07/06/2020 18:19:44",
      "content": "<p>Yes, you are correct with this. Resizing and normalization is handled by the \"GeneralizedRCNNTransform\". I just do something like this as the parameters are passed to the GeneralizedRCNNTransform:\n<code>\nmodel = FasterRCNN(min_size=1024, max_size=1024)\n</code></p>",
      "rawMarkdown": "Yes, you are correct with this. Resizing and normalization is handled by the \"GeneralizedRCNNTransform\". I just do something like this as the parameters are passed to the GeneralizedRCNNTransform:\n```\nmodel = FasterRCNN(min_size=1024, max_size=1024)\n```",
      "votes": null
    },
    {
      "id": "917753",
      "postDate": "07/06/2020 18:22:05",
      "content": "<p>Just one thing to add to what Peter said: I would recommend leaving the <code>image_mean</code> and <code>image_std</code> as is as this was one thing that screwed me up in the past. I figured changing these to the mean and std of our dataset would be better but I actually got worse performance because the pretrained resnet50 model was trained using the default parameters.</p>",
      "rawMarkdown": "Just one thing to add to what Peter said: I would recommend leaving the `image_mean` and `image_std` as is as this was one thing that screwed me up in the past. I figured changing these to the mean and std of our dataset would be better but I actually got worse performance because the pretrained resnet50 model was trained using the default parameters.",
      "votes": null
    },
    {
      "id": "917811",
      "postDate": "07/06/2020 18:54:40",
      "content": "<p>Thanks for the update to both of you!</p>",
      "rawMarkdown": "Thanks for the update to both of you!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 917718,
      "author_name": "ChristianDenich",
      "author_url": "",
      "post_date": "07/06/2020 18:05:29",
      "content": "<p>Dear <a href=\"/pestipeti\">@pestipeti</a>, <a href=\"/tanulsingh077\">@tanulsingh077</a> , did you know?  Was new to me until today.</p>",
      "votes": null,
      "replies": [
        {
          "id": 917742,
          "author_name": "pestipeti",
          "author_url": "",
          "post_date": "07/06/2020 18:19:11",
          "content": "<p>Yes, the default sizes are 800/1333. You can change this by adding <code>min_size</code> and <code>max_size</code> argument to the <code>torchvision.models.detection.fasterrcnn_resnet50_fpn</code> method. You can crop/resize to 512 or 1024 (using Albumentations or your own script), just make sure you set the params above to the right value.</p>\n\n<p>You can also set the <code>image_mean</code> and <code>image_std</code>. You are right, the default implementation will normalize the inputs.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 917753,
          "author_name": "matthewmasters",
          "author_url": "",
          "post_date": "07/06/2020 18:22:05",
          "content": "<p>Just one thing to add to what Peter said: I would recommend leaving the <code>image_mean</code> and <code>image_std</code> as is as this was one thing that screwed me up in the past. I figured changing these to the mean and std of our dataset would be better but I actually got worse performance because the pretrained resnet50 model was trained using the default parameters.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 917811,
          "author_name": "ChristianDenich",
          "author_url": "",
          "post_date": "07/06/2020 18:54:40",
          "content": "<p>Thanks for the update to both of you!</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 917744,
      "author_name": "matthewmasters",
      "author_url": "",
      "post_date": "07/06/2020 18:19:44",
      "content": "<p>Yes, you are correct with this. Resizing and normalization is handled by the \"GeneralizedRCNNTransform\". I just do something like this as the parameters are passed to the GeneralizedRCNNTransform:\n<code>\nmodel = FasterRCNN(min_size=1024, max_size=1024)\n</code></p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "917715": "Fellow Farm-Girls and Farm-Boys,\nI checked out Faster-RCCN source code &amp; implementation and found that \n\n- in the official[ pytroch implementation](https://pytorch.org/docs/stable/_modules/torchvision/models/detection/faster_rcnn.html#fasterrcnn_resnet50_fpn), the minimum image size for FasterRCNN is 800 and the maximum is 1333. So resizing to below 800 (most notebooks use 512 for training) before feeding it in the network is not only unnecessary computational cost, but also decreasing the information contained in the pictures.\n\n- images should not be standardized during augmentation-process or in your Dataset-class. Subtracting the mean and dividing by std. deviation is automatically done in the [GeneralizedRCNNTransform](https://github.com/pytorch/vision/blob/39021408587eb252ebb842a54195d840d6d76095/torchvision/models/detection/transform.py)-Class which is used by the model itself!\n\nDid i overlook something? Do you have anything to add?\n\nSome more details and a full augmentation pipeline are explained in my [notebook](https://www.kaggle.com/chrisden/end2end-object-detection-with-fasterrcnn).\nAs this iy my first-ever Pytroch notebook, I am always happy to hear tipps.\n\nThanks for reading, I hoped it helped!",
    "917718": "Dear @pestipeti, @tanulsingh077 , did you know?  Was new to me until today.",
    "917742": "Yes, the default sizes are 800/1333. You can change this by adding `min_size` and `max_size` argument to the `torchvision.models.detection.fasterrcnn_resnet50_fpn` method. You can crop/resize to 512 or 1024 (using Albumentations or your own script), just make sure you set the params above to the right value.\n\nYou can also set the `image_mean` and `image_std`. You are right, the default implementation will normalize the inputs.",
    "917744": "Yes, you are correct with this. Resizing and normalization is handled by the \"GeneralizedRCNNTransform\". I just do something like this as the parameters are passed to the GeneralizedRCNNTransform:\n```\nmodel = FasterRCNN(min_size=1024, max_size=1024)\n```",
    "917753": "Just one thing to add to what Peter said: I would recommend leaving the `image_mean` and `image_std` as is as this was one thing that screwed me up in the past. I figured changing these to the mean and std of our dataset would be better but I actually got worse performance because the pretrained resnet50 model was trained using the default parameters.",
    "917811": "Thanks for the update to both of you!"
  },
  "source": "meta"
}