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


Python dataset_utils.bytes_feature方法代码示例

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


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

示例1: _convert_to_example

# 需要导入模块: from datasets import dataset_utils [as 别名]
# 或者: from datasets.dataset_utils import bytes_feature [as 别名]
def _convert_to_example(filename, image_data, height, width, current_file_info, common_info):
    colorspace = 'RGB'
    channels = 3
    image_format = 'JPEG'

    example = tf.train.Example(features=tf.train.Features(feature={
      'image/height': dataset_utils.int64_feature(height),
      'image/width': dataset_utils.int64_feature(width),
      'image/colorspace': dataset_utils.bytes_feature(colorspace),
      'image/channels': dataset_utils.int64_feature(channels),
      'image/format': dataset_utils.bytes_feature(image_format),
      'image/filename': dataset_utils.bytes_feature(os.path.basename(filename)),
      'image/encoded': dataset_utils.bytes_feature(image_data)}))
    return example 
开发者ID:jerryli27,项目名称:TwinGAN,代码行数:16,代码来源:convert_celeba.py

示例2: _convert_to_example

# 需要导入模块: from datasets import dataset_utils [as 别名]
# 或者: from datasets.dataset_utils import bytes_feature [as 别名]
def _convert_to_example(filename, image_buffer, height, width, current_file_info, common_info):
    """Build an Example proto for an example.

    Args:
      filename: string, path to an image file, e.g., '/path/to/example.JPG'
      image_buffer: string, JPEG encoding of RGB image
      height: integer, image height in pixels
      width: integer, image width in pixels
      current_file_info:  equivalent to label: integer, identifier for the ground truth for the network
      common_info: a list of tags with format: ('type', 'ambiguous', 'count', 'name', 'id')

    Returns:
      Example proto
    """
    colorspace = 'RGB'
    channels = 3
    image_format = 'JPEG'
    human_readable_tags = DanbooruDataConverter._tag_to_human_readable(current_file_info,common_info)

    example = tf.train.Example(features=tf.train.Features(feature={
      'image/height': dataset_utils.int64_feature(height),
      'image/width': dataset_utils.int64_feature(width),
      'image/colorspace': dataset_utils.bytes_feature(colorspace),
      'image/channels': dataset_utils.int64_feature(channels),
      'image/class/label': dataset_utils.int64_feature(current_file_info),
      'image/class/text': dataset_utils.bytes_feature(human_readable_tags),
      'image/format': dataset_utils.bytes_feature(image_format),
      'image/filename': dataset_utils.bytes_feature(os.path.basename(filename)),
      'image/encoded': dataset_utils.bytes_feature(image_buffer)}))
    return example 
开发者ID:jerryli27,项目名称:TwinGAN,代码行数:32,代码来源:convert_danbooru_data.py

示例3: _convert_to_example

# 需要导入模块: from datasets import dataset_utils [as 别名]
# 或者: from datasets.dataset_utils import bytes_feature [as 别名]
def _convert_to_example(filename, image_data, height, width, current_file_info, common_info):
    colorspace = 'RGB'
    channels = 3
    image_format = 'JPEG'

    example = tf.train.Example(features=tf.train.Features(feature={
      'image/colorspace': dataset_utils.bytes_feature(colorspace),
      'image/channels': dataset_utils.int64_feature(channels),
      'image/format': dataset_utils.bytes_feature(image_format),
      'image/filename': dataset_utils.bytes_feature(os.path.basename(filename)),
      'image/encoded': dataset_utils.bytes_feature(image_data),
    }))
    return example 
开发者ID:jerryli27,项目名称:TwinGAN,代码行数:15,代码来源:convert_image_only.py

示例4: _convert_to_example

