ImageNetV2 icon indicating copy to clipboard operation
ImageNetV2 copied to clipboard

generate_class_info.py uses incorrect constructor for ImageNetData

Open mckinziebrandon opened this issue 3 years ago • 4 comments

Hello, I'm trying to get the mapping from class labels to IDs, and presumably this is done by running python generate_class_info_file.py from within the code directory (please let me know if this is wrong).

Upon running this, I hit the following error:

Traceback (most recent call last):
  File "generate_class_info_file.py", line 8, in <module>
    imgnet = imagenet.ImageNetData(load_class_info=False)
TypeError: __init__() got an unexpected keyword argument 'load_class_info'

Indeed, imagenet.ImageNetData does not have a kwarg called "load_class_info". Perhaps this code is outdated?

If there is an easier way for me to simply get the map from label IDs to the original class name strings, please let me know. Thank you!

mckinziebrandon avatar Aug 10 '22 14:08 mckinziebrandon

I assumed I could also just use the original mapping from ImageNet2012, but wanted to verify / poke around a bit.

mckinziebrandon avatar Aug 10 '22 14:08 mckinziebrandon

Ah, looks like I can just use class_info.json directly.

Also, the S3 bucket was hanging for me, FWIW, when I tried just initializing ImageNetData() myself in a notebook. My aws/cli credentials should be configured properly.

mckinziebrandon avatar Aug 10 '22 14:08 mckinziebrandon

Ok, I'm probably doing something dumb here but neither the class_info.json nor the public imagenet label synset mapping seem to correspond to the integer IDs returned when using datasets.ImageFolder('imagenetv2-top-images-format-val').

Is there another mapping I need to go from the index directory name in your dataset files to the class ID for imagenet? There are 1000 folders here so I (perhaps incorrectly) assumed that directory with name i corresponded to imagenet class with label id i.

image

mckinziebrandon avatar Aug 10 '22 14:08 mckinziebrandon

Ok, this comment in a previous issue resolved the erroneous mapping issues: https://github.com/modestyachts/ImageNetV2/issues/6#issuecomment-797383723

Anyway, the constructor is still outdated as mentioned in my original post, sorry for going off on an unrelated tangent 🙂

mckinziebrandon avatar Aug 10 '22 14:08 mckinziebrandon

Sorry you will need to use the pytorch dataloader here: https://github.com/modestyachts/ImageNetV2_pytorch to load the dataset. We don't have compatibility with the ImageFolder dataset currently.

Vaishaal avatar Oct 06 '22 03:10 Vaishaal