Closed issamemari closed 4 years ago
Great question, we forgot to add this to the README and will add it later!
You can find the WordNet IDs of the classes here and the WordNet lemmas of the classes here. We have not actually double-checked the files yet, so if you try it out, please let us know if it looks correct!
Thank you for your response @lucasb-eyer. I tried the file you linked and the output seems indeed correct. Here's some code for those interested:
import numpy as np
import torch
from bit.models import ResNetV2
from torchvision import transforms
from PIL import Image
from nltk.corpus import wordnet as wn
wordnet_ids = open("/home/issa/Desktop/wordnet_ids.txt", "r").readlines()
wordnet_ids = [x.strip() for x in wordnet_ids]
wordnet_ids = [int(x[1:]) for x in wordnet_ids]
model = ResNetV2(ResNetV2.BLOCK_UNITS["r101"], width_factor=1, zero_head=False)
model.load_from(np.load("/home/issa/Desktop/BiT-M-R101x1.npz"))
model.eval()
transform_test = transforms.Compose(
[
transforms.Resize(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5]),
]
)
image = Image.open("/home/issa/Downloads/DSC_0611.jpg")
output = model(transform_test(image).unsqueeze(0))[0]
for index in torch.argsort(output, descending=True)[:10]:
print(wn.synset_from_pos_and_offset('n', wordnet_ids[int(index)]))
Great, thank you for the update and the code example!
Great question, we forgot to add this to the README and will add it later!
You can find the WordNet IDs of the classes here and the WordNet lemmas of the classes here. We have not actually double-checked the files yet, so if you try it out, please let us know if it looks correct!
Hi,
I checked the file provided, but it seems it does not contain all label in imagenet. For example, "n11738203", "European pasqueflower, Pulsatilla vulgaris, Anemone plusatilla" is not in the list
Great question, we forgot to add this to the README and will add it later! You can find the WordNet IDs of the classes here and the WordNet lemmas of the classes here. We have not actually double-checked the files yet, so if you try it out, please let us know if it looks correct!
Hi,
I checked the file provided, but it seems it does not contain all label in imagenet. For example, "n11738203", "European pasqueflower, Pulsatilla vulgaris, Anemone plusatilla" is not in the list
Hi, have you solve this problem?
Hi! Can you please just put the text file with 21841 classes and lines. Current file has 21843 lines instead!
Please remove the line 9206 and 15028 in both lemma and id files. line 9206 and line 15028 must be omitted in both files. Then you can use them comfortably. If you do not do that after class 9204 you will receive the wrong answer.
Hi there! I would like to use one of the ImageNet-21k pre-trained models as is, without fine tuning. Where can I find the mapping between output indices and class names?