当前位置: 首页>>代码示例>>Python>>正文


Python string_int_label_map_pb2.StringIntLabelMap方法代码示例

本文整理汇总了Python中string_int_label_map_pb2.StringIntLabelMap方法的典型用法代码示例。如果您正苦于以下问题:Python string_int_label_map_pb2.StringIntLabelMap方法的具体用法?Python string_int_label_map_pb2.StringIntLabelMap怎么用?Python string_int_label_map_pb2.StringIntLabelMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在string_int_label_map_pb2的用法示例。


在下文中一共展示了string_int_label_map_pb2.StringIntLabelMap方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_labelmap

# 需要导入模块: import string_int_label_map_pb2 [as 别名]
# 或者: from string_int_label_map_pb2 import StringIntLabelMap [as 别名]
def load_labelmap(path):
  """Loads label map proto.

  Args:
    path: path to StringIntLabelMap proto text file.
  Returns:
    a StringIntLabelMapProto
  """
  with tf.gfile.GFile(path, 'r') as fid:
    label_map_string = fid.read()
    label_map = string_int_label_map_pb2.StringIntLabelMap()
    try:
      text_format.Merge(label_map_string, label_map)
    except text_format.ParseError:
      label_map.ParseFromString(label_map_string)
  _validate_label_map(label_map)
  return label_map 
开发者ID:DLR-RM,项目名称:AugmentedAutoencoder,代码行数:19,代码来源:label_map_util.py

示例2: load_labelmap

# 需要导入模块: import string_int_label_map_pb2 [as 别名]
# 或者: from string_int_label_map_pb2 import StringIntLabelMap [as 别名]
def load_labelmap(path):
  """Loads label map proto.

  Args:
    path: path to StringIntLabelMap proto text file.
  Returns:
    a StringIntLabelMapProto
  """
  with tf.gfile.GFile(path, 'r') as fid:
    label_map_string = fid.read()
    label_map = string_int_label_map_pb2.StringIntLabelMap()
    try:
      text_format.Merge(label_map_string, label_map)
    except text_format.ParseError:
      label_map.ParseFromString(label_map_string)
  return label_map 
开发者ID:KleinYuan,项目名称:tf-object-detection,代码行数:18,代码来源:label_map_util.py

示例3: _validate_label_map

# 需要导入模块: import string_int_label_map_pb2 [as 别名]
# 或者: from string_int_label_map_pb2 import StringIntLabelMap [as 别名]
def _validate_label_map(label_map):
  """Checks if a label map is valid.

  Args:
    label_map: StringIntLabelMap to validate.

  Raises:
    ValueError: if label map is invalid.
  """
  for item in label_map.item:
    if item.id < 1:
      raise ValueError('Label map ids should be >= 1.') 
开发者ID:DLR-RM,项目名称:AugmentedAutoencoder,代码行数:14,代码来源:label_map_util.py

示例4: create_category_index_from_labelmap

# 需要导入模块: import string_int_label_map_pb2 [as 别名]
# 或者: from string_int_label_map_pb2 import StringIntLabelMap [as 别名]
def create_category_index_from_labelmap(label_map_path):
  """Reads a label map and returns a category index.

  Args:
    label_map_path: Path to `StringIntLabelMap` proto text file.

  Returns:
    A category index, which is a dictionary that maps integer ids to dicts
    containing categories, e.g.
    {1: {'id': 1, 'name': 'dog'}, 2: {'id': 2, 'name': 'cat'}, ...}
  """
  label_map = load_labelmap(label_map_path)
  max_num_classes = max(item.id for item in label_map.item)
  categories = convert_label_map_to_categories(label_map, max_num_classes)
  return create_category_index(categories) 
开发者ID:DLR-RM,项目名称:AugmentedAutoencoder,代码行数:17,代码来源:label_map_util.py

示例5: _validate_label_map

# 需要导入模块: import string_int_label_map_pb2 [as 别名]
# 或者: from string_int_label_map_pb2 import StringIntLabelMap [as 别名]
def _validate_label_map(label_map):
  """Checks if a label map is valid.

  Args:
    label_map: StringIntLabelMap to validate.

  Raises:
    ValueError: if label map is invalid.
  """
  for item in label_map.item:
    if item.id < 0:
      raise ValueError('Label map ids should be >= 0.')
    if (item.id == 0 and item.name != 'background' and
        item.display_name != 'background'):
      raise ValueError('Label map id 0 is reserved for the background label') 
开发者ID:ucloud,项目名称:uai-sdk,代码行数:17,代码来源:label_map_util.py


注:本文中的string_int_label_map_pb2.StringIntLabelMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。