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


Python tfexample_decoder.Image方法代码示例

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


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

示例1: testDecodeExampleWithJpegEncoding

# 需要导入模块: from tensorflow.contrib.slim.python.slim.data import tfexample_decoder [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.data.tfexample_decoder import Image [as 别名]
def testDecodeExampleWithJpegEncoding(self):
    image_shape = (2, 3, 3)
    image, serialized_example = self.GenerateImage(
        image_format='jpeg', image_shape=image_shape)

    decoded_image = self.RunDecodeExample(
        serialized_example, tfexample_decoder.Image(), image_format='jpeg')

    # Need to use a tolerance of 1 because of noise in the jpeg encode/decode
    self.assertAllClose(image, decoded_image, atol=1.001) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:12,代码来源:tfexample_decoder_test.py

示例2: testDecodeExampleWithJPEGEncoding

# 需要导入模块: from tensorflow.contrib.slim.python.slim.data import tfexample_decoder [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.data.tfexample_decoder import Image [as 别名]
def testDecodeExampleWithJPEGEncoding(self):
    test_image_channels = [1, 3]
    for channels in test_image_channels:
      image_shape = (2, 3, channels)
      image, serialized_example = self.GenerateImage(
          image_format='JPEG', image_shape=image_shape)

      decoded_image = self.RunDecodeExample(
          serialized_example,
          tfexample_decoder.Image(channels=channels),
          image_format='JPEG')

      # Need to use a tolerance of 1 because of noise in the jpeg encode/decode
      self.assertAllClose(image, decoded_image, atol=1.001) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:16,代码来源:tfexample_decoder_test.py

示例3: testDecodeExampleWithNoShapeInfo

# 需要导入模块: from tensorflow.contrib.slim.python.slim.data import tfexample_decoder [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.data.tfexample_decoder import Image [as 别名]
def testDecodeExampleWithNoShapeInfo(self):
    test_image_channels = [1, 3]
    for channels in test_image_channels:
      image_shape = (2, 3, channels)
      _, serialized_example = self.GenerateImage(
          image_format='jpeg', image_shape=image_shape)

      tf_decoded_image = self.DecodeExample(
          serialized_example,
          tfexample_decoder.Image(
              shape=None, channels=channels),
          image_format='jpeg')
      self.assertEqual(tf_decoded_image.get_shape().ndims, 3) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:15,代码来源:tfexample_decoder_test.py

示例4: testDecodeExampleWithPngEncoding

# 需要导入模块: from tensorflow.contrib.slim.python.slim.data import tfexample_decoder [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.data.tfexample_decoder import Image [as 别名]
def testDecodeExampleWithPngEncoding(self):
    test_image_channels = [1, 3, 4]
    for channels in test_image_channels:
      image_shape = (2, 3, channels)
      image, serialized_example = self.GenerateImage(
          image_format='png', image_shape=image_shape)

      decoded_image = self.RunDecodeExample(
          serialized_example,
          tfexample_decoder.Image(channels=channels),
          image_format='png')

      self.assertAllClose(image, decoded_image, atol=0) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:15,代码来源:tfexample_decoder_test.py

示例5: testDecodeExampleWithPNGEncoding

# 需要导入模块: from tensorflow.contrib.slim.python.slim.data import tfexample_decoder [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.data.tfexample_decoder import Image [as 别名]
def testDecodeExampleWithPNGEncoding(self):
    test_image_channels = [1, 3, 4]
    for channels in test_image_channels:
      image_shape = (2, 3, channels)
      image, serialized_example = self.GenerateImage(
          image_format='PNG', image_shape=image_shape)

      decoded_image = self.RunDecodeExample(
          serialized_example,
          tfexample_decoder.Image(channels=channels),
          image_format='PNG')

      self.assertAllClose(image, decoded_image, atol=0) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:15,代码来源:tfexample_decoder_test.py

示例6: testDecodeExampleWithRAWEncoding

# 需要导入模块: from tensorflow.contrib.slim.python.slim.data import tfexample_decoder [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.data.tfexample_decoder import Image [as 别名]
def testDecodeExampleWithRAWEncoding(self):
    image_shape = (2, 3, 3)
    image, serialized_example = self.GenerateImage(
        image_format='RAW', image_shape=image_shape)

    decoded_image = self.RunDecodeExample(
        serialized_example,
        tfexample_decoder.Image(shape=image_shape),
        image_format='RAW')

    self.assertAllClose(image, decoded_image, atol=0) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:13,代码来源:tfexample_decoder_test.py

