pytorch / vision

Datasets, Transforms and Models specific to Computer Vision
https://pytorch.org/vision
BSD 3-Clause "New" or "Revised" License
16.3k stars 6.96k forks source link

What is the relationship between the output label of pretrained model in model zoo and wordnet synset id? #484

Open imkzh opened 6 years ago

imkzh commented 6 years ago

we can easily access pytorch pre-trained model like VGG, AlexNet and SqueezeNet by

import torchvision 
torchvision.models.vgg16(pretrained=True)

can anyone point out what's the relationship between the output label(index of maximum output value) and the actual category?

i downloaded ILSVRC2012_devkit_t12 and got the imagenet id and other metainfo provided by meta.mat, however it seems pre-trained model have some different id. because when i evaluate the network with ILSVRC2012 validation set, it reports 100% error.

Cadene commented 6 years ago

You can find an example here.

You will need two files:

imkzh commented 6 years ago

Thank you for your help, they are exactly what i need, as torchvision modules itself didn't provide any documentations on this.

fmassa commented 6 years ago

I think we should provide somewhere the mapping between the class names and the indices. Not sure if it should be in pytorch/examples or in torchvision. What do you think?

imkzh commented 6 years ago

That's great! i think it will be torchvision to provide those mapping, and pytorch/examples to have some example on it. :grinning: am i too greedy?

fmassa commented 6 years ago

I think this totally make sense to provide this mapping. I'll think about a good way of doing it, maybe making a base class TorchvisionModel, that contains the basic pre-processing parameters that are used for all the models, as well as the image synset.

theoptips commented 5 years ago

+1 would appreciate a model.class method or model.labels kind of like sklearn. Developers can easily see the mapping between output labels and index. May be this feature already exists? Would love to know how to do it. Thanks!

NizarTarabay commented 5 years ago

Thank you for your help, they are exactly what i need, as torchvision modules itself didn't provide any documentations on this. How did you manage to make it work, even with these two text files there still a discrepancy between the output predicted labels and the imagenet validation dataset. I am using Squeezenet to predict the validation classes on ILSVRC2012. The pretrained model seems working well, however, the accuracy is 0!

stared commented 5 years ago

I think that class names (i.e. a map idx -> class name) are an integral part of any pre-trained classifier. Would a PR with class names be welcome?