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

ReadError: file could not be opened successfully #3

Open
annabechang opened this issue Apr 8, 2023 · 1 comment
Open

ReadError: file could not be opened successfully #3

annabechang opened this issue Apr 8, 2023 · 1 comment

Comments

@annabechang
Copy link

Hi,
I tried to load the ImageNetV2Dataset on both linux and colab, both returned the same error:

! pip install git+https://github.com/modestyachts/ImageNetV2_pytorch

from imagenetv2_pytorch import ImageNetV2Dataset
from torch.utils.data import DataLoader

Collecting git+https://github.com/modestyachts/ImageNetV2_pytorch
Cloning https://github.com/modestyachts/ImageNetV2_pytorch to /tmp/pip-req-build-mjyllfja
Running command git clone --filter=blob:none --quiet https://github.com/modestyachts/ImageNetV2_pytorch /tmp/pip-req-build-mjyllfja
Resolved https://github.com/modestyachts/ImageNetV2_pytorch to commit 9017469
Preparing metadata (setup.py) ... done

images = ImageNetV2Dataset(transform=preprocess)

Extracting....
---------------------------------------------------------------------------
ReadError                                 Traceback (most recent call last)
Cell In[19], line 1
----> 1 images = ImageNetV2Dataset(transform=preprocess)

File ~/.conda/envs/py38/lib/python3.8/site-packages/imagenetv2_pytorch/ImageNetV2_dataset.py:82, in ImageNetV2Dataset.__init__(self, variant, transform, location)
     80         assert False, f"Downloading from {URLS[variant]} failed"
     81 print("Extracting....")
---> 82 tarfile.open(self.tar_root).extractall(f"{location}")
     83 shutil.move(f"{location}/{FNAMES[variant]}", self.dataset_root)
     84 self.fnames = list(self.dataset_root.glob("**/*.jpeg"))

File ~/.conda/envs/py38/lib/python3.8/tarfile.py:1608, in TarFile.open(cls, name, mode, fileobj, bufsize, **kwargs)
   1606                 fileobj.seek(saved_pos)
   1607             continue
-> 1608     raise ReadError("file could not be opened successfully")
   1610 elif ":" in mode:
   1611     filemode, comptype = mode.split(":", 1)

ReadError: file could not be opened successfully

@shionhonda
Copy link

You can just try re-installing the package. The problem is solved in the current version!

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