Lemma implementaiton examples
Are there any examples available for implementing inference for this model, with label descriptions? I found ImageNetInfo in the source code and gave that a try:
indices = top5_class_indices.cpu().numpy()
subset = infer_imagenet_subset(model)
info = ImageNetInfo(subset=subset)
for index in indices[0]:
print(info.index_to_description(index))
And this seems to be close to what I need, but the id2label set that it uses doesn't seem to line up with the actual indexes. The output I get for the example beignets image:
homo, man, human being, human
bird
world, human race, humanity, humankind, human beings, humans, mankind, man
equipment
animal, animate being, beast, brute, creature, fauna
I assume right now that I'm just using this wrong, so I'd love an example if one is available. I also tried building an id2label dict from huggingface/label-files
repo_id = "huggingface/label-files"
filename = "imagenet-22k-id2label.json"
id2label = json.load(open(hf_hub_download(repo_id, filename, repo_type="dataset"), "r"))
id2label = {int(k): v for k, v in id2label.items()}
But this yielded identical results
@cerzol you can see the timm API inference code that's used by the classification widget here: https://github.com/huggingface/api-inference-community/blob/main/docker_images/timm/app/pipelines/image_classification.py
It uses internal timm imagenet mappings since having redundant 22k line maps for every timm model seemed pointless when the variations are limited.