【问题标题】:Get ImageNet label for a specific index in the 1000-dimensional output tensor in torch获取torch中1000维输出张量中特定索引的ImageNet标签
【发布时间】:2016-06-02 10:03:43
【问题描述】:

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

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

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

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

【问题讨论】:

  • 这是一个关于存储库的 github 问题的好问题

标签: label torch data-science resnet imagenet


【解决方案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

【讨论】:

    猜你喜欢
    • 2019-12-18
    • 2020-05-11
    • 2019-01-13
    • 2020-06-21
    • 2017-09-11
    • 1970-01-01
    • 2021-10-07
    • 2021-11-12
    • 1970-01-01
    相关资源
    最近更新 更多