# 需要导入模块: from datasets import dataset_utils [as 别名]
# 或者: from datasets.dataset_utils import bytes_feature [as 别名]
def _convert_to_example(image_data, labels, labels_text, bboxes, shape,
                        difficult, truncated):
    """Build an Example proto for an image example.

    Args:
      image_data: string, JPEG encoding of RGB image;
      labels: list of integers, identifier for the ground truth;
      labels_text: list of strings, human-readable labels;
      bboxes: list of bounding boxes; each box is a list of integers;
          specifying [xmin, ymin, xmax, ymax]. All boxes are assumed to belong
          to the same label as the image label.
      shape: 3 integers, image shapes in pixels.
    Returns:
      Example proto
    """
    xmin = []
    ymin = []
    xmax = []
    ymax = []
    for b in bboxes:
        assert len(b) == 4
        # pylint: disable=expression-not-assigned
        [l.append(point) for l, point in zip([ymin, xmin, ymax, xmax], b)]
        # pylint: enable=expression-not-assigned

    image_format = b'JPEG'
    example = tf.train.Example(features=tf.train.Features(feature={
            'image/height': int64_feature(shape[0]),
            'image/width': int64_feature(shape[1]),
            'image/channels': int64_feature(shape[2]),
            'image/shape': int64_feature(shape),
            'image/object/bbox/xmin': float_feature(xmin),
            'image/object/bbox/xmax': float_feature(xmax),
            'image/object/bbox/ymin': float_feature(ymin),
            'image/object/bbox/ymax': float_feature(ymax),
            'image/object/bbox/label': int64_feature(labels),
            'image/object/bbox/label_text': bytes_feature(labels_text),
            'image/object/bbox/difficult': int64_feature(difficult),
            'image/object/bbox/truncated': int64_feature(truncated),
            'image/format': bytes_feature(image_format),
            'image/encoded': bytes_feature(image_data)}))
    return example 
开发者ID:Zehaos,项目名称:MobileNet,代码行数:44,代码来源:pascalvoc_to_tfrecords.py

示例5: _process_image

# 需要导入模块: from datasets import dataset_utils [as 别名]
# 或者: from datasets.dataset_utils import bytes_feature [as 别名]
def _process_image(directory, split, name):
    # Read the image file.
    filename = os.path.join(directory, 'image_2', name + '.png')
    image_data = tf.gfile.FastGFile(filename, 'r').read()

    # Get shape
    img = cv2.imread(filename)
    shape = np.shape(img)

    label_list = []
    type_list = []

    bbox_x1_list = []
    bbox_y1_list = []
    bbox_x2_list = []
    bbox_y2_list = []


    # If 'test' split, skip annotations
    if re.findall(r'train', split):
      # Read the txt annotation file.
      filename = os.path.join(directory, 'label_2', name + '.txt')
      with open(filename) as anno_file:
        objects = anno_file.readlines()

      for object in objects:
          obj_anno = object.split(' ')
          type_txt = obj_anno[0].encode('ascii')
          if type_txt in CLASSES:
            label_list.append(CLASSES[type_txt])
            type_list.append(type_txt)

            # Bounding Box
            bbox_x1 = float(obj_anno[4])
            bbox_y1 = float(obj_anno[5])
            bbox_x2 = float(obj_anno[6])
            bbox_y2 = float(obj_anno[7])
            bbox_x1_list.append(bbox_x1)
            bbox_y1_list.append(bbox_y1)
            bbox_x2_list.append(bbox_x2)
            bbox_y2_list.append(bbox_y2)

    image_format = b'PNG'
    example = tf.train.Example(features=tf.train.Features(feature={
            'image/encoded': bytes_feature(image_data),
            'image/height': int64_feature(shape[0]),
            'image/width': int64_feature(shape[1]),
            'image/channels': int64_feature(shape[2]),
            'image/shape': int64_feature(shape),
            'image/object/bbox/xmin': float_feature(bbox_x1_list),
            'image/object/bbox/xmax': float_feature(bbox_x2_list),
            'image/object/bbox/ymin': float_feature(bbox_y1_list),
            'image/object/bbox/ymax': float_feature(bbox_y2_list),
            'image/object/bbox/label': int64_feature(label_list),
            'image/object/bbox/label_text': bytes_feature(type_list),
    }))
    return example 
开发者ID:Zehaos,项目名称:MobileNet,代码行数:59,代码来源:kitti_object_to_tfrecords.py

示例6: _convert_to_example

