{
  "id": 244832,
  "title": "Is there any x_min etc that's negative?",
  "url": "/competitions/siim-covid19-detection/discussion/244832",
  "author_name": "",
  "post_date": "2021-06-08T13:58:19.673969300Z",
  "votes": null,
  "comment_count": 1,
  "views": 0,
  "content": "<p>I ran into this notebook:</p>\n<p><a href=\"https://www.kaggle.com/ammarnassanalhajali/siim-covid-19-detectron2-training/notebook\" target=\"_blank\">https://www.kaggle.com/ammarnassanalhajali/siim-covid-19-detectron2-training/notebook</a></p>\n<p>And one of the files it uses, \"train_image_df\", has negative x_min values in it.</p>\n<p>Is there any bbox that has negative x_min value in the data?</p>",
  "messages": [
    {
      "id": "1341207",
      "postDate": "06/08/2021 13:58:19",
      "content": "<p>I ran into this notebook:</p>\n<p><a href=\"https://www.kaggle.com/ammarnassanalhajali/siim-covid-19-detectron2-training/notebook\" target=\"_blank\">https://www.kaggle.com/ammarnassanalhajali/siim-covid-19-detectron2-training/notebook</a></p>\n<p>And one of the files it uses, \"train_image_df\", has negative x_min values in it.</p>\n<p>Is there any bbox that has negative x_min value in the data?</p>",
      "rawMarkdown": "I ran into this notebook:\n\nhttps://www.kaggle.com/ammarnassanalhajali/siim-covid-19-detectron2-training/notebook\n\nAnd one of the files it uses, \"train_image_df\", has negative x_min values in it.\n\nIs there any bbox that has negative x_min value in the data?",
      "votes": null
    },
    {
      "id": "1341283",
      "postDate": "06/08/2021 14:55:33",
      "content": "<p>you can change</p>\n<p>h_ratio = resized_height / height<br>\nw_ratio = resized_width / width</p>\n<p>bbox_resized = [<br>\n    float(row[\"x_min\"]) * w_ratio,<br>\n    float(row[\"y_min\"]) * h_ratio,<br>\n    float(row[\"x_max\"]) * w_ratio,<br>\n    float(row[\"y_max\"]) * h_ratio,<br>\n]</p>\n<p>to</p>\n<p>bbox_resized = np.array([<br>\n    float(row[\"x_min\"]) * w_ratio,<br>\n    float(row[\"y_min\"]) * h_ratio,<br>\n    float(row[\"x_max\"]) * w_ratio,<br>\n    float(row[\"y_max\"]) * h_ratio,<br>\n])</p>\n<p>bbox_resized[[0,2]] = bbox_resized[[0,2]].clip(0, resized_width)<br>\nbbox_resized[[1,3]] = bbox_resized[[1,3]].clip(0, resized_height)<br>\nbbox_resized = list(bbox_resized)</p>",
      "rawMarkdown": "you can change\n\nh_ratio = resized_height / height\nw_ratio = resized_width / width\n\nbbox_resized = [\n    float(row[\"x_min\"]) * w_ratio,\n    float(row[\"y_min\"]) * h_ratio,\n    float(row[\"x_max\"]) * w_ratio,\n    float(row[\"y_max\"]) * h_ratio,\n]\n\nto\n\nbbox_resized = np.array([\n    float(row[\"x_min\"]) * w_ratio,\n    float(row[\"y_min\"]) * h_ratio,\n    float(row[\"x_max\"]) * w_ratio,\n    float(row[\"y_max\"]) * h_ratio,\n])\n\nbbox_resized[[0,2]] = bbox_resized[[0,2]].clip(0, resized_width)\nbbox_resized[[1,3]] = bbox_resized[[1,3]].clip(0, resized_height)\nbbox_resized = list(bbox_resized)",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1341283,
      "author_name": "nguyenbadung",
      "author_url": "",
      "post_date": "06/08/2021 14:55:33",
      "content": "<p>you can change</p>\n<p>h_ratio = resized_height / height<br>\nw_ratio = resized_width / width</p>\n<p>bbox_resized = [<br>\n    float(row[\"x_min\"]) * w_ratio,<br>\n    float(row[\"y_min\"]) * h_ratio,<br>\n    float(row[\"x_max\"]) * w_ratio,<br>\n    float(row[\"y_max\"]) * h_ratio,<br>\n]</p>\n<p>to</p>\n<p>bbox_resized = np.array([<br>\n    float(row[\"x_min\"]) * w_ratio,<br>\n    float(row[\"y_min\"]) * h_ratio,<br>\n    float(row[\"x_max\"]) * w_ratio,<br>\n    float(row[\"y_max\"]) * h_ratio,<br>\n])</p>\n<p>bbox_resized[[0,2]] = bbox_resized[[0,2]].clip(0, resized_width)<br>\nbbox_resized[[1,3]] = bbox_resized[[1,3]].clip(0, resized_height)<br>\nbbox_resized = list(bbox_resized)</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1341207": "I ran into this notebook:\n\nhttps://www.kaggle.com/ammarnassanalhajali/siim-covid-19-detectron2-training/notebook\n\nAnd one of the files it uses, \"train_image_df\", has negative x_min values in it.\n\nIs there any bbox that has negative x_min value in the data?",
    "1341283": "you can change\n\nh_ratio = resized_height / height\nw_ratio = resized_width / width\n\nbbox_resized = [\n    float(row[\"x_min\"]) * w_ratio,\n    float(row[\"y_min\"]) * h_ratio,\n    float(row[\"x_max\"]) * w_ratio,\n    float(row[\"y_max\"]) * h_ratio,\n]\n\nto\n\nbbox_resized = np.array([\n    float(row[\"x_min\"]) * w_ratio,\n    float(row[\"y_min\"]) * h_ratio,\n    float(row[\"x_max\"]) * w_ratio,\n    float(row[\"y_max\"]) * h_ratio,\n])\n\nbbox_resized[[0,2]] = bbox_resized[[0,2]].clip(0, resized_width)\nbbox_resized[[1,3]] = bbox_resized[[1,3]].clip(0, resized_height)\nbbox_resized = list(bbox_resized)"
  },
  "source": "meta"
}