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


Python preprocessing.preprocess_image方法代码示例

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


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

示例1: build_image_serving_input_fn

# 需要导入模块: import preprocessing [as 别名]
# 或者: from preprocessing import preprocess_image [as 别名]
def build_image_serving_input_fn(image_size):
  """Builds a serving input fn for raw images."""
  def _image_serving_input_fn():
    """Serving input fn for raw images."""
    def _preprocess_image(image_bytes):
      """Preprocess a single raw image."""
      image = preprocessing.preprocess_image(
          image_bytes=image_bytes, is_training=False, image_size=image_size)
      return image

    image_bytes_list = tf.placeholder(
        shape=[None],
        dtype=tf.string,
    )
    images = tf.map_fn(
        _preprocess_image, image_bytes_list, back_prop=False, dtype=tf.float32)
    return tf.estimator.export.ServingInputReceiver(
        images, {'image_bytes': image_bytes_list})
  return _image_serving_input_fn 
开发者ID:artyompal,项目名称:tpu_models,代码行数:21,代码来源:imagenet_input.py

示例2: __init__

# 需要导入模块: import preprocessing [as 别名]
# 或者: from preprocessing import preprocess_image [as 别名]
def __init__(self,
               is_training,
               use_bfloat16,
               num_cores=8,
               image_size=224,
               transpose_input=False,
               include_background_label=False,
               autoaugment_name=None):
    self.image_preprocessing_fn = preprocessing.preprocess_image
    self.is_training = is_training
    self.use_bfloat16 = use_bfloat16
    self.num_cores = num_cores
    self.transpose_input = transpose_input
    self.image_size = image_size
    self.include_background_label = include_background_label
    self.autoaugment_name = autoaugment_name 
开发者ID:artyompal,项目名称:tpu_models,代码行数:18,代码来源:imagenet_input.py

示例3: build_dataset

# 需要导入模块: import preprocessing [as 别名]
# 或者: from preprocessing import preprocess_image [as 别名]
def build_dataset(self, filenames, labels, is_training):
    """Build input dataset."""
    filenames = tf.constant(filenames)
    labels = tf.constant(labels)
    dataset = tf.data.Dataset.from_tensor_slices((filenames, labels))

    def _parse_function(filename, label):
      image_string = tf.read_file(filename)
      image_decoded = preprocessing.preprocess_image(
          image_string, is_training, self.image_size)
      image = tf.cast(image_decoded, tf.float32)
      return image, label

    dataset = dataset.map(_parse_function)
    dataset = dataset.batch(self.batch_size)

    iterator = dataset.make_one_shot_iterator()
    images, labels = iterator.get_next()
    return images, labels 
开发者ID:lukemelas,项目名称:EfficientNet-PyTorch,代码行数:21,代码来源:eval_ckpt_main.py

示例4: build_dataset

# 需要导入模块: import preprocessing [as 别名]
# 或者: from preprocessing import preprocess_image [as 别名]
def build_dataset(self, filenames, labels, is_training):
    """Build input dataset."""
    filenames = tf.constant(filenames)
    labels = tf.constant(labels)
    dataset = tf.data.Dataset.from_tensor_slices((filenames, labels))

    def _parse_function(filename, label):
      image_string = tf.read_file(filename)
      image_decoded = preprocessing.preprocess_image(
          image_string, is_training, image_size=self.image_size)
      image = tf.cast(image_decoded, tf.float32)
      return image, label

    dataset = dataset.map(_parse_function)
    dataset = dataset.batch(self.batch_size)

    iterator = dataset.make_one_shot_iterator()
    images, labels = iterator.get_next()
    return images, labels 
开发者ID:narumiruna,项目名称:efficientnet-pytorch,代码行数:21,代码来源:eval_ckpt_main.py

示例5: image_serving_input_fn

# 需要导入模块: import preprocessing [as 别名]
# 或者: from preprocessing import preprocess_image [as 别名]
def image_serving_input_fn():
  """Serving input fn for raw images."""

  def _preprocess_image(image_bytes):
    """Preprocess a single raw image."""
    image = preprocessing.preprocess_image(
        image_bytes=image_bytes, is_training=False)
    return image

  image_bytes_list = tf.placeholder(
      shape=[None],
      dtype=tf.string,
  )
  images = tf.map_fn(
      _preprocess_image, image_bytes_list, back_prop=False, dtype=tf.float32)
  return tf.estimator.export.ServingInputReceiver(
      images, {'image_bytes': image_bytes_list}) 
开发者ID:dstamoulis,项目名称:single-path-nas,代码行数:19,代码来源:imagenet_input.py

示例6: __init__

# 需要导入模块: import preprocessing [as 别名]
# 或者: from preprocessing import preprocess_image [as 别名]
def __init__(self,
               is_training,
               use_bfloat16,
               num_cores=8,
               image_size=224,
               transpose_input=False):
    self.image_preprocessing_fn = preprocessing.preprocess_image
    self.is_training = is_training
    self.use_bfloat16 = use_bfloat16
    self.num_cores = num_cores
    self.transpose_input = transpose_input
    self.image_size = image_size 
开发者ID:artyompal,项目名称:tpu_models,代码行数:14,代码来源:imagenet_input.py


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