-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
include classification labels in pretrained models #1946
Comments
Unfortunately, the labels that I can find online don't seem to correspond to the ordering used by This is a problem because I cannot independently verify that the model is doing what it's "supposed" to be doing. Can someone please identify a correct set of ImageNet class labels for, e.g., the ImageNet dataset that was used to train the |
I have the same issue, did you solve it? |
Unfortunately, no. |
I think there are two parts here:
Best regards Thomas |
Concerning adding the label info in the model, indeed that would be useful. We just need to consider carefully its API. Possibly this meta data would be linked to the weights and not the model architecture. We plan to tackle model versioning this half, so once this is done we would be able to safely bring this feature. For now here is an example on how to have the labels without downloading the whole dataset: pytorch/hub#175 |
I think we should not let the perfect generic scheme be the enemy of the pragmatic here. |
@t-vi I agree with you and it's been a problem that we haven't added it for so long. Nevertheless given that this is getting traction, it won't take too long to resolve. I was thinking that at this point we should go for a proper solution than a quick patch. We are currently considering that labels along with other meta-data such as trained image size etc, should probably be linked with a specific version of weights as we might on the future offer pretrained weights on various datasets (say coco vs voc). I plan to pick multi-pretrained weight support (#4611) immediately after the first round of primitives of #3911 is completed. |
Maybe until then, at least include a copy-pasteable list of well-aligned categories in some README.md file or docs online. Or maybe hard-code them in a new ImageNet dataset class? (rather than having people to use ImageFolder as in the official ImageNet training example https://github.com/pytorch/examples/blob/master/imagenet/main.py) |
@vadimkantorov I'm literally working on this now. In the meanwhile, we have added a list with the ImageNet categories on hub. You can see examples on how to easily use them for all TorchVision models here: |
This information is now available on the prototype API. Hence I'll close the ticket. |
🚀 Feature
Include classification labels in pretrained models
Motivation
Let's say I want to use one of Torchvision's pre-trained classification networks, e.g.
torchvision.models.alexnet(pretrained=True)
. The AlexNet model has 1,000 outputs which correspond to specific classes (i.e. the ImageNet 1,000 classes). To the best of my knowledge, the class labels (e.g. snail, basketball, banana) are not accessible anywhere in Pytorch or Torchvision.This means that if someone wants to use a pre-trained model, they have to go through the extra steps of finding a file containing a list of the ImageNet 1,000 classes, and then importing and parsing that file to get those class names into their code.
So I think it would be great if the class labels were natively included somewhere in Torchvision.
Pitch
My best idea is to represent the class labels as a list, which would be an attribute of the model:
It may make sense to only define this list when the model is obtained using
pretrained=True
.Alternatives
Additional context
The text was updated successfully, but these errors were encountered: