Mapping between labels and class names for pretrained networks

How do I find the mapping between class names and labels?

I’m using a pretrained network (mobilnet v2) and can get a prediction using pretrained weights using a random image. I then get call argmax of the output to get the label. But I would like to know the name of the label, eg is 654 a plane or a car or something else?

I’ve looked at this post but it does not answer my question


The mapping between class indices and class names is part of the dataset definition, not the model.
Since mobilenet was pretrained on ImageNet, you could search for the class index to name mapping and will find some sources, e.g. here.

Thanks, but how did you get that information?

When I look at the code at github for mobilenet v2

I can’t find the label mapping or which dataset they are using. They are reffering to “imagenet checkpoints”.

One could assume they are using the same data set as in V1 where they are using the ILSVRC-2012-CLS, since they are comparing the accuracy between the nets. But there exist an imagenet2 also right?

Is the exact label mapping defined for all datasets? Or is it possible that one could eg mix the order between the labels and class-names when training the net?

Sorry for these fundamental questions, maybe it’s obvious for you guys…
This seems to be many assumptions from my side and I’m searching for a crystal-clear solution.
I will most certainly step into other datasets and then it’s good to know how to find this type of information.

thanks again for the link.


I’m not sure which dataset Tensorflow uses, but the torchvision models were trained on ImageNet-12 according to this post.