{
  "id": 74284,
  "title": "Dealing with Images of Different Sizes",
  "url": "/competitions/humpback-whale-identification/discussion/74284",
  "author_name": "",
  "post_date": "2018-12-10T23:15:55.696702400Z",
  "votes": 2,
  "comment_count": 3,
  "views": 0,
  "content": "<p>How should we be approaching datasets where different images can have different sizes? </p>",
  "messages": [
    {
      "id": "436774",
      "postDate": "12/10/2018 23:15:55",
      "content": "<p>How should we be approaching datasets where different images can have different sizes? </p>",
      "rawMarkdown": "How should we be approaching datasets where different images can have different sizes?",
      "votes": null
    },
    {
      "id": "436798",
      "postDate": "12/11/2018 00:45:11",
      "content": "<p>I am keeping the same aspect ratio and cropping to maintain fine grained details like the fluke edge, but the dataset has some images that are stretched in the original image, as well...</p>",
      "rawMarkdown": "I am keeping the same aspect ratio and cropping to maintain fine grained details like the fluke edge, but the dataset has some images that are stretched in the original image, as well...",
      "votes": null
    },
    {
      "id": "437541",
      "postDate": "12/12/2018 05:27:32",
      "content": "<p>It depends on the dataset or the ultimate goal of the training. As <a href=\"https://www.kaggle.com/badtyprr\">@Simeon</a> said, in this case, where spatial information in the image could be critical for the task, maybe an approach to take into consideration would be to transform images to maintain the same aspect ratio.</p>\n\n<p>Other approach would be to resize the images to the desired shape (changing the aspect ratio), or randomly cropping them (approach which could be used for data augmentation).</p>\n\n<p>For an initial naive approach, I think the quickest option would be to change the image size to the needed input of your model.</p>",
      "rawMarkdown": "It depends on the dataset or the ultimate goal of the training. As [@Simeon][1] said, in this case, where spatial information in the image could be critical for the task, maybe an approach to take into consideration would be to transform images to maintain the same aspect ratio.\n\nOther approach would be to resize the images to the desired shape (changing the aspect ratio), or randomly cropping them (approach which could be used for data augmentation).\n\nFor an initial naive approach, I think the quickest option would be to change the image size to the needed input of your model.\n\n\n  [1]: https://www.kaggle.com/badtyprr",
      "votes": null
    },
    {
      "id": "444848",
      "postDate": "12/25/2018 01:25:37",
      "content": "<p>Hi Zak <a href=\"/zakraicik\">@zakraicik</a>! I've just upload a <a href=\"https://www.kaggle.com/jhonatansilva31415/the-ultimate-guide-to-image-datasets-in-kaggle\">Kernel</a> to work with the images, but I resized the images then use crop and compose with PyTorch. Something that caused a lot of troubleshooting for me as well was <strong>NOT</strong> looking at the channels, the code I was using didn't take into account for images with shape of <strong>[224,224]</strong> instead of <strong>[224,224,1]</strong>. All RGB images after resize were [224,224,3] . It took sometime to figure it out that the problem was related to some images with different shapes as well. </p>",
      "rawMarkdown": "Hi Zak @zakraicik! I've just upload a [Kernel][1] to work with the images, but I resized the images then use crop and compose with PyTorch. Something that caused a lot of troubleshooting for me as well was **NOT** looking at the channels, the code I was using didn't take into account for images with shape of **[224,224]** instead of **[224,224,1]**. All RGB images after resize were [224,224,3] . It took sometime to figure it out that the problem was related to some images with different shapes as well. \n\n\n  [1]: https://www.kaggle.com/jhonatansilva31415/the-ultimate-guide-to-image-datasets-in-kaggle",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 436798,
      "author_name": "badtyprr",
      "author_url": "",
      "post_date": "12/11/2018 00:45:11",
      "content": "<p>I am keeping the same aspect ratio and cropping to maintain fine grained details like the fluke edge, but the dataset has some images that are stretched in the original image, as well...</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 437541,
      "author_name": "chelus",
      "author_url": "",
      "post_date": "12/12/2018 05:27:32",
      "content": "<p>It depends on the dataset or the ultimate goal of the training. As <a href=\"https://www.kaggle.com/badtyprr\">@Simeon</a> said, in this case, where spatial information in the image could be critical for the task, maybe an approach to take into consideration would be to transform images to maintain the same aspect ratio.</p>\n\n<p>Other approach would be to resize the images to the desired shape (changing the aspect ratio), or randomly cropping them (approach which could be used for data augmentation).</p>\n\n<p>For an initial naive approach, I think the quickest option would be to change the image size to the needed input of your model.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 444848,
      "author_name": "jhonatansilva31415",
      "author_url": "",
      "post_date": "12/25/2018 01:25:37",
      "content": "<p>Hi Zak <a href=\"/zakraicik\">@zakraicik</a>! I've just upload a <a href=\"https://www.kaggle.com/jhonatansilva31415/the-ultimate-guide-to-image-datasets-in-kaggle\">Kernel</a> to work with the images, but I resized the images then use crop and compose with PyTorch. Something that caused a lot of troubleshooting for me as well was <strong>NOT</strong> looking at the channels, the code I was using didn't take into account for images with shape of <strong>[224,224]</strong> instead of <strong>[224,224,1]</strong>. All RGB images after resize were [224,224,3] . It took sometime to figure it out that the problem was related to some images with different shapes as well. </p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "436774": "How should we be approaching datasets where different images can have different sizes?",
    "436798": "I am keeping the same aspect ratio and cropping to maintain fine grained details like the fluke edge, but the dataset has some images that are stretched in the original image, as well...",
    "437541": "It depends on the dataset or the ultimate goal of the training. As [@Simeon][1] said, in this case, where spatial information in the image could be critical for the task, maybe an approach to take into consideration would be to transform images to maintain the same aspect ratio.\n\nOther approach would be to resize the images to the desired shape (changing the aspect ratio), or randomly cropping them (approach which could be used for data augmentation).\n\nFor an initial naive approach, I think the quickest option would be to change the image size to the needed input of your model.\n\n\n  [1]: https://www.kaggle.com/badtyprr",
    "444848": "Hi Zak @zakraicik! I've just upload a [Kernel][1] to work with the images, but I resized the images then use crop and compose with PyTorch. Something that caused a lot of troubleshooting for me as well was **NOT** looking at the channels, the code I was using didn't take into account for images with shape of **[224,224]** instead of **[224,224,1]**. All RGB images after resize were [224,224,3] . It took sometime to figure it out that the problem was related to some images with different shapes as well. \n\n\n  [1]: https://www.kaggle.com/jhonatansilva31415/the-ultimate-guide-to-image-datasets-in-kaggle"
  },
  "source": "meta"
}