Skip to content

For anyone who would like to use this with torchvision #1

@Surayuth

Description

@Surayuth

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions