build_imagenet_data.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:revnet-public 作者: renmengye 项目源码 文件源码
def _build_synset_lookup(imagenet_metadata_file):
  """Build lookup for synset to human-readable label.
  Args:
    imagenet_metadata_file: string, path to file containing mapping from
      synset to human-readable label.
      Assumes each line of the file looks like:
        n02119247    black fox
        n02119359    silver fox
        n02119477    red fox, Vulpes fulva
      where each line corresponds to a unique mapping. Note that each line is
      formatted as <synset>\t<human readable label>.
  Returns:
    Dictionary of synset to human labels, such as:
      'n02119022' --> 'red fox, Vulpes vulpes'
  """
  lines = tf.gfile.FastGFile(imagenet_metadata_file, 'r').readlines()
  synset_to_human = {}
  for l in lines:
    if l:
      parts = l.strip().split('\t')
      assert len(parts) == 2
      synset = parts[0]
      human = parts[1]
      synset_to_human[synset] = human
  return synset_to_human
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号