{
  "id": 125670,
  "title": "Apply testmasks",
  "url": "/competitions/pku-autonomous-driving/discussion/125670",
  "author_name": "",
  "post_date": "2020-01-12T17:31:14.679403300Z",
  "votes": null,
  "comment_count": 4,
  "views": 0,
  "content": "<p>Will it make any difference if we apply test masks to images.</p>\n\n<p>Can some one point out how to do so if there is any post about same</p>",
  "messages": [
    {
      "id": "717074",
      "postDate": "01/12/2020 17:31:14",
      "content": "<p>Will it make any difference if we apply test masks to images.</p>\n\n<p>Can some one point out how to do so if there is any post about same</p>",
      "rawMarkdown": "Will it make any difference if we apply test masks to images.\n\nCan some one point out how to do so if there is any post about same",
      "votes": null
    },
    {
      "id": "717934",
      "postDate": "01/13/2020 20:01:11",
      "content": "<p>Please see the <a href=\"https://www.kaggle.com/isakev/rb-s-centernet-baseline-pytorch-without-dropout\">kernel</a> where I applied test masks. At the bottom of the notebook there is a dataframe showing how many cars were taken out by test masks application. My estimate it adds around  0.002 to PL score for smaller models. I feel test masks application might have been one of the positive factors that improved the Centernet Baseline <a href=\"https://www.kaggle.com/hocop1/centernet-baseline\">kernel</a> from PL 0.038 to 0.041. For my best model, it raised the score from 0.052 to 0.055</p>",
      "rawMarkdown": "Please see the [kernel](https://www.kaggle.com/isakev/rb-s-centernet-baseline-pytorch-without-dropout) where I applied test masks. At the bottom of the notebook there is a dataframe showing how many cars were taken out by test masks application. My estimate it adds around  0.002 to PL score for smaller models. I feel test masks application might have been one of the positive factors that improved the Centernet Baseline [kernel](https://www.kaggle.com/hocop1/centernet-baseline) from PL 0.038 to 0.041. For my best model, it raised the score from 0.052 to 0.055",
      "votes": null
    },
    {
      "id": "718576",
      "postDate": "01/14/2020 14:49:34",
      "content": "<p><a href=\"/isakev\">@isakev</a>  thanks\nwhy do use 256,64 here?\n2) Why we should subtract the test mask,and also using 100 below</p>\n\n<p>I thought it was just to multiply the available mask as per the size of image.</p>\n\n<p>```\n if isinstance(test_mask, np.ndarray):\n                    test_mask = cv2.resize(test_mask, (256,64))[...,0]\n                    test_mask = np.where(test_mask&gt;255//2, 100, 0)  # subtract from logits</p>\n\n<pre><code>                out[0,...] =  out[0,...] - test_mask\n\n            coords = extract_coords(out, threshold= threshold) \n            s = coords2str(coords)\n            preds.append(s)\n</code></pre>\n\n<p>```</p>",
      "rawMarkdown": "isakev  thanks\nwhy do use 256,64 here?\n2) Why we should subtract the test mask,and also using 100 below\n\nI thought it was just to multiply the available mask as per the size of image.\n\n ```\n if isinstance(test_mask, np.ndarray):\n                    test_mask = cv2.resize(test_mask, (256,64))[...,0]\n                    test_mask = np.where(test_mask&gt;255//2, 100, 0)  # subtract from logits\n                        \n                    out[0,...] =  out[0,...] - test_mask\n                    \n                coords = extract_coords(out, threshold= threshold) \n                s = coords2str(coords)\n                preds.append(s)\n```",
      "votes": null
    },
    {
      "id": "718739",
      "postDate": "01/14/2020 17:48:03",
      "content": "<p>Thanks for the interest <a href=\"/jaideepvalani\">@jaideepvalani</a> . \n1) The Centernet Baseline kernel's model output[0] is of 64x256 shape, so I resized test_masks to be able to subtract from output[0] logits. I choose to subtract test_masks, not to multiply, because somehow they are not only zeros and ones (or 1 and 255's).\n2) Any number above the magnitude of the cutoff threshold (mine was - (-1.5)) seemed acceptable to subtract from logits. I just chose 100. Subtracting 100 from predictions at selected positions makes the values of the points much more negative, thus the car predictions at positions where test masks are &gt; 255/2 are excluded from  final predictions.\nAppx. 1.5k cars out of 22k cars predicted on the test set were excluded in this manner.</p>",
      "rawMarkdown": "Thanks for the interest @jaideepvalani . \n1) The Centernet Baseline kernel's model output[0] is of 64x256 shape, so I resized test_masks to be able to subtract from output[0] logits. I choose to subtract test_masks, not to multiply, because somehow they are not only zeros and ones (or 1 and 255's).\n2) Any number above the magnitude of the cutoff threshold (mine was - (-1.5)) seemed acceptable to subtract from logits. I just chose 100. Subtracting 100 from predictions at selected positions makes the values of the points much more negative, thus the car predictions at positions where test masks are &gt; 255/2 are excluded from  final predictions.\nAppx. 1.5k cars out of 22k cars predicted on the test set were excluded in this manner.",
      "votes": null
    },
    {
      "id": "720167",
      "postDate": "01/16/2020 08:07:13",
      "content": "<p>ok thanks.\nx,y that we get after projections on full image size, where are they rescaled to new image size. \ncv.resize which u are using will take care of adjusting the coordinates of x,y to new image size which we get after scaling and triming</p>",
      "rawMarkdown": "ok thanks.\nx,y that we get after projections on full image size, where are they rescaled to new image size. \ncv.resize which u are using will take care of adjusting the coordinates of x,y to new image size which we get after scaling and triming",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 717934,
      "author_name": "isakev",
      "author_url": "",
      "post_date": "01/13/2020 20:01:11",
      "content": "<p>Please see the <a href=\"https://www.kaggle.com/isakev/rb-s-centernet-baseline-pytorch-without-dropout\">kernel</a> where I applied test masks. At the bottom of the notebook there is a dataframe showing how many cars were taken out by test masks application. My estimate it adds around  0.002 to PL score for smaller models. I feel test masks application might have been one of the positive factors that improved the Centernet Baseline <a href=\"https://www.kaggle.com/hocop1/centernet-baseline\">kernel</a> from PL 0.038 to 0.041. For my best model, it raised the score from 0.052 to 0.055</p>",
      "votes": null,
      "replies": [
        {
          "id": 718576,
          "author_name": "jaideepvalani",
          "author_url": "",
          "post_date": "01/14/2020 14:49:34",
          "content": "<p><a href=\"/isakev\">@isakev</a>  thanks\nwhy do use 256,64 here?\n2) Why we should subtract the test mask,and also using 100 below</p>\n\n<p>I thought it was just to multiply the available mask as per the size of image.</p>\n\n<p>```\n if isinstance(test_mask, np.ndarray):\n                    test_mask = cv2.resize(test_mask, (256,64))[...,0]\n                    test_mask = np.where(test_mask&gt;255//2, 100, 0)  # subtract from logits</p>\n\n<pre><code>                out[0,...] =  out[0,...] - test_mask\n\n            coords = extract_coords(out, threshold= threshold) \n            s = coords2str(coords)\n            preds.append(s)\n</code></pre>\n\n<p>```</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 718739,
          "author_name": "isakev",
          "author_url": "",
          "post_date": "01/14/2020 17:48:03",
          "content": "<p>Thanks for the interest <a href=\"/jaideepvalani\">@jaideepvalani</a> . \n1) The Centernet Baseline kernel's model output[0] is of 64x256 shape, so I resized test_masks to be able to subtract from output[0] logits. I choose to subtract test_masks, not to multiply, because somehow they are not only zeros and ones (or 1 and 255's).\n2) Any number above the magnitude of the cutoff threshold (mine was - (-1.5)) seemed acceptable to subtract from logits. I just chose 100. Subtracting 100 from predictions at selected positions makes the values of the points much more negative, thus the car predictions at positions where test masks are &gt; 255/2 are excluded from  final predictions.\nAppx. 1.5k cars out of 22k cars predicted on the test set were excluded in this manner.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 720167,
          "author_name": "jaideepvalani",
          "author_url": "",
          "post_date": "01/16/2020 08:07:13",
          "content": "<p>ok thanks.\nx,y that we get after projections on full image size, where are they rescaled to new image size. \ncv.resize which u are using will take care of adjusting the coordinates of x,y to new image size which we get after scaling and triming</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "717074": "Will it make any difference if we apply test masks to images.\n\nCan some one point out how to do so if there is any post about same",
    "717934": "Please see the [kernel](https://www.kaggle.com/isakev/rb-s-centernet-baseline-pytorch-without-dropout) where I applied test masks. At the bottom of the notebook there is a dataframe showing how many cars were taken out by test masks application. My estimate it adds around  0.002 to PL score for smaller models. I feel test masks application might have been one of the positive factors that improved the Centernet Baseline [kernel](https://www.kaggle.com/hocop1/centernet-baseline) from PL 0.038 to 0.041. For my best model, it raised the score from 0.052 to 0.055",
    "718576": "isakev  thanks\nwhy do use 256,64 here?\n2) Why we should subtract the test mask,and also using 100 below\n\nI thought it was just to multiply the available mask as per the size of image.\n\n ```\n if isinstance(test_mask, np.ndarray):\n                    test_mask = cv2.resize(test_mask, (256,64))[...,0]\n                    test_mask = np.where(test_mask&gt;255//2, 100, 0)  # subtract from logits\n                        \n                    out[0,...] =  out[0,...] - test_mask\n                    \n                coords = extract_coords(out, threshold= threshold) \n                s = coords2str(coords)\n                preds.append(s)\n```",
    "718739": "Thanks for the interest @jaideepvalani . \n1) The Centernet Baseline kernel's model output[0] is of 64x256 shape, so I resized test_masks to be able to subtract from output[0] logits. I choose to subtract test_masks, not to multiply, because somehow they are not only zeros and ones (or 1 and 255's).\n2) Any number above the magnitude of the cutoff threshold (mine was - (-1.5)) seemed acceptable to subtract from logits. I just chose 100. Subtracting 100 from predictions at selected positions makes the values of the points much more negative, thus the car predictions at positions where test masks are &gt; 255/2 are excluded from  final predictions.\nAppx. 1.5k cars out of 22k cars predicted on the test set were excluded in this manner.",
    "720167": "ok thanks.\nx,y that we get after projections on full image size, where are they rescaled to new image size. \ncv.resize which u are using will take care of adjusting the coordinates of x,y to new image size which we get after scaling and triming"
  },
  "source": "meta"
}