Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
catch and ignore potential exif transpose bug (#361)
Summary: There is a bug in Pillow not yet fixed when exif-transposing images: python-pillow/Pillow#3973 and this can crash the whole training, this PR is to catch the bug and ignore and use the image as is I believe that if the exif data was valuable for the user, he will check before hand that they are correct, so this PR should not impact anything meaniningfull error to be fixed: ``` Original Traceback (most recent call last): File "/miniconda/envs/sterblue/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop data = fetcher.fetch(index) File "/miniconda/envs/sterblue/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/miniconda/envs/sterblue/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File "/miniconda/envs/sterblue/lib/python3.7/site-packages/detectron2/data/common.py", line 39, in __getitem__ data = self._map_func(self._dataset[cur_idx]) File "/miniconda/envs/sterblue/lib/python3.7/site-packages/detectron2/data/dataset_mapper.py", line 74, in __call__ image = utils.read_image(dataset_dict["file_name"], format=self.img_format) File "/miniconda/envs/sterblue/lib/python3.7/site-packages/detectron2/data/detection_utils.py", line 49, in read_image image = ImageOps.exif_transpose(image) File "/miniconda/envs/sterblue/lib/python3.7/site-packages/PIL/ImageOps.py", line 549, in exif_transpose transposed_image.info["exif"] = exif.tobytes() File "/miniconda/envs/sterblue/lib/python3.7/site-packages/PIL/Image.py", line 3213, in tobytes return b"Exif\x00\x00" + head + ifd.tobytes(offset) File "/miniconda/envs/sterblue/lib/python3.7/site-packages/PIL/TiffImagePlugin.py", line 837, in tobytes count = len(data) TypeError: object of type 'int' has no len() ``` Pull Request resolved: facebookresearch/detectron2#361 Differential Revision: D18630767 Pulled By: ppwwyyxx fbshipit-source-id: 79ec76454ee853a2dbd82c750071b69ff535df53
- Loading branch information