Skip to content

Meta file not found or corrupted. #1645

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

Closed
Esaada opened this issue Dec 7, 2019 · 4 comments
Closed

Meta file not found or corrupted. #1645

Esaada opened this issue Dec 7, 2019 · 4 comments

Comments

@Esaada
Copy link

Esaada commented Dec 7, 2019

🐛 Bug

To Reproduce

Steps to reproduce the behavior:

import torchvision.datasets as datasets
input_transform = None

imagenet = datasets.ImageNet("path2imagenet", split="val", transform=input_transform, target_transform=None, download=False)

Gives error:

Traceback (most recent call last):
File "test_imagenet.py", line 4, in
imagenet = datasets.ImageNet("path2imagenet", split="val", transform=input_transform, target_transform=None, download=False)
File "/usr/local/lib/python3.6/dist-packages/torchvision/datasets/imagenet.py", line 56, in init
wnid_to_classes = self._load_meta_file()[0]
File "/usr/local/lib/python3.6/dist-packages/torchvision/datasets/imagenet.py", line 108, in _load_meta_file
"You can use download=True to create it.")
RuntimeError: ('Meta file not found or corrupted.', 'You can use download=True to create it.')

Expected behavior

Expected behavior? load ImageNet and not break.

Environment

Collecting environment information...
PyTorch version: 1.2.0
Is debug build: No
CUDA used to build PyTorch: 10.0.130

OS: Ubuntu 18.04.2 LTS
GCC version: (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.0
CMake version: version 3.10.2

Python version: 3.6
Is CUDA available: Yes
CUDA runtime version: Could not collect
GPU models and configuration:
GPU 0: TITAN Xp
GPU 1: TITAN Xp
GPU 2: TITAN Xp
GPU 3: TITAN Xp

Nvidia driver version: 418.67
cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.5.0

Versions of relevant libraries:
[pip3] numpy==1.17.4
[pip3] torch==1.2.0
[pip3] torchvision==0.4.0

Additional context

I tried download=true, didn't work, but this doesn't matter since I don't want to download the dataset as I already have one.
Thanks.

@pmeier
Copy link
Collaborator

pmeier commented Dec 7, 2019

For a description of what the meta.bin file is, see my comment in #1646

To create it in torchvision==0.4.0 you need to place the devkit archive in the root folder and set download=True when instantiating the ImageNet dataset. Basically this section of the download code has to be executed:

if not check_integrity(self.meta_file):
tmp_dir = tempfile.mkdtemp()
archive_dict = ARCHIVE_DICT['devkit']
download_and_extract_archive(archive_dict['url'], self.root,
extract_root=tmp_dir,
md5=archive_dict['md5'])
devkit_folder = _splitexts(os.path.basename(archive_dict['url']))[0]
meta = parse_devkit(os.path.join(tmp_dir, devkit_folder))
self._save_meta_file(*meta)
shutil.rmtree(tmp_dir)

Of course you can also perform these steps manually to create the meta file.

@zhangyizhong17
Copy link

The same error occurred in my code. I was trying to use the torchvision to load the imagenet datasets downloaded by myself. The key problem is that the format of the self downloaded datasets do not match the given datasets. We have to make our own meta.bin by ourselves just like the one provided in the package.

@fmassa
Copy link
Member

fmassa commented Dec 10, 2019

We will be soon releasing a new version of torchvision, which will fix this error for you.

Alternatively, you can install torchvision from a nightly release.

@datumbox
Copy link
Contributor

datumbox commented Jan 6, 2021

This issue appears to be stale, so I'm closing it. If you think it should remain open, feel free to reopen it.

@datumbox datumbox closed this as completed Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants