获取火炬中1000维输出张量中特定索引的ImageNet标签

时间:2016-02-20 20:56:13

标签: label torch data-science resnet imagenet

我有a Facebook implementation of the ResNet model前向传球的输出Tensor和猫图像。这是具有分类概率的1000维张量。使用torch.topk我可以在输出张量中获得前5个概率及其索引。现在我想看看那些最可能的索引的人类可读标签。

我在网上搜索了标签列表(显然也称为sysnets)并且只发现了这个: http://image-net.org/challenges/LSVRC/2015/browse-synsets

我将这些标签放在一个文件中,使用行号作为标签索引,当我用两个不同的猫图像运行网络时,我得到了"螺丝刀"作为两者的最佳猜测。如果我按字母顺序对标签文件进行排序,我会得到电影"对于两者。

这似乎是将索引转换为标签的问题,对吧? 所以......问题是: 如何正确地将网络输出张量中的索引映射到Imagenet标签?

1 个答案:

答案 0 :(得分:1)

找到this tutorial on training ConvNets on ImageNet by Dato,最后它包含正确的映射。在此报告以备记录:

{
 0: 'tench, Tinca tinca',
 1: 'goldfish, Carassius auratus',
 2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias',
 3: 'tiger shark, Galeocerdo cuvieri',
 4: 'hammerhead, hammerhead shark',
 5: 'electric ray, crampfish, numbfish, torpedo',
 6: 'stingray',
 7: 'cock',
 8: 'hen',
 9: 'ostrich, Struthio camelus',
 10: 'brambling, Fringilla montifringilla',
 ... [truncated for space]
 990: 'buckeye, horse chestnut, conker',
 991: 'coral fungus',
 992: 'agaric',
 993: 'gyromitra',
 994: 'stinkhorn, carrion fungus',
 995: 'earthstar',
 996: 'hen-of-the-woods, hen of the woods, Polyporus frondosus, Grifola frondosa',
 997: 'bolete',
 998: 'ear, spike, capitulum',
 999: 'toilet tissue, toilet paper, bathroom tissue'
}

此处完整映射:https://gist.github.com/maraoz/388eddec39d60c6d52d4

相关问题