Detectron2: SizeMismatchError from check_image_size

Created on 1 Nov 2019  路  3Comments  路  Source: facebookresearch/detectron2

I'm running the detectron2 tutorial from the Google Colab link. But I'm facing a size mismatch error on the dataloader.

SizeMismatchError: Caught SizeMismatchError in DataLoader worker process 1. Original Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop data = fetcher.fetch(index) File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File "/content/detectron2_repo/detectron2/data/common.py", line 39, in __getitem__ data = self._map_func(self._dataset[cur_idx]) File "/content/detectron2_repo/detectron2/utils/serialize.py", line 23, in __call__ return self._obj(*args, **kwargs) File "/content/detectron2_repo/detectron2/data/dataset_mapper.py", line 76, in __call__ utils.check_image_size(dataset_dict, image) File "/content/detectron2_repo/detectron2/data/detection_utils.py", line 73, in check_image_size "mismatch (W,H), got {}, expect {}".format(image_wh, expected_wh) detectron2.data.detection_utils.SizeMismatchError: mismatch (W,H), got (4128, 2322), expect (2322, 4128)

Update: I realized that PIL was not reading the exif data of my image and auto-rotating it for me. Whereas in cv2.imread(), it will just read the image as it is.

Most helpful comment

All 3 comments

It is not swapped. It means the width and height in your annotation does not agree with what PIL thinks the size of your image is.

Thank you. I had the same problem with 1366cde3b480a15c.jpg in the Open Images 2019 dataset. This image file is rotated by applying exif_transpose.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jinfagang picture jinfagang  路  3Comments

soumik12345 picture soumik12345  路  3Comments

Cold-Winter picture Cold-Winter  路  3Comments

RomRoc picture RomRoc  路  4Comments

choasup picture choasup  路  3Comments