# 需要导入模块: from datasets import dataset_utils [as 别名]
# 或者: from datasets.dataset_utils import bytes_feature [as 别名]
def _convert_to_example(filename, image_data, height, width, current_file_info, shared_info):
    colorspace = 'RGB'
    channels = 3
    image_format = 'JPEG'
    (x_expanded, y_expanded, w_expanded, h_expanded, image_w, image_h, tags_id, original_image,
     face_xywh) = current_file_info

    feature = {
      'image/x': dataset_utils.int64_feature(x_expanded),
      'image/y': dataset_utils.int64_feature(y_expanded),
      'image/height': dataset_utils.int64_feature(h_expanded),
      'image/width': dataset_utils.int64_feature(w_expanded),

      'image/face_xywh': dataset_utils.float_feature(face_xywh),
      # 'image/left_eye_xywh': dataset_utils.float_feature(left_eye_xywh),
      # 'image/right_eye_xywh': dataset_utils.float_feature(right_eye_xywh),
      # 'image/mouth_xywh': dataset_utils.float_feature(mouth_xywh),

      'image/colorspace': dataset_utils.bytes_feature(colorspace),
      'image/channels': dataset_utils.int64_feature(channels),
      'image/format': dataset_utils.bytes_feature(image_format),
      'image/filename': dataset_utils.bytes_feature(os.path.basename(filename)),
      'image/encoded': dataset_utils.bytes_feature(image_data),
      # Encoding original takes up too much space. Not recommended.
      # 'image/original': dataset_utils.bytes_feature(original_image),
    }
    example = tf.train.Example(features=tf.train.Features(feature=feature))
    return example

  ###########################
  # Other utility functions #
  ###########################
  # Inherits from parent class.

  ########
  # Main #
  ########
  # Inherits from parent class.


################
# Helper class #
################ 
开发者ID:jerryli27,项目名称:TwinGAN,代码行数:45,代码来源:convert_anime_faces_from_object_detection.py

示例7: _convert_to_example

# 需要导入模块: from datasets import dataset_utils [as 别名]
# 或者: from datasets.dataset_utils import bytes_feature [as 别名]
def _convert_to_example(image_data, labels, labels_text, bboxes, shape,
                        difficult, truncated,name):
    """Build an Example proto for an image example.

    Args:
      image_data: string, JPEG encoding of RGB image;
      labels: list of integers, identifier for the ground truth;
      labels_text: list of strings, human-readable labels;
      bboxes: list of bounding boxes; each box is a list of integers;
          specifying [xmin, ymin, xmax, ymax]. All boxes are assumed to belong
          to the same label as the image label.
      shape: 3 integers, image shapes in pixels.
    Returns:
      Example proto
    """
    xmin = []
    ymin = []
    xmax = []
    ymax = []
    for b in bboxes:
        assert len(b) == 4
        # pylint: disable=expression-not-assigned
        [l.append(point) for l, point in zip([ymin, xmin, ymax, xmax], b)]
        # pylint: enable=expression-not-assigned

    image_format = b'JPEG'
    example = tf.train.Example(features=tf.train.Features(feature={
            'image/height': int64_feature(shape[0]),
            'image/width': int64_feature(shape[1]),
            'image/channels': int64_feature(shape[2]),
            'image/shape': int64_feature(shape),
            'image/object/bbox/xmin': float_feature(xmin),
            'image/object/bbox/xmax': float_feature(xmax),
            'image/object/bbox/ymin': float_feature(ymin),
            'image/object/bbox/ymax': float_feature(ymax),
            'image/object/bbox/label': int64_feature(labels),
            'image/object/bbox/label_text': bytes_feature(labels_text),
            'image/object/bbox/difficult': int64_feature(difficult),
            'image/object/bbox/truncated': int64_feature(truncated),
            'image/format': bytes_feature(image_format),
            'image/filename': bytes_feature(name.encode('utf-8')),
            'image/encoded': bytes_feature(image_data)}))
    return example 
开发者ID:LevinJ,项目名称:SSD_tensorflow_VOC,代码行数:45,代码来源:pascalvoc_to_tfrecords.py


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