示例7: _create_tfrecord_dataset

# 需要导入模块: from tensorflow.contrib.slim.python.slim.data import tfexample_decoder [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.data.tfexample_decoder import Image [as 别名]
def _create_tfrecord_dataset(tmpdir):
  if not gfile.Exists(tmpdir):
    gfile.MakeDirs(tmpdir)

  data_sources = test_utils.create_tfrecord_files(tmpdir, num_files=1)

  keys_to_features = {
      'image/encoded':
          parsing_ops.FixedLenFeature(
              shape=(), dtype=dtypes.string, default_value=''),
      'image/format':
          parsing_ops.FixedLenFeature(
              shape=(), dtype=dtypes.string, default_value='jpeg'),
      'image/class/label':
          parsing_ops.FixedLenFeature(
              shape=[1],
              dtype=dtypes.int64,
              default_value=array_ops.zeros(
                  [1], dtype=dtypes.int64))
  }

  items_to_handlers = {
      'image': tfexample_decoder.Image(),
      'label': tfexample_decoder.Tensor('image/class/label'),
  }

  decoder = tfexample_decoder.TFExampleDecoder(keys_to_features,
                                               items_to_handlers)

  return dataset.Dataset(
      data_sources=data_sources,
      reader=io_ops.TFRecordReader,
      decoder=decoder,
      num_samples=100,
      items_to_descriptions=None) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:37,代码来源:dataset_data_provider_test.py

示例8: items_to_handlers

# 需要导入模块: from tensorflow.contrib.slim.python.slim.data import tfexample_decoder [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.data.tfexample_decoder import Image [as 别名]
def items_to_handlers(self):
    """Items to handlers
    """
    default = {
        'image': tfexample_decoder.Image(
            shape=self.params['image_shape'],
            image_key='image/encoded',
            format_key='image/format'),
        'label': tfexample_decoder.Tensor(tensor_key='image/class'),
        'text': tfexample_decoder.Tensor(tensor_key='image/text'),
        'length': tfexample_decoder.Tensor(tensor_key='image/text_length'),
        'name': tfexample_decoder.Tensor(tensor_key='image/name')
    }
    return default 
开发者ID:FangShancheng,项目名称:conv-ensemble-str,代码行数:16,代码来源:datasets.py

示例9: make_data_provider

# 需要导入模块: from tensorflow.contrib.slim.python.slim.data import tfexample_decoder [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.data.tfexample_decoder import Image [as 别名]
def make_data_provider(self, **kwargs):

    context_keys_to_features = {
        self.params["image_field"]: tf.FixedLenFeature(
            [], dtype=tf.string),
        "image/format": tf.FixedLenFeature(
            [], dtype=tf.string, default_value=self.params["image_format"]),
    }

    sequence_keys_to_features = {
        self.params["caption_ids_field"]: tf.FixedLenSequenceFeature(
            [], dtype=tf.int64),
        self.params["caption_tokens_field"]: tf.FixedLenSequenceFeature(
            [], dtype=tf.string)
    }

    items_to_handlers = {
        "image": tfexample_decoder.Image(
            image_key=self.params["image_field"],
            format_key="image/format",
            channels=3),
        "target_ids":
        tfexample_decoder.Tensor(self.params["caption_ids_field"]),
        "target_tokens":
        tfexample_decoder.Tensor(self.params["caption_tokens_field"]),
        "target_len": tfexample_decoder.ItemHandlerCallback(
            keys=[self.params["caption_tokens_field"]],
            func=lambda x: tf.size(x[self.params["caption_tokens_field"]]))
    }

    decoder = TFSEquenceExampleDecoder(
        context_keys_to_features, sequence_keys_to_features, items_to_handlers)

    dataset = tf.contrib.slim.dataset.Dataset(
        data_sources=self.params["files"],
        reader=tf.TFRecordReader,
        decoder=decoder,
        num_samples=None,
        items_to_descriptions={})

    return tf.contrib.slim.dataset_data_provider.DatasetDataProvider(
        dataset=dataset,
        shuffle=self.params["shuffle"],
        num_epochs=self.params["num_epochs"],
        **kwargs) 
