本文整理匯總了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