我想按原样使用https://tfhub.dev/google/imagenet/inception_v3/classification/1
模块,以使用原始标签集进行推断(如果仅出于其他原因,除非要在修改之前验证我是否可以正常工作)。
我需要一种将输出logit映射回英语的方法。此示例https://github.com/tensorflow/models/blob/master/tutorials/image/imagenet/classify_image.py显示了与检查点文件打包在一起的英语映射。 docker hub上版本的检查点文件没有相似的映射(我可以找到)http://download.tensorflow.org/models/inception_v3_2016_08_28.tar.gz。
如何将tensorflow集线器模型的输出logit映射回英语?
答案 0 :(得分:1)
在深入研究tfslim模型源之后,我发现了一些实用程序。
但是,本质上是:
from datasets import imagenet
# ^ this module does not exist in a package repo as far as I can tell.
# I just manually downloaded it and its dependencies from the above repo.
...
names = imagenet.create_readable_names_for_imagenet_labels()
print('Probability %0.2f%% => [%s]' % (probabilities[index] * 100, names[index]))