{
  "id": 458822,
  "title": "NMS (Non-Maximum Suppression): Post processing",
  "url": "/competitions/child-mind-institute-detect-sleep-states/discussion/458822",
  "author_name": "",
  "post_date": "2023-12-01T17:08:58.699012500Z",
  "votes": 15,
  "comment_count": 2,
  "views": 0,
  "content": "<p>\"NMS\" in the context of machine learning, specifically in computer vision (CV), stands for \"Non-Maximum Suppression.\" </p>\n<p>This technique is used in object detection tasks to select the most confident bounding boxes (rectangles surrounding objects) out of many overlapping ones. Essentially, when multiple predictions are made for the same object, NMS helps in choosing the 'best' prediction and discards the rest, thereby improving the accuracy of the final detection results.</p>\n<p>I've implemented it so that you can read and use the submissions, if you'd like.</p>\n<pre><code>import pandas  pd\nsubdf = pd.read\n\ndef non:\n    grouped = df.groupby()\n    nms_predictions = \n\n     _, group  grouped:\n        sorted_group = group.sort\n\n         not sorted_group.empty:\n            highest = sorted_group.iloc\n            nms_predictions.append(highest)\n            sorted_group = sorted_group.sub(highest).abs &gt; iou_threshold]\n\n    nms_df = pd..sort.reset\n    return nms_df\n\n!rm /kaggle/working/submission.csv \n\nnms_submission = non\nnms_submission.\n</code></pre>",
  "messages": [
    {
      "id": "2545696",
      "postDate": "12/01/2023 17:08:58",
      "content": "<p>\"NMS\" in the context of machine learning, specifically in computer vision (CV), stands for \"Non-Maximum Suppression.\" </p>\n<p>This technique is used in object detection tasks to select the most confident bounding boxes (rectangles surrounding objects) out of many overlapping ones. Essentially, when multiple predictions are made for the same object, NMS helps in choosing the 'best' prediction and discards the rest, thereby improving the accuracy of the final detection results.</p>\n<p>I've implemented it so that you can read and use the submissions, if you'd like.</p>\n<pre><code>import pandas  pd\nsubdf = pd.read\n\ndef non:\n    grouped = df.groupby()\n    nms_predictions = \n\n     _, group  grouped:\n        sorted_group = group.sort\n\n         not sorted_group.empty:\n            highest = sorted_group.iloc\n            nms_predictions.append(highest)\n            sorted_group = sorted_group.sub(highest).abs &gt; iou_threshold]\n\n    nms_df = pd..sort.reset\n    return nms_df\n\n!rm /kaggle/working/submission.csv \n\nnms_submission = non\nnms_submission.\n</code></pre>",
      "rawMarkdown": "\"NMS\" in the context of machine learning, specifically in computer vision (CV), stands for \"Non-Maximum Suppression.\" \n\nThis technique is used in object detection tasks to select the most confident bounding boxes (rectangles surrounding objects) out of many overlapping ones. Essentially, when multiple predictions are made for the same object, NMS helps in choosing the 'best' prediction and discards the rest, thereby improving the accuracy of the final detection results.\n\nI've implemented it so that you can read and use the submissions, if you'd like.\n\n```\nimport pandas as pd\nsubdf = pd.read_csv(\"/kaggle/working/submission.csv\")\n\ndef non_maximum_suppression(df, iou_threshold=100):\n    grouped = df.groupby(['event', 'series_id'])\n    nms_predictions = []\n\n    for _, group in grouped:\n        sorted_group = group.sort_values(by='score', ascending=False)\n\n        while not sorted_group.empty:\n            highest = sorted_group.iloc[0]\n            nms_predictions.append(highest)\n            sorted_group = sorted_group[sorted_group['step'].sub(highest['step']).abs() > iou_threshold]\n\n    nms_df = pd.DataFrame(nms_predictions).sort_values(by='row_id').reset_index(drop=True)\n    return nms_df\n\n!rm /kaggle/working/submission.csv \n\nnms_submission = non_maximum_suppression(subdf)\nnms_submission.to_csv('/kaggle/working/submission.csv', index=False)\n```",
      "votes": null
    },
    {
      "id": "2545813",
      "postDate": "12/01/2023 19:05:04",
      "content": "<p>There is an adjacent concept from object detection, WBF (Weighted Boxes Fusion). It's main point is in averaging of many boxes located in some area according to their score, i.e. weighted average. Box with the higher score has higher income into the result. In object detection it usually shows better result than NMS. I tried analog of WBF in the current competition, it didn't work out for me but maybe it will work for the others.</p>\n<p>More info about this method could be found here</p>\n<p><a href=\"https://github.com/ZFTurbo/Weighted-Boxes-Fusion\" target=\"_blank\">https://github.com/ZFTurbo/Weighted-Boxes-Fusion</a></p>",
      "rawMarkdown": "There is an adjacent concept from object detection, WBF (Weighted Boxes Fusion). It's main point is in averaging of many boxes located in some area according to their score, i.e. weighted average. Box with the higher score has higher income into the result. In object detection it usually shows better result than NMS. I tried analog of WBF in the current competition, it didn't work out for me but maybe it will work for the others.\n\nMore info about this method could be found here\n\nhttps://github.com/ZFTurbo/Weighted-Boxes-Fusion",
      "votes": null
    },
    {
      "id": "2545856",
      "postDate": "12/01/2023 20:12:56",
      "content": "<p>Thanks Alex, I'll try that. I learned a lot. I tried a WBF-like implementation myself, but it didn't work out too well.</p>",
      "rawMarkdown": "Thanks Alex, I'll try that. I learned a lot. I tried a WBF-like implementation myself, but it didn't work out too well.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2545813,
      "author_name": "beatwad",
      "author_url": "",
      "post_date": "12/01/2023 19:05:04",
      "content": "<p>There is an adjacent concept from object detection, WBF (Weighted Boxes Fusion). It's main point is in averaging of many boxes located in some area according to their score, i.e. weighted average. Box with the higher score has higher income into the result. In object detection it usually shows better result than NMS. I tried analog of WBF in the current competition, it didn't work out for me but maybe it will work for the others.</p>\n<p>More info about this method could be found here</p>\n<p><a href=\"https://github.com/ZFTurbo/Weighted-Boxes-Fusion\" target=\"_blank\">https://github.com/ZFTurbo/Weighted-Boxes-Fusion</a></p>",
      "votes": null,
      "replies": [
        {
          "id": 2545856,
          "author_name": "dolphin15",
          "author_url": "",
          "post_date": "12/01/2023 20:12:56",
          "content": "<p>Thanks Alex, I'll try that. I learned a lot. I tried a WBF-like implementation myself, but it didn't work out too well.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2545696": "\"NMS\" in the context of machine learning, specifically in computer vision (CV), stands for \"Non-Maximum Suppression.\" \n\nThis technique is used in object detection tasks to select the most confident bounding boxes (rectangles surrounding objects) out of many overlapping ones. Essentially, when multiple predictions are made for the same object, NMS helps in choosing the 'best' prediction and discards the rest, thereby improving the accuracy of the final detection results.\n\nI've implemented it so that you can read and use the submissions, if you'd like.\n\n```\nimport pandas as pd\nsubdf = pd.read_csv(\"/kaggle/working/submission.csv\")\n\ndef non_maximum_suppression(df, iou_threshold=100):\n    grouped = df.groupby(['event', 'series_id'])\n    nms_predictions = []\n\n    for _, group in grouped:\n        sorted_group = group.sort_values(by='score', ascending=False)\n\n        while not sorted_group.empty:\n            highest = sorted_group.iloc[0]\n            nms_predictions.append(highest)\n            sorted_group = sorted_group[sorted_group['step'].sub(highest['step']).abs() > iou_threshold]\n\n    nms_df = pd.DataFrame(nms_predictions).sort_values(by='row_id').reset_index(drop=True)\n    return nms_df\n\n!rm /kaggle/working/submission.csv \n\nnms_submission = non_maximum_suppression(subdf)\nnms_submission.to_csv('/kaggle/working/submission.csv', index=False)\n```",
    "2545813": "There is an adjacent concept from object detection, WBF (Weighted Boxes Fusion). It's main point is in averaging of many boxes located in some area according to their score, i.e. weighted average. Box with the higher score has higher income into the result. In object detection it usually shows better result than NMS. I tried analog of WBF in the current competition, it didn't work out for me but maybe it will work for the others.\n\nMore info about this method could be found here\n\nhttps://github.com/ZFTurbo/Weighted-Boxes-Fusion",
    "2545856": "Thanks Alex, I'll try that. I learned a lot. I tried a WBF-like implementation myself, but it didn't work out too well."
  },
  "source": "meta"
}