{
  "id": 108075,
  "title": "why submission differ...",
  "url": "/competitions/aptos2019-blindness-detection/discussion/108075",
  "author_name": "",
  "post_date": "2019-09-08T22:45:23.242379200Z",
  "votes": null,
  "comment_count": 4,
  "views": 0,
  "content": "<p>After competition ends I want to do some reproducing and experiments. But I find a weird situation:</p>\n\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2721247%2F0497057948a150f8b90e8cf3f622b14f%2Faptoswrong.bmp?generation=1567982632049414&amp;alt=media\" alt=\"\"></p>\n\n<p>The bottom result is what i run the inference kernel. The top result is that I just copy the prediction from the inference kernel and do fast submission. why there is difference in public LB?</p>",
  "messages": [
    {
      "id": "621758",
      "postDate": "09/08/2019 22:45:23",
      "content": "<p>After competition ends I want to do some reproducing and experiments. But I find a weird situation:</p>\n\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2721247%2F0497057948a150f8b90e8cf3f622b14f%2Faptoswrong.bmp?generation=1567982632049414&amp;alt=media\" alt=\"\"></p>\n\n<p>The bottom result is what i run the inference kernel. The top result is that I just copy the prediction from the inference kernel and do fast submission. why there is difference in public LB?</p>",
      "rawMarkdown": "After competition ends I want to do some reproducing and experiments. But I find a weird situation:\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2721247%2F0497057948a150f8b90e8cf3f622b14f%2Faptoswrong.bmp?generation=1567982632049414&amp;alt=media)\n\nThe bottom result is what i run the inference kernel. The top result is that I just copy the prediction from the inference kernel and do fast submission. why there is difference in public LB?",
      "votes": null
    },
    {
      "id": "621762",
      "postDate": "09/08/2019 23:00:50",
      "content": "<p>The submission.csv you can see only contains data from the public leaderboard set, so you only made predictions on that set.</p>",
      "rawMarkdown": "The submission.csv you can see only contains data from the public leaderboard set, so you only made predictions on that set.",
      "votes": null
    },
    {
      "id": "621764",
      "postDate": "09/08/2019 23:03:42",
      "content": "<p>But that should be no difference at public LB. Or you mean I should use test.csv instead of sample_submission.csv?</p>",
      "rawMarkdown": "But that should be no difference at public LB. Or you mean I should use test.csv instead of sample_submission.csv?",
      "votes": null
    },
    {
      "id": "621782",
      "postDate": "09/09/2019 00:17:36",
      "content": "<p>Ah I see, then it is not explained by that, I'm not sure then </p>",
      "rawMarkdown": "Ah I see, then it is not explained by that, I'm not sure then",
      "votes": null
    },
    {
      "id": "621800",
      "postDate": "09/09/2019 00:53:54",
      "content": "<p>findout the reason:\nthese 2 function to crop: \n```python\ndef resize_images(img, desired_size = 1024): <br>\n    img = cv2.copyMakeBorder(img,10,10,10,10,cv2.BORDER_CONSTANT,value=[0,0,0])\n    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\n    ret,gray = cv2.threshold(gray,10,255,cv2.THRESH_BINARY)</p>\n\n<pre><code>contours,hierarchy = cv2.findContours(gray,\n                                      cv2.RETR_EXTERNAL,\n                                      cv2.CHAIN_APPROX_SIMPLE)\ncontours = max(contours, key=cv2.contourArea)\nx,y,w,h = cv2.boundingRect(contours)\n\nif w&amp;gt;200 and h&amp;gt;200:\n    new_img = img[y:y+h,x:x+w]\n    height, width, _= new_img.shape\n\n    if max([height, width]) &amp;gt; desired_size:\n        ratio = float(desired_size/max([height, width]))\n        new_img = cv2.resize(new_img, \n                             tuple([int(width*ratio), int(height*ratio)]), \n                             interpolation = cv2.INTER_CUBIC)\n\n    return new_img\nelse:\n    print(f'No bounding for {name}')\n    return new_img\n</code></pre>\n\n<p><code>\nand\n</code>python\ndef crop(gray, img, percent_smaller):</p>\n\n<pre><code>thresh = 8\n\ntop    = 0\nleft   = 0\nbottom = gray.shape[0] - 1\nright  = gray.shape[1] - 1\n\n# work in from the top and bottom along the middle collumn\nmiddleCol = gray[:, int(gray.shape[1]/2)] &amp;gt; thresh\nwhile middleCol[top] == 0:\n    top += 1\nwhile middleCol[bottom] == 0:\n    bottom -= 1\n\n# work in from the sides along the middle row\nmiddleRow = gray[int(gray.shape[0]/2)] &amp;gt; thresh\nwhile middleRow[left] == 0:\n    left += 1\nwhile middleRow[right] == 0:\n    right -= 1\n\nheight = bottom - top\nwidth  = right - left\n\nbottom -= int(percent_smaller*height)\ntop    += int(percent_smaller*height)\nright  -= int(percent_smaller*width)\nleft   += int(percent_smaller*width)\n\nif height &amp;lt; 100 or width &amp;lt; 100:\n    print(\"Error: squareUp: bottom:\", bottom, \"top:\", top)\n    print(\"Error: squareUp: right:\", right, \"left:\", left)\n    return img\n\nreturn img[top:bottom, left:right]\n</code></pre>\n\n<p>```\nhas trouble to deal with some private test picture.\nAny team used these 2 function or some similar functions might have a heart break trouble.</p>",
      "rawMarkdown": "findout the reason:\nthese 2 function to crop: \n```python\ndef resize_images(img, desired_size = 1024):  \n    img = cv2.copyMakeBorder(img,10,10,10,10,cv2.BORDER_CONSTANT,value=[0,0,0])\n    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\n    ret,gray = cv2.threshold(gray,10,255,cv2.THRESH_BINARY)\n    \n    contours,hierarchy = cv2.findContours(gray,\n                                          cv2.RETR_EXTERNAL,\n                                          cv2.CHAIN_APPROX_SIMPLE)\n    contours = max(contours, key=cv2.contourArea)\n    x,y,w,h = cv2.boundingRect(contours)\n\n    if w&gt;200 and h&gt;200:\n        new_img = img[y:y+h,x:x+w]\n        height, width, _= new_img.shape\n\n        if max([height, width]) &gt; desired_size:\n            ratio = float(desired_size/max([height, width]))\n            new_img = cv2.resize(new_img, \n                                 tuple([int(width*ratio), int(height*ratio)]), \n                                 interpolation = cv2.INTER_CUBIC)\n            \n        return new_img\n    else:\n        print(f'No bounding for {name}')\n        return new_img\n```\nand\n```python\ndef crop(gray, img, percent_smaller):\n    \n    thresh = 8\n    \n    top    = 0\n    left   = 0\n    bottom = gray.shape[0] - 1\n    right  = gray.shape[1] - 1\n    \n    # work in from the top and bottom along the middle collumn\n    middleCol = gray[:, int(gray.shape[1]/2)] &gt; thresh\n    while middleCol[top] == 0:\n        top += 1\n    while middleCol[bottom] == 0:\n        bottom -= 1\n        \n    # work in from the sides along the middle row\n    middleRow = gray[int(gray.shape[0]/2)] &gt; thresh\n    while middleRow[left] == 0:\n        left += 1\n    while middleRow[right] == 0:\n        right -= 1\n        \n    height = bottom - top\n    width  = right - left\n    \n    bottom -= int(percent_smaller*height)\n    top    += int(percent_smaller*height)\n    right  -= int(percent_smaller*width)\n    left   += int(percent_smaller*width)\n        \n    if height &lt; 100 or width &lt; 100:\n        print(\"Error: squareUp: bottom:\", bottom, \"top:\", top)\n        print(\"Error: squareUp: right:\", right, \"left:\", left)\n        return img\n    \n    return img[top:bottom, left:right]\n```\nhas trouble to deal with some private test picture.\nAny team used these 2 function or some similar functions might have a heart break trouble.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 621762,
      "author_name": "gzuidhof",
      "author_url": "",
      "post_date": "09/08/2019 23:00:50",
      "content": "<p>The submission.csv you can see only contains data from the public leaderboard set, so you only made predictions on that set.</p>",
      "votes": null,
      "replies": [
        {
          "id": 621764,
          "author_name": "httpwwwfszyc",
          "author_url": "",
          "post_date": "09/08/2019 23:03:42",
          "content": "<p>But that should be no difference at public LB. Or you mean I should use test.csv instead of sample_submission.csv?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 621782,
          "author_name": "gzuidhof",
          "author_url": "",
          "post_date": "09/09/2019 00:17:36",
          "content": "<p>Ah I see, then it is not explained by that, I'm not sure then </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 621800,
      "author_name": "httpwwwfszyc",
      "author_url": "",
      "post_date": "09/09/2019 00:53:54",
      "content": "<p>findout the reason:\nthese 2 function to crop: \n```python\ndef resize_images(img, desired_size = 1024): <br>\n    img = cv2.copyMakeBorder(img,10,10,10,10,cv2.BORDER_CONSTANT,value=[0,0,0])\n    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\n    ret,gray = cv2.threshold(gray,10,255,cv2.THRESH_BINARY)</p>\n\n<pre><code>contours,hierarchy = cv2.findContours(gray,\n                                      cv2.RETR_EXTERNAL,\n                                      cv2.CHAIN_APPROX_SIMPLE)\ncontours = max(contours, key=cv2.contourArea)\nx,y,w,h = cv2.boundingRect(contours)\n\nif w&amp;gt;200 and h&amp;gt;200:\n    new_img = img[y:y+h,x:x+w]\n    height, width, _= new_img.shape\n\n    if max([height, width]) &amp;gt; desired_size:\n        ratio = float(desired_size/max([height, width]))\n        new_img = cv2.resize(new_img, \n                             tuple([int(width*ratio), int(height*ratio)]), \n                             interpolation = cv2.INTER_CUBIC)\n\n    return new_img\nelse:\n    print(f'No bounding for {name}')\n    return new_img\n</code></pre>\n\n<p><code>\nand\n</code>python\ndef crop(gray, img, percent_smaller):</p>\n\n<pre><code>thresh = 8\n\ntop    = 0\nleft   = 0\nbottom = gray.shape[0] - 1\nright  = gray.shape[1] - 1\n\n# work in from the top and bottom along the middle collumn\nmiddleCol = gray[:, int(gray.shape[1]/2)] &amp;gt; thresh\nwhile middleCol[top] == 0:\n    top += 1\nwhile middleCol[bottom] == 0:\n    bottom -= 1\n\n# work in from the sides along the middle row\nmiddleRow = gray[int(gray.shape[0]/2)] &amp;gt; thresh\nwhile middleRow[left] == 0:\n    left += 1\nwhile middleRow[right] == 0:\n    right -= 1\n\nheight = bottom - top\nwidth  = right - left\n\nbottom -= int(percent_smaller*height)\ntop    += int(percent_smaller*height)\nright  -= int(percent_smaller*width)\nleft   += int(percent_smaller*width)\n\nif height &amp;lt; 100 or width &amp;lt; 100:\n    print(\"Error: squareUp: bottom:\", bottom, \"top:\", top)\n    print(\"Error: squareUp: right:\", right, \"left:\", left)\n    return img\n\nreturn img[top:bottom, left:right]\n</code></pre>\n\n<p>```\nhas trouble to deal with some private test picture.\nAny team used these 2 function or some similar functions might have a heart break trouble.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "621758": "After competition ends I want to do some reproducing and experiments. But I find a weird situation:\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2721247%2F0497057948a150f8b90e8cf3f622b14f%2Faptoswrong.bmp?generation=1567982632049414&amp;alt=media)\n\nThe bottom result is what i run the inference kernel. The top result is that I just copy the prediction from the inference kernel and do fast submission. why there is difference in public LB?",
    "621762": "The submission.csv you can see only contains data from the public leaderboard set, so you only made predictions on that set.",
    "621764": "But that should be no difference at public LB. Or you mean I should use test.csv instead of sample_submission.csv?",
    "621782": "Ah I see, then it is not explained by that, I'm not sure then",
    "621800": "findout the reason:\nthese 2 function to crop: \n```python\ndef resize_images(img, desired_size = 1024):  \n    img = cv2.copyMakeBorder(img,10,10,10,10,cv2.BORDER_CONSTANT,value=[0,0,0])\n    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\n    ret,gray = cv2.threshold(gray,10,255,cv2.THRESH_BINARY)\n    \n    contours,hierarchy = cv2.findContours(gray,\n                                          cv2.RETR_EXTERNAL,\n                                          cv2.CHAIN_APPROX_SIMPLE)\n    contours = max(contours, key=cv2.contourArea)\n    x,y,w,h = cv2.boundingRect(contours)\n\n    if w&gt;200 and h&gt;200:\n        new_img = img[y:y+h,x:x+w]\n        height, width, _= new_img.shape\n\n        if max([height, width]) &gt; desired_size:\n            ratio = float(desired_size/max([height, width]))\n            new_img = cv2.resize(new_img, \n                                 tuple([int(width*ratio), int(height*ratio)]), \n                                 interpolation = cv2.INTER_CUBIC)\n            \n        return new_img\n    else:\n        print(f'No bounding for {name}')\n        return new_img\n```\nand\n```python\ndef crop(gray, img, percent_smaller):\n    \n    thresh = 8\n    \n    top    = 0\n    left   = 0\n    bottom = gray.shape[0] - 1\n    right  = gray.shape[1] - 1\n    \n    # work in from the top and bottom along the middle collumn\n    middleCol = gray[:, int(gray.shape[1]/2)] &gt; thresh\n    while middleCol[top] == 0:\n        top += 1\n    while middleCol[bottom] == 0:\n        bottom -= 1\n        \n    # work in from the sides along the middle row\n    middleRow = gray[int(gray.shape[0]/2)] &gt; thresh\n    while middleRow[left] == 0:\n        left += 1\n    while middleRow[right] == 0:\n        right -= 1\n        \n    height = bottom - top\n    width  = right - left\n    \n    bottom -= int(percent_smaller*height)\n    top    += int(percent_smaller*height)\n    right  -= int(percent_smaller*width)\n    left   += int(percent_smaller*width)\n        \n    if height &lt; 100 or width &lt; 100:\n        print(\"Error: squareUp: bottom:\", bottom, \"top:\", top)\n        print(\"Error: squareUp: right:\", right, \"left:\", left)\n        return img\n    \n    return img[top:bottom, left:right]\n```\nhas trouble to deal with some private test picture.\nAny team used these 2 function or some similar functions might have a heart break trouble."
  },
  "source": "meta"
}