{
  "id": 169600,
  "title": "Understanding WBF",
  "url": "/competitions/global-wheat-detection/discussion/169600",
  "author_name": "",
  "post_date": "2020-07-24T12:06:33.005422200Z",
  "votes": null,
  "comment_count": 3,
  "views": 0,
  "content": "<p><code>boxes = [(prediction[image_index]['boxes']/(image_size-1)).tolist()  for prediction in predictions]</code></p>\n\n<p>1) Why are we dividing by image_size -1  and then multiplying it back.</p>\n\n<p>2) Bbox will be on Full res image 1024 ,but in the inference we use 512 ,where does bbox values are rescaled to match with 1024 resolution image. I presume since we make prediction over 512 resize image so bbox will also be accordingly.</p>",
  "messages": [
    {
      "id": "943503",
      "postDate": "07/24/2020 12:06:33",
      "content": "<p><code>boxes = [(prediction[image_index]['boxes']/(image_size-1)).tolist()  for prediction in predictions]</code></p>\n\n<p>1) Why are we dividing by image_size -1  and then multiplying it back.</p>\n\n<p>2) Bbox will be on Full res image 1024 ,but in the inference we use 512 ,where does bbox values are rescaled to match with 1024 resolution image. I presume since we make prediction over 512 resize image so bbox will also be accordingly.</p>",
      "rawMarkdown": "` boxes = [(prediction[image_index]['boxes']/(image_size-1)).tolist()  for prediction in predictions]`\n\n1) Why are we dividing by image_size -1  and then multiplying it back.\n\n2) Bbox will be on Full res image 1024 ,but in the inference we use 512 ,where does bbox values are rescaled to match with 1024 resolution image. I presume since we make prediction over 512 resize image so bbox will also be accordingly.",
      "votes": null
    },
    {
      "id": "943553",
      "postDate": "07/24/2020 12:34:25",
      "content": "<ol>\n<li><p>Assuming image_size is 512. Then image index expands from 0 to 511. Hence you divide by 511(image_size-1) to normalize the bounding box(0 to 1 range).</p></li>\n<li><p>by multiplying back, you can re-scale the bounding boxes. If you are referencing Alex Shonenkov's brilliant notebook, there you will see:\na) inside the run_wbf function, he re-scales the boxes to 512 by multiplying with (image_size-1).\nb) finally he multiplies again by 2 to re-scale the boxes to 1024. </p></li>\n</ol>",
      "rawMarkdown": "1. Assuming image_size is 512. Then image index expands from 0 to 511. Hence you divide by 511(image_size-1) to normalize the bounding box(0 to 1 range).\n\n2. by multiplying back, you can re-scale the bounding boxes. If you are referencing Alex Shonenkov's brilliant notebook, there you will see:\na) inside the run_wbf function, he re-scales the boxes to 512 by multiplying with (image_size-1).\nb) finally he multiplies again by 2 to re-scale the boxes to 1024.",
      "votes": null
    },
    {
      "id": "944370",
      "postDate": "07/25/2020 04:09:22",
      "content": "<p>Thanks will checkout.One more thing if u can help out  ,in alex kernel i dont see below code is in use basically param groups</p>\n\n<p><code>\nparam_optimizer = list(self.model.named_parameters())\n        no_decay = ['bias', 'LayerNorm.bias', 'LayerNorm.weight']\n        optimizer_grouped_parameters = [\n            {'params': [p for n, p in param_optimizer if not any(nd in n for nd in no_decay)], 'weight_decay': 0.001},\n            {'params': [p for n, p in param_optimizer if any(nd in n for nd in no_decay)], 'weight_decay': 0.0}\n        ]\n</code></p>",
      "rawMarkdown": "Thanks will checkout.One more thing if u can help out  ,in alex kernel i dont see below code is in use basically param groups\n\n```\nparam_optimizer = list(self.model.named_parameters())\n        no_decay = ['bias', 'LayerNorm.bias', 'LayerNorm.weight']\n        optimizer_grouped_parameters = [\n            {'params': [p for n, p in param_optimizer if not any(nd in n for nd in no_decay)], 'weight_decay': 0.001},\n            {'params': [p for n, p in param_optimizer if any(nd in n for nd in no_decay)], 'weight_decay': 0.0}\n        ]\n```",
      "votes": null
    },
    {
      "id": "944464",
      "postDate": "07/25/2020 06:13:26",
      "content": "<p>yes, he does not use 'optimizer-grouped-parameters' in the adamW. Probably leftover code from other notebooks of him.</p>",
      "rawMarkdown": "yes, he does not use 'optimizer-grouped-parameters' in the adamW. Probably leftover code from other notebooks of him.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 943553,
      "author_name": "mohammadzunaed",
      "author_url": "",
      "post_date": "07/24/2020 12:34:25",
      "content": "<ol>\n<li><p>Assuming image_size is 512. Then image index expands from 0 to 511. Hence you divide by 511(image_size-1) to normalize the bounding box(0 to 1 range).</p></li>\n<li><p>by multiplying back, you can re-scale the bounding boxes. If you are referencing Alex Shonenkov's brilliant notebook, there you will see:\na) inside the run_wbf function, he re-scales the boxes to 512 by multiplying with (image_size-1).\nb) finally he multiplies again by 2 to re-scale the boxes to 1024. </p></li>\n</ol>",
      "votes": null,
      "replies": [
        {
          "id": 944370,
          "author_name": "jaideepvalani",
          "author_url": "",
          "post_date": "07/25/2020 04:09:22",
          "content": "<p>Thanks will checkout.One more thing if u can help out  ,in alex kernel i dont see below code is in use basically param groups</p>\n\n<p><code>\nparam_optimizer = list(self.model.named_parameters())\n        no_decay = ['bias', 'LayerNorm.bias', 'LayerNorm.weight']\n        optimizer_grouped_parameters = [\n            {'params': [p for n, p in param_optimizer if not any(nd in n for nd in no_decay)], 'weight_decay': 0.001},\n            {'params': [p for n, p in param_optimizer if any(nd in n for nd in no_decay)], 'weight_decay': 0.0}\n        ]\n</code></p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 944464,
          "author_name": "mohammadzunaed",
          "author_url": "",
          "post_date": "07/25/2020 06:13:26",
          "content": "<p>yes, he does not use 'optimizer-grouped-parameters' in the adamW. Probably leftover code from other notebooks of him.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "943503": "` boxes = [(prediction[image_index]['boxes']/(image_size-1)).tolist()  for prediction in predictions]`\n\n1) Why are we dividing by image_size -1  and then multiplying it back.\n\n2) Bbox will be on Full res image 1024 ,but in the inference we use 512 ,where does bbox values are rescaled to match with 1024 resolution image. I presume since we make prediction over 512 resize image so bbox will also be accordingly.",
    "943553": "1. Assuming image_size is 512. Then image index expands from 0 to 511. Hence you divide by 511(image_size-1) to normalize the bounding box(0 to 1 range).\n\n2. by multiplying back, you can re-scale the bounding boxes. If you are referencing Alex Shonenkov's brilliant notebook, there you will see:\na) inside the run_wbf function, he re-scales the boxes to 512 by multiplying with (image_size-1).\nb) finally he multiplies again by 2 to re-scale the boxes to 1024.",
    "944370": "Thanks will checkout.One more thing if u can help out  ,in alex kernel i dont see below code is in use basically param groups\n\n```\nparam_optimizer = list(self.model.named_parameters())\n        no_decay = ['bias', 'LayerNorm.bias', 'LayerNorm.weight']\n        optimizer_grouped_parameters = [\n            {'params': [p for n, p in param_optimizer if not any(nd in n for nd in no_decay)], 'weight_decay': 0.001},\n            {'params': [p for n, p in param_optimizer if any(nd in n for nd in no_decay)], 'weight_decay': 0.0}\n        ]\n```",
    "944464": "yes, he does not use 'optimizer-grouped-parameters' in the adamW. Probably leftover code from other notebooks of him."
  },
  "source": "meta"
}