{
  "id": 503090,
  "title": "Non-RGB images in testset?",
  "url": "/competitions/image-matching-challenge-2024/discussion/503090",
  "author_name": "",
  "post_date": "2024-05-16T03:36:34.398087200Z",
  "votes": 4,
  "comment_count": 1,
  "views": 0,
  "content": "<p>My submissions failed when I load images with PIL like below:</p>\n<pre><code>tfm = torchvision.transforms.Compose([\n    torchvision.transforms.Resize(input_size),\n    torchvision.transforms.ToTensor(),\n    torchvision.transforms.Normalize(mean, std)\n])\n\n torch.inference_mode():\n        image = Image.(img_path)\n        x = tfm(image).unsqueeze().to(DEVICE)\n</code></pre>\n<p>However, when I moved to kornia, the exception didn't occur.</p>\n<pre><code>tfm = torchvision.transforms.Normalize(mean, std)\n\n torch.inference_mode():\n        image = K.io.load_image(img_path, K.io.ImageLoadType.RGB32)[]\n        x = K.geometry.transform.resize(image, input_size)\n        x = tfm(x).to(DEVICE)\n</code></pre>\n<p>Does anyone know what type of images will break the former implementation?</p>",
  "messages": [
    {
      "id": "2815713",
      "postDate": "05/16/2024 03:36:34",
      "content": "<p>My submissions failed when I load images with PIL like below:</p>\n<pre><code>tfm = torchvision.transforms.Compose([\n    torchvision.transforms.Resize(input_size),\n    torchvision.transforms.ToTensor(),\n    torchvision.transforms.Normalize(mean, std)\n])\n\n torch.inference_mode():\n        image = Image.(img_path)\n        x = tfm(image).unsqueeze().to(DEVICE)\n</code></pre>\n<p>However, when I moved to kornia, the exception didn't occur.</p>\n<pre><code>tfm = torchvision.transforms.Normalize(mean, std)\n\n torch.inference_mode():\n        image = K.io.load_image(img_path, K.io.ImageLoadType.RGB32)[]\n        x = K.geometry.transform.resize(image, input_size)\n        x = tfm(x).to(DEVICE)\n</code></pre>\n<p>Does anyone know what type of images will break the former implementation?</p>",
      "rawMarkdown": "My submissions failed when I load images with PIL like below:\n\n```python\ntfm = torchvision.transforms.Compose([\n    torchvision.transforms.Resize(input_size),\n    torchvision.transforms.ToTensor(),\n    torchvision.transforms.Normalize(mean, std)\n])\n\nwith torch.inference_mode():\n        image = Image.open(img_path)\n        x = tfm(image).unsqueeze(0).to(DEVICE)\n```\n\nHowever, when I moved to kornia, the exception didn't occur.\n\n```python\ntfm = torchvision.transforms.Normalize(mean, std)\n\nwith torch.inference_mode():\n        image = K.io.load_image(img_path, K.io.ImageLoadType.RGB32)[None]\n        x = K.geometry.transform.resize(image, input_size)\n        x = tfm(x).to(DEVICE)\n```\n\nDoes anyone know what type of images will break the former implementation?",
      "votes": null
    },
    {
      "id": "2816880",
      "postDate": "05/16/2024 15:18:49",
      "content": "<p>I believe the problem also occurs if you just use the full trainingset….not sure if it is BW image or other type of image..different channels.</p>\n<p>But solved it by not using PIL. Didn't really investigate it further though. </p>",
      "rawMarkdown": "I believe the problem also occurs if you just use the full trainingset....not sure if it is BW image or other type of image..different channels.\n\nBut solved it by not using PIL. Didn't really investigate it further though.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2816880,
      "author_name": "rsmits",
      "author_url": "",
      "post_date": "05/16/2024 15:18:49",
      "content": "<p>I believe the problem also occurs if you just use the full trainingset….not sure if it is BW image or other type of image..different channels.</p>\n<p>But solved it by not using PIL. Didn't really investigate it further though. </p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2815713": "My submissions failed when I load images with PIL like below:\n\n```python\ntfm = torchvision.transforms.Compose([\n    torchvision.transforms.Resize(input_size),\n    torchvision.transforms.ToTensor(),\n    torchvision.transforms.Normalize(mean, std)\n])\n\nwith torch.inference_mode():\n        image = Image.open(img_path)\n        x = tfm(image).unsqueeze(0).to(DEVICE)\n```\n\nHowever, when I moved to kornia, the exception didn't occur.\n\n```python\ntfm = torchvision.transforms.Normalize(mean, std)\n\nwith torch.inference_mode():\n        image = K.io.load_image(img_path, K.io.ImageLoadType.RGB32)[None]\n        x = K.geometry.transform.resize(image, input_size)\n        x = tfm(x).to(DEVICE)\n```\n\nDoes anyone know what type of images will break the former implementation?",
    "2816880": "I believe the problem also occurs if you just use the full trainingset....not sure if it is BW image or other type of image..different channels.\n\nBut solved it by not using PIL. Didn't really investigate it further though."
  },
  "source": "meta"
}