{
  "id": 163095,
  "title": "Speed Improvement with Weighted Box Fusion Ver. 1.0.4",
  "url": "/competitions/global-wheat-detection/discussion/163095",
  "author_name": "",
  "post_date": "2020-07-01T03:00:38.300779200Z",
  "votes": 28,
  "comment_count": 8,
  "views": 0,
  "content": "<h2>UPDATE on July 5</h2>\n\n<p>In many of my experiments, this 1.0.4 version even though faster can make slightly different results. I usually got 3rd decimal place lower LB than the previous WBF version.</p>\n\n<h2>Original post</h2>\n\n<p>Hi,</p>\n\n<p>As WBF plays a critical role in almost public kernels performance. Last week the author <a href=\"/zfturbo\">@zfturbo</a> updated his repo to ver 1.0.4\n<a href=\"https://github.com/ZFTurbo/Weighted-Boxes-Fusion/releases\">https://github.com/ZFTurbo/Weighted-Boxes-Fusion/releases</a>\n(Please star his repo)</p>\n\n<p>```\n<strong>Speed up + New Features</strong>\n@ZFTurbo ZFTurbo released this 5 days ago · 1 commit to master since this release</p>\n\n<p>Added many input data checks in all methods: set to 0.0 coords &lt; 0, set to 1.0 coords &gt; 1, swap cases where x2 &lt; x1 and y2 &lt; y1, remove zero area boxes.</p>\n\n<p>Added numba @jit(nopython=True) for critical functions (NMS, NMW and WBF). Speed up around x2 times (tested on example_oid.py).\n```\nWe can see that now the new version use numba implementation and potentially improve WBF speed by 2x (However, in my own experiment, speed improvement is only around 25%-30%)</p>\n\n<p>You can use his newest version from this dataset : \n<a href=\"https://www.kaggle.com/ratthachat/weighted-boxes-fusion-104\">https://www.kaggle.com/ratthachat/weighted-boxes-fusion-104</a></p>\n\n<p><strong>IMPORTANT NOTE</strong> This new version requires <em>normalized</em> xyxy input so we have to change the public kernel code a bit (3 lines) ... <strong><em>BE SURE to visualize your bboxes before submit!!</em></strong></p>\n\n<p>Since there are already many kernels on YoloV5, I don't think I need to do a new kernel, we have to change the following 3 lines of <a href=\"/orkatz2\">@orkatz2</a> baseline and only 1 line of <a href=\"/nvnnghia\">@nvnnghia</a> (perhaps <a href=\"/orkatz2\">@orkatz2</a> and <a href=\"/nvnnghia\">@nvnnghia</a>  may consider to update their great kernels :D  )</p>\n\n<p>(1) Insert the new dataset  --&gt; only this change for <a href=\"/nvnnghia\">@nvnnghia</a> kernel\n```</p>\n\n<h1>sys.path.insert(0, \"../input/weightedboxesfusion\")</h1>\n\n<p>sys.path.insert(0, \"../input/weighted-boxes-fusion-104\")\n```</p>\n\n<p>(2) In <code>def detect(save_img=False):</code>\nAdd one line\n```\nfor *xyxy, conf, cls in det:\n    xyxy = torch.tensor(xyxy).view(-1).numpy()  # unnormalized xyxy</p>\n\n<pre><code># ADD this line for wbf 1.0.4\nxyxy = xyxy.astype(np.float32)/1024 #normalized xyxy\n</code></pre>\n\n<p>```    </p>\n\n<p>(3) In final prediction, \n```</p>\n\n<h1>boxes = (boxes*1024/1024).astype(np.int32).clip(min=0, max=1023) # old WBF</h1>\n\n<p>boxes = (boxes*1024).astype(np.int32).clip(min=0, max=1023) # WBF 1.0.4\n```</p>",
  "messages": [
    {
      "id": "910163",
      "postDate": "07/01/2020 03:00:38",
      "content": "<h2>UPDATE on July 5</h2>\n\n<p>In many of my experiments, this 1.0.4 version even though faster can make slightly different results. I usually got 3rd decimal place lower LB than the previous WBF version.</p>\n\n<h2>Original post</h2>\n\n<p>Hi,</p>\n\n<p>As WBF plays a critical role in almost public kernels performance. Last week the author <a href=\"/zfturbo\">@zfturbo</a> updated his repo to ver 1.0.4\n<a href=\"https://github.com/ZFTurbo/Weighted-Boxes-Fusion/releases\">https://github.com/ZFTurbo/Weighted-Boxes-Fusion/releases</a>\n(Please star his repo)</p>\n\n<p>```\n<strong>Speed up + New Features</strong>\n@ZFTurbo ZFTurbo released this 5 days ago · 1 commit to master since this release</p>\n\n<p>Added many input data checks in all methods: set to 0.0 coords &lt; 0, set to 1.0 coords &gt; 1, swap cases where x2 &lt; x1 and y2 &lt; y1, remove zero area boxes.</p>\n\n<p>Added numba @jit(nopython=True) for critical functions (NMS, NMW and WBF). Speed up around x2 times (tested on example_oid.py).\n```\nWe can see that now the new version use numba implementation and potentially improve WBF speed by 2x (However, in my own experiment, speed improvement is only around 25%-30%)</p>\n\n<p>You can use his newest version from this dataset : \n<a href=\"https://www.kaggle.com/ratthachat/weighted-boxes-fusion-104\">https://www.kaggle.com/ratthachat/weighted-boxes-fusion-104</a></p>\n\n<p><strong>IMPORTANT NOTE</strong> This new version requires <em>normalized</em> xyxy input so we have to change the public kernel code a bit (3 lines) ... <strong><em>BE SURE to visualize your bboxes before submit!!</em></strong></p>\n\n<p>Since there are already many kernels on YoloV5, I don't think I need to do a new kernel, we have to change the following 3 lines of <a href=\"/orkatz2\">@orkatz2</a> baseline and only 1 line of <a href=\"/nvnnghia\">@nvnnghia</a> (perhaps <a href=\"/orkatz2\">@orkatz2</a> and <a href=\"/nvnnghia\">@nvnnghia</a>  may consider to update their great kernels :D  )</p>\n\n<p>(1) Insert the new dataset  --&gt; only this change for <a href=\"/nvnnghia\">@nvnnghia</a> kernel\n```</p>\n\n<h1>sys.path.insert(0, \"../input/weightedboxesfusion\")</h1>\n\n<p>sys.path.insert(0, \"../input/weighted-boxes-fusion-104\")\n```</p>\n\n<p>(2) In <code>def detect(save_img=False):</code>\nAdd one line\n```\nfor *xyxy, conf, cls in det:\n    xyxy = torch.tensor(xyxy).view(-1).numpy()  # unnormalized xyxy</p>\n\n<pre><code># ADD this line for wbf 1.0.4\nxyxy = xyxy.astype(np.float32)/1024 #normalized xyxy\n</code></pre>\n\n<p>```    </p>\n\n<p>(3) In final prediction, \n```</p>\n\n<h1>boxes = (boxes*1024/1024).astype(np.int32).clip(min=0, max=1023) # old WBF</h1>\n\n<p>boxes = (boxes*1024).astype(np.int32).clip(min=0, max=1023) # WBF 1.0.4\n```</p>",
      "rawMarkdown": "## UPDATE on July 5\nIn many of my experiments, this 1.0.4 version even though faster can make slightly different results. I usually got 3rd decimal place lower LB than the previous WBF version.\n\n## Original post\nHi,\n\nAs WBF plays a critical role in almost public kernels performance. Last week the author @zfturbo updated his repo to ver 1.0.4\nhttps://github.com/ZFTurbo/Weighted-Boxes-Fusion/releases\n(Please star his repo)\n\n```\n**Speed up + New Features**\n@ZFTurbo ZFTurbo released this 5 days ago · 1 commit to master since this release\n\nAdded many input data checks in all methods: set to 0.0 coords &lt; 0, set to 1.0 coords &gt; 1, swap cases where x2 &lt; x1 and y2 &lt; y1, remove zero area boxes.\n\nAdded numba @jit(nopython=True) for critical functions (NMS, NMW and WBF). Speed up around x2 times (tested on example_oid.py).\n```\nWe can see that now the new version use numba implementation and potentially improve WBF speed by 2x (However, in my own experiment, speed improvement is only around 25%-30%)\n\nYou can use his newest version from this dataset : \nhttps://www.kaggle.com/ratthachat/weighted-boxes-fusion-104\n\n**IMPORTANT NOTE** This new version requires *normalized* xyxy input so we have to change the public kernel code a bit (3 lines) ... ***BE SURE to visualize your bboxes before submit!!***\n\nSince there are already many kernels on YoloV5, I don't think I need to do a new kernel, we have to change the following 3 lines of @orkatz2 baseline and only 1 line of @nvnnghia (perhaps @orkatz2 and @nvnnghia  may consider to update their great kernels :D  )\n\n(1) Insert the new dataset  --&gt; only this change for @nvnnghia kernel\n```\n# sys.path.insert(0, \"../input/weightedboxesfusion\")\nsys.path.insert(0, \"../input/weighted-boxes-fusion-104\")\n```\n\n(2) In `def detect(save_img=False):`\nAdd one line\n```\nfor *xyxy, conf, cls in det:\n    xyxy = torch.tensor(xyxy).view(-1).numpy()  # unnormalized xyxy\n                            \n    # ADD this line for wbf 1.0.4\n    xyxy = xyxy.astype(np.float32)/1024 #normalized xyxy\n```    \n\n(3) In final prediction, \n```\n#boxes = (boxes*1024/1024).astype(np.int32).clip(min=0, max=1023) # old WBF\nboxes = (boxes*1024).astype(np.int32).clip(min=0, max=1023) # WBF 1.0.4\n```",
      "votes": null
    },
    {
      "id": "910165",
      "postDate": "07/01/2020 03:01:35",
      "content": "<p>Sounds great! Thanks for the share!</p>",
      "rawMarkdown": "Sounds great! Thanks for the share!",
      "votes": null
    },
    {
      "id": "910410",
      "postDate": "07/01/2020 06:17:10",
      "content": "<p>Great!</p>",
      "rawMarkdown": "Great!",
      "votes": null
    },
    {
      "id": "910441",
      "postDate": "07/01/2020 06:40:53",
      "content": "<p><a href=\"/ratthachat\">@ratthachat</a> I am not able to search this dataset using below url-\n<a href=\"https://www.kaggle.com/ratthachat/weighted-boxes-fusion-104\">https://www.kaggle.com/ratthachat/weighted-boxes-fusion-104</a></p>",
      "rawMarkdown": "ratthachat I am not able to search this dataset using below url-\nhttps://www.kaggle.com/ratthachat/weighted-boxes-fusion-104",
      "votes": null
    },
    {
      "id": "910447",
      "postDate": "07/01/2020 06:44:32",
      "content": "<p><a href=\"/iamprateek\">@iamprateek</a> Thank you! It's a shame, I thought I made it public, but somehow i did not. Now you should see the dataset :D</p>",
      "rawMarkdown": "iamprateek Thank you! It's a shame, I thought I made it public, but somehow i did not. Now you should see the dataset :D",
      "votes": null
    },
    {
      "id": "910576",
      "postDate": "07/01/2020 08:15:38",
      "content": "<p>Thanks <a href=\"/ratthachat\">@ratthachat</a> . Now I am able to access it.</p>",
      "rawMarkdown": "Thanks @ratthachat . Now I am able to access it.",
      "votes": null
    },
    {
      "id": "910585",
      "postDate": "07/01/2020 08:23:08",
      "content": "<p>Thanks for sharing <a href=\"/ratthachat\">@ratthachat</a> </p>",
      "rawMarkdown": "Thanks for sharing @ratthachat",
      "votes": null
    },
    {
      "id": "910868",
      "postDate": "07/01/2020 12:21:47",
      "content": "<p>Good job. Thanks for sharing, it will save us a lot of time <a href=\"/ratthachat\">@ratthachat</a></p>",
      "rawMarkdown": "Good job. Thanks for sharing, it will save us a lot of time @ratthachat",
      "votes": null
    },
    {
      "id": "912669",
      "postDate": "07/02/2020 16:30:20",
      "content": "<p>Great! thanks a lot for sharing :D</p>",
      "rawMarkdown": "Great! thanks a lot for sharing :D",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 910165,
      "author_name": "matthewmasters",
      "author_url": "",
      "post_date": "07/01/2020 03:01:35",
      "content": "<p>Sounds great! Thanks for the share!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 910410,
      "author_name": "uspdpi",
      "author_url": "",
      "post_date": "07/01/2020 06:17:10",
      "content": "<p>Great!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 910441,
      "author_name": "iamprateek",
      "author_url": "",
      "post_date": "07/01/2020 06:40:53",
      "content": "<p><a href=\"/ratthachat\">@ratthachat</a> I am not able to search this dataset using below url-\n<a href=\"https://www.kaggle.com/ratthachat/weighted-boxes-fusion-104\">https://www.kaggle.com/ratthachat/weighted-boxes-fusion-104</a></p>",
      "votes": null,
      "replies": [
        {
          "id": 910447,
          "author_name": "ratthachat",
          "author_url": "",
          "post_date": "07/01/2020 06:44:32",
          "content": "<p><a href=\"/iamprateek\">@iamprateek</a> Thank you! It's a shame, I thought I made it public, but somehow i did not. Now you should see the dataset :D</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 910576,
          "author_name": "iamprateek",
          "author_url": "",
          "post_date": "07/01/2020 08:15:38",
          "content": "<p>Thanks <a href=\"/ratthachat\">@ratthachat</a> . Now I am able to access it.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 910585,
      "author_name": "nvnnghia",
      "author_url": "",
      "post_date": "07/01/2020 08:23:08",
      "content": "<p>Thanks for sharing <a href=\"/ratthachat\">@ratthachat</a> </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 910868,
      "author_name": "duykhanh99",
      "author_url": "",
      "post_date": "07/01/2020 12:21:47",
      "content": "<p>Good job. Thanks for sharing, it will save us a lot of time <a href=\"/ratthachat\">@ratthachat</a></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 912669,
      "author_name": "rifat963",
      "author_url": "",
      "post_date": "07/02/2020 16:30:20",
      "content": "<p>Great! thanks a lot for sharing :D</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "910163": "## UPDATE on July 5\nIn many of my experiments, this 1.0.4 version even though faster can make slightly different results. I usually got 3rd decimal place lower LB than the previous WBF version.\n\n## Original post\nHi,\n\nAs WBF plays a critical role in almost public kernels performance. Last week the author @zfturbo updated his repo to ver 1.0.4\nhttps://github.com/ZFTurbo/Weighted-Boxes-Fusion/releases\n(Please star his repo)\n\n```\n**Speed up + New Features**\n@ZFTurbo ZFTurbo released this 5 days ago · 1 commit to master since this release\n\nAdded many input data checks in all methods: set to 0.0 coords &lt; 0, set to 1.0 coords &gt; 1, swap cases where x2 &lt; x1 and y2 &lt; y1, remove zero area boxes.\n\nAdded numba @jit(nopython=True) for critical functions (NMS, NMW and WBF). Speed up around x2 times (tested on example_oid.py).\n```\nWe can see that now the new version use numba implementation and potentially improve WBF speed by 2x (However, in my own experiment, speed improvement is only around 25%-30%)\n\nYou can use his newest version from this dataset : \nhttps://www.kaggle.com/ratthachat/weighted-boxes-fusion-104\n\n**IMPORTANT NOTE** This new version requires *normalized* xyxy input so we have to change the public kernel code a bit (3 lines) ... ***BE SURE to visualize your bboxes before submit!!***\n\nSince there are already many kernels on YoloV5, I don't think I need to do a new kernel, we have to change the following 3 lines of @orkatz2 baseline and only 1 line of @nvnnghia (perhaps @orkatz2 and @nvnnghia  may consider to update their great kernels :D  )\n\n(1) Insert the new dataset  --&gt; only this change for @nvnnghia kernel\n```\n# sys.path.insert(0, \"../input/weightedboxesfusion\")\nsys.path.insert(0, \"../input/weighted-boxes-fusion-104\")\n```\n\n(2) In `def detect(save_img=False):`\nAdd one line\n```\nfor *xyxy, conf, cls in det:\n    xyxy = torch.tensor(xyxy).view(-1).numpy()  # unnormalized xyxy\n                            \n    # ADD this line for wbf 1.0.4\n    xyxy = xyxy.astype(np.float32)/1024 #normalized xyxy\n```    \n\n(3) In final prediction, \n```\n#boxes = (boxes*1024/1024).astype(np.int32).clip(min=0, max=1023) # old WBF\nboxes = (boxes*1024).astype(np.int32).clip(min=0, max=1023) # WBF 1.0.4\n```",
    "910165": "Sounds great! Thanks for the share!",
    "910410": "Great!",
    "910441": "ratthachat I am not able to search this dataset using below url-\nhttps://www.kaggle.com/ratthachat/weighted-boxes-fusion-104",
    "910447": "iamprateek Thank you! It's a shame, I thought I made it public, but somehow i did not. Now you should see the dataset :D",
    "910576": "Thanks @ratthachat . Now I am able to access it.",
    "910585": "Thanks for sharing @ratthachat",
    "910868": "Good job. Thanks for sharing, it will save us a lot of time @ratthachat",
    "912669": "Great! thanks a lot for sharing :D"
  },
  "source": "meta"
}