You need to change the names of class folders (0, 1, 2, ..) to index codes which are specified in the json files.
The example below shows how you could create 'val' dataset using torchvision:
import os
from pathlib import Path
with open('path/to/ImageNet_class_index.json') as f:
d = json.load(f)
root = Path("path/to/ImageNet/val")
for path in root.iterdir():
idx = path.name
new_path = path.parent / d[idx][0]
os.rename(str(path), str(new_path))
Then, you can create imagenet dataset using torchvision by
dataset = ImageNet(root="ImageNet", split="val")
Note that you also need ILSVRC2012_devkit_t12.tar.gz which can be downloaded from the imagenet website.
You need to change the names of class folders (0, 1, 2, ..) to index codes which are specified in the json files.
The example below shows how you could create 'val' dataset using torchvision:
Then, you can create imagenet dataset using torchvision by
dataset = ImageNet(root="ImageNet", split="val")Note that you also need
ILSVRC2012_devkit_t12.tar.gzwhich can be downloaded from the imagenet website.