开发者ID:akanimax,项目名称:natural-language-summary-generation-from-structured-data,代码行数:47,代码来源:input_pipeline.py

示例10: get_split

# 需要导入模块: from tensorflow.contrib.slim.python.slim.data import tfexample_decoder [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.data.tfexample_decoder import Image [as 别名]
def get_split(split_name, dataset_dir=None):
  """Gets a dataset tuple with instructions for reading cifar100.

  Args:
    split_name: A train/test split name.
    dataset_dir: The base directory of the dataset sources.

  Returns:
    A `Dataset` namedtuple. Image tensors are integers in [0, 255].

  Raises:
    ValueError: if `split_name` is not a valid train/test split.
  """
  if split_name not in _SPLITS_TO_SIZES:
    raise ValueError('split name %s was not recognized.' % split_name)

  file_pattern = os.path.join(dataset_dir, _FILE_PATTERN % split_name)

  keys_to_features = {
      'image/encoded': tf.FixedLenFeature((), tf.string, default_value=''),
      'image/format': tf.FixedLenFeature((), tf.string, default_value=''),
      'image/class/fine_label': tf.FixedLenFeature(
          [1], tf.int64, default_value=tf.zeros([1], dtype=tf.int64)),
      'image/class/coarse_label': tf.FixedLenFeature(
          [1], tf.int64, default_value=tf.zeros([1], dtype=tf.int64)),
  }

  items_to_handlers = {
      'image': tfexample_decoder.Image(shape=[32, 32, 3]),
      'fine_label': tfexample_decoder.Tensor('image/class/fine_label'),
      'coarse_label': tfexample_decoder.Tensor('image/class/coarse_label'),
  }

  decoder = tfexample_decoder.TFExampleDecoder(
      keys_to_features, items_to_handlers)

  return dataset.Dataset(
      data_sources=file_pattern,
      reader=tf.TFRecordReader,
      decoder=decoder,
      num_samples=_SPLITS_TO_SIZES[split_name],
      num_classes=_NUM_CLASSES,
      items_to_descriptions=_ITEMS_TO_DESCRIPTIONS) 
开发者ID:google,项目名称:mentornet,代码行数:45,代码来源:cifar100_dataset.py

示例11: get_split

# 需要导入模块: from tensorflow.contrib.slim.python.slim.data import tfexample_decoder [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.data.tfexample_decoder import Image [as 别名]
def get_split(split_name, dataset_dir=None):
  """Gets a dataset tuple with instructions for reading cifar10.

  Args:
    split_name: A train/test split name.
    dataset_dir: The base directory of the dataset sources.

  Returns:
    A `Dataset` namedtuple. Image tensors are integers in [0, 255].

  Raises:
    ValueError: if `split_name` is not a valid train/test split.
  """
  if split_name not in _SPLITS_TO_SIZES:
    raise ValueError('split name %s was not recognized.' % split_name)

  if dataset_dir is None:
    dataset_dir = _DATASET_DIR

  file_pattern = os.path.join(dataset_dir, _FILE_PATTERN % split_name)

  keys_to_features = {
      'image/encoded': tf.FixedLenFeature((), tf.string, default_value=''),
      'image/format': tf.FixedLenFeature((), tf.string, default_value=''),
      'image/class/label': tf.FixedLenFeature(
          [1], tf.int64, default_value=tf.zeros([1], dtype=tf.int64)),
  }

  items_to_handlers = {
      'image': tfexample_decoder.Image(shape=[32, 32, 3]),
      'label': tfexample_decoder.Tensor('image/class/label'),
  }

  decoder = tfexample_decoder.TFExampleDecoder(
      keys_to_features, items_to_handlers)

  return dataset.Dataset(
      data_sources=file_pattern,
      reader=tf.TFRecordReader,
      decoder=decoder,
      num_samples=_SPLITS_TO_SIZES[split_name],
      num_classes=_NUM_CLASSES,
      items_to_descriptions=_ITEMS_TO_DESCRIPTIONS) 
开发者ID:google,项目名称:mentornet,代码行数:45,代码来源:cifar10_dataset.py


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