本文整理汇总了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
示例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
示例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
示例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
示例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})
示例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