當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。