Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIL file open error #12

Closed
ramchandracheke opened this issue Jul 2, 2021 · 2 comments
Closed

PIL file open error #12

ramchandracheke opened this issue Jul 2, 2021 · 2 comments

Comments

@ramchandracheke
Copy link

ramchandracheke commented Jul 2, 2021

Hi,

Thank you for this amazing repo. I am trying to train a model. However, I am getting below error. It seems like, issue with PIL reader.

   data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/work/PixPro/contrast/data/dataset.py", line 261, in __getitem__
    image = self.loader(path)
  File "/work/PixPro/contrast/data/dataset.py", line 219, in default_img_loader
    return pil_loader(path)
  File "/work/PixPro/contrast/data/dataset.py", line 202, in pil_loader
    return img.convert('RGB')
  File "/home/users/conda/envs/PixPro/lib/python3.7/site-packages/PIL/Image.py", line 904, in convert
    self.load()
  File "/home/users/conda/envs/PixPro/lib/python3.7/site-packages/PIL/ImageFile.py", line 228, in load
    seek(offset)
ValueError: seek of closed file

I am using dual gpu setup and I have set the parameters accordingly.

Could you please help me?
Thanks

@xyl3902596
Copy link

xyl3902596 commented Jul 8, 2021

I also met this problem, and I solved it like this:
modified line 199 in dataset.py

with open(path, 'rb') as f:
      img = Image.open(f)

as
img = Image.open(path)

@ramchandracheke
Copy link
Author

Thank you @xyl3902596 . That works. It would be great if these changes are made in main program.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants