{
  "id": 334405,
  "title": "Submission Code?",
  "url": "/competitions/denoising-shabby-pages/discussion/334405",
  "author_name": "",
  "post_date": "2022-07-01T12:33:27.132309200Z",
  "votes": null,
  "comment_count": 3,
  "views": 0,
  "content": "<p>Why are we using random pixel selection code? How does it make a difference?</p>\n<p>` Make_submission.py:<br>\nimport random<br>\nimport os<br>\nimport cv2</p>\n<h6>#</h6>\n<h1>CHANGE THIS</h1>\n<h6>#</h6>\n<p>cleaned_images_dir = OUTPUT_DIR</p>\n<h6>#</h6>\n<h1>DON'T CHANGE ANYTHING BELOW HERE</h1>\n<h6>#</h6>\n<p>def select_pixels(img):<br>\n    y,x = img.shape</p>\n<pre><code>pixels = list()\n\nfor i in range(10000):\n    pixel = (random.randrange(y), random.randrange(x))\n\n    if pixel not in pixels:\n        pixels.append(pixel)\n\nreturn pixels\n</code></pre>\n<p>random.seed(0)<br>\ncleaned_images = sorted(os.listdir(cleaned_images_dir))</p>\n<p>with open(\"submission.csv\", \"w\") as submission_file:<br>\n    submission_file.write(\"id,predicted\\n\")</p>\n<pre><code>filenum = 1\nfor image in cleaned_images:\n\n    img = cv2.imread(\"{}/{}\".format(cleaned_images_dir, image), cv2.IMREAD_GRAYSCALE)\n    pixels = select_pixels(img)\n\n    for pixel in pixels:\n        y,x = pixel\n        submission_file.write(\"{}_{}_{},{}\\n\".format(filenum, y, x, img[y][x]/255.0))\n\n    filenum += 1`\n</code></pre>",
  "messages": [
    {
      "id": "1839462",
      "postDate": "07/01/2022 12:33:27",
      "content": "<p>Why are we using random pixel selection code? How does it make a difference?</p>\n<p>` Make_submission.py:<br>\nimport random<br>\nimport os<br>\nimport cv2</p>\n<h6>#</h6>\n<h1>CHANGE THIS</h1>\n<h6>#</h6>\n<p>cleaned_images_dir = OUTPUT_DIR</p>\n<h6>#</h6>\n<h1>DON'T CHANGE ANYTHING BELOW HERE</h1>\n<h6>#</h6>\n<p>def select_pixels(img):<br>\n    y,x = img.shape</p>\n<pre><code>pixels = list()\n\nfor i in range(10000):\n    pixel = (random.randrange(y), random.randrange(x))\n\n    if pixel not in pixels:\n        pixels.append(pixel)\n\nreturn pixels\n</code></pre>\n<p>random.seed(0)<br>\ncleaned_images = sorted(os.listdir(cleaned_images_dir))</p>\n<p>with open(\"submission.csv\", \"w\") as submission_file:<br>\n    submission_file.write(\"id,predicted\\n\")</p>\n<pre><code>filenum = 1\nfor image in cleaned_images:\n\n    img = cv2.imread(\"{}/{}\".format(cleaned_images_dir, image), cv2.IMREAD_GRAYSCALE)\n    pixels = select_pixels(img)\n\n    for pixel in pixels:\n        y,x = pixel\n        submission_file.write(\"{}_{}_{},{}\\n\".format(filenum, y, x, img[y][x]/255.0))\n\n    filenum += 1`\n</code></pre>",
      "rawMarkdown": "Why are we using random pixel selection code? How does it make a difference?\n\n` Make_submission.py:\nimport random\nimport os\nimport cv2\n\n################################################################################\n# CHANGE THIS\n################################################################################\ncleaned_images_dir = OUTPUT_DIR\n\n################################################################################\n# DON'T CHANGE ANYTHING BELOW HERE\n################################################################################\ndef select_pixels(img):\n    y,x = img.shape\n\n    pixels = list()\n\n    for i in range(10000):\n        pixel = (random.randrange(y), random.randrange(x))\n\n        if pixel not in pixels:\n            pixels.append(pixel)\n\n    return pixels\n\nrandom.seed(0)\ncleaned_images = sorted(os.listdir(cleaned_images_dir))\n\nwith open(\"submission.csv\", \"w\") as submission_file:\n    submission_file.write(\"id,predicted\\n\")\n\n    filenum = 1\n    for image in cleaned_images:\n\n        img = cv2.imread(\"{}/{}\".format(cleaned_images_dir, image), cv2.IMREAD_GRAYSCALE)\n        pixels = select_pixels(img)\n\n        for pixel in pixels:\n            y,x = pixel\n            submission_file.write(\"{}_{}_{},{}\\n\".format(filenum, y, x, img[y][x]/255.0))\n\n        filenum += 1`",
      "votes": null
    },
    {
      "id": "1848839",
      "postDate": "07/09/2022 00:42:37",
      "content": "<p>It should be selecting a same set of random pixels because it is using a same random seed <code>random.seed(0)</code>. I think it will be more memory efficient to select only 10,000 pixels instead of using all pixels. Otherwise, we might getting a very large submission excel file.</p>",
      "rawMarkdown": "It should be selecting a same set of random pixels because it is using a same random seed `random.seed(0)`. I think it will be more memory efficient to select only 10,000 pixels instead of using all pixels. Otherwise, we might getting a very large submission excel file.",
      "votes": null
    },
    {
      "id": "1848863",
      "postDate": "07/09/2022 02:23:40",
      "content": "<p>Great question!</p>\n<p>Firstly, there are limitations to the Kaggle platform (e.g., forcing use of CSVs for all types of data) which make working with image data more challenging.</p>\n<p>Secondly, as <a href=\"https://www.kaggle.com/weisinx7\" target=\"_blank\">@weisinx7</a> mentioned, sampling the pixels in the denoised images is statistically comparable to looking at all the pixels in a given image, so it’s just a more efficient way to evaluate submissions, particularly against a larger set of images.</p>",
      "rawMarkdown": "Great question!\n\nFirstly, there are limitations to the Kaggle platform (e.g., forcing use of CSVs for all types of data) which make working with image data more challenging.\n\nSecondly, as @weisinx7 mentioned, sampling the pixels in the denoised images is statistically comparable to looking at all the pixels in a given image, so it’s just a more efficient way to evaluate submissions, particularly against a larger set of images.",
      "votes": null
    },
    {
      "id": "1850572",
      "postDate": "07/10/2022 13:56:25",
      "content": "<p>Thank you. </p>",
      "rawMarkdown": "Thank you.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1848839,
      "author_name": "weisinx7",
      "author_url": "",
      "post_date": "07/09/2022 00:42:37",
      "content": "<p>It should be selecting a same set of random pixels because it is using a same random seed <code>random.seed(0)</code>. I think it will be more memory efficient to select only 10,000 pixels instead of using all pixels. Otherwise, we might getting a very large submission excel file.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1848863,
      "author_name": "jboarman",
      "author_url": "",
      "post_date": "07/09/2022 02:23:40",
      "content": "<p>Great question!</p>\n<p>Firstly, there are limitations to the Kaggle platform (e.g., forcing use of CSVs for all types of data) which make working with image data more challenging.</p>\n<p>Secondly, as <a href=\"https://www.kaggle.com/weisinx7\" target=\"_blank\">@weisinx7</a> mentioned, sampling the pixels in the denoised images is statistically comparable to looking at all the pixels in a given image, so it’s just a more efficient way to evaluate submissions, particularly against a larger set of images.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1850572,
          "author_name": "deepdreamx",
          "author_url": "",
          "post_date": "07/10/2022 13:56:25",
          "content": "<p>Thank you. </p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1839462": "Why are we using random pixel selection code? How does it make a difference?\n\n` Make_submission.py:\nimport random\nimport os\nimport cv2\n\n################################################################################\n# CHANGE THIS\n################################################################################\ncleaned_images_dir = OUTPUT_DIR\n\n################################################################################\n# DON'T CHANGE ANYTHING BELOW HERE\n################################################################################\ndef select_pixels(img):\n    y,x = img.shape\n\n    pixels = list()\n\n    for i in range(10000):\n        pixel = (random.randrange(y), random.randrange(x))\n\n        if pixel not in pixels:\n            pixels.append(pixel)\n\n    return pixels\n\nrandom.seed(0)\ncleaned_images = sorted(os.listdir(cleaned_images_dir))\n\nwith open(\"submission.csv\", \"w\") as submission_file:\n    submission_file.write(\"id,predicted\\n\")\n\n    filenum = 1\n    for image in cleaned_images:\n\n        img = cv2.imread(\"{}/{}\".format(cleaned_images_dir, image), cv2.IMREAD_GRAYSCALE)\n        pixels = select_pixels(img)\n\n        for pixel in pixels:\n            y,x = pixel\n            submission_file.write(\"{}_{}_{},{}\\n\".format(filenum, y, x, img[y][x]/255.0))\n\n        filenum += 1`",
    "1848839": "It should be selecting a same set of random pixels because it is using a same random seed `random.seed(0)`. I think it will be more memory efficient to select only 10,000 pixels instead of using all pixels. Otherwise, we might getting a very large submission excel file.",
    "1848863": "Great question!\n\nFirstly, there are limitations to the Kaggle platform (e.g., forcing use of CSVs for all types of data) which make working with image data more challenging.\n\nSecondly, as @weisinx7 mentioned, sampling the pixels in the denoised images is statistically comparable to looking at all the pixels in a given image, so it’s just a more efficient way to evaluate submissions, particularly against a larger set of images.",
    "1850572": "Thank you."
  },
  "source": "meta"
}