本文整理汇总了Python中object_detection.protos.image_resizer_pb2.ImageResizer方法的典型用法代码示例。如果您正苦于以下问题:Python image_resizer_pb2.ImageResizer方法的具体用法?Python image_resizer_pb2.ImageResizer怎么用?Python image_resizer_pb2.ImageResizer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object_detection.protos.image_resizer_pb2
的用法示例。
在下文中一共展示了image_resizer_pb2.ImageResizer方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_input
# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def build_input():
image_tensor = image_ph = tf.placeholder(dtype=tf.uint8, shape=[None, None, 3], name='image_ph')
image_resizer_text_proto = """
keep_aspect_ratio_resizer {
min_dimension: 800
max_dimension: 1365
}
"""
image_resizer_config = image_resizer_pb2.ImageResizer()
text_format.Merge(image_resizer_text_proto, image_resizer_config)
image_resizer_fn = image_resizer_builder.build(image_resizer_config)
resized_image_tensor, _ = image_resizer_fn(image_tensor)
resized_image_tensor = tf.cast(resized_image_tensor, dtype=tf.uint8)
resized_image_tensor = tf.expand_dims(resized_image_tensor, 0)
return image_ph, resized_image_tensor
示例2: _shape_of_resized_random_image_given_text_proto
# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def _shape_of_resized_random_image_given_text_proto(
self, input_shape, text_proto):
image_resizer_config = image_resizer_pb2.ImageResizer()
text_format.Merge(text_proto, image_resizer_config)
image_resizer_fn = image_resizer_builder.build(image_resizer_config)
images = tf.to_float(tf.random_uniform(
input_shape, minval=0, maxval=255, dtype=tf.int32))
resized_images = image_resizer_fn(images)
with self.test_session() as sess:
return sess.run(resized_images).shape
示例3: build
# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def build(image_resizer_config):
"""Builds callable for image resizing operations.
Args:
image_resizer_config: image_resizer.proto object containing parameters for
an image resizing operation.
Returns:
image_resizer_fn: Callable for image resizing. This callable always takes
a rank-3 image tensor (corresponding to a single image) and returns a
rank-3 image tensor, possibly with new spatial dimensions.
Raises:
ValueError: if `image_resizer_config` is of incorrect type.
ValueError: if `image_resizer_config.image_resizer_oneof` is of expected
type.
ValueError: if min_dimension > max_dimension when keep_aspect_ratio_resizer
is used.
"""
if not isinstance(image_resizer_config, image_resizer_pb2.ImageResizer):
raise ValueError('image_resizer_config not of type '
'image_resizer_pb2.ImageResizer.')
if image_resizer_config.WhichOneof(
'image_resizer_oneof') == 'keep_aspect_ratio_resizer':
keep_aspect_ratio_config = image_resizer_config.keep_aspect_ratio_resizer
if not (keep_aspect_ratio_config.min_dimension
<= keep_aspect_ratio_config.max_dimension):
raise ValueError('min_dimension > max_dimension')
return functools.partial(
preprocessor.resize_to_range,
min_dimension=keep_aspect_ratio_config.min_dimension,
max_dimension=keep_aspect_ratio_config.max_dimension)
if image_resizer_config.WhichOneof(
'image_resizer_oneof') == 'fixed_shape_resizer':
fixed_shape_resizer_config = image_resizer_config.fixed_shape_resizer
return functools.partial(preprocessor.resize_image,
new_height=fixed_shape_resizer_config.height,
new_width=fixed_shape_resizer_config.width)
raise ValueError('Invalid image resizer option.')
示例4: testGetSpatialImageSizeFromFixedShapeResizerConfig
# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def testGetSpatialImageSizeFromFixedShapeResizerConfig(self):
image_resizer_config = image_resizer_pb2.ImageResizer()
image_resizer_config.fixed_shape_resizer.height = 100
image_resizer_config.fixed_shape_resizer.width = 200
image_shape = config_util.get_spatial_image_size(image_resizer_config)
self.assertAllEqual(image_shape, [100, 200])
示例5: testGetSpatialImageSizeFromAspectPreservingResizerConfig
# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def testGetSpatialImageSizeFromAspectPreservingResizerConfig(self):
image_resizer_config = image_resizer_pb2.ImageResizer()
image_resizer_config.keep_aspect_ratio_resizer.min_dimension = 100
image_resizer_config.keep_aspect_ratio_resizer.max_dimension = 600
image_resizer_config.keep_aspect_ratio_resizer.pad_to_max_dimension = True
image_shape = config_util.get_spatial_image_size(image_resizer_config)
self.assertAllEqual(image_shape, [600, 600])
示例6: testGetSpatialImageSizeFromAspectPreservingResizerDynamic
# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def testGetSpatialImageSizeFromAspectPreservingResizerDynamic(self):
image_resizer_config = image_resizer_pb2.ImageResizer()
image_resizer_config.keep_aspect_ratio_resizer.min_dimension = 100
image_resizer_config.keep_aspect_ratio_resizer.max_dimension = 600
image_shape = config_util.get_spatial_image_size(image_resizer_config)
self.assertAllEqual(image_shape, [-1, -1])
示例7: _shape_of_resized_random_image_given_text_proto
# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def _shape_of_resized_random_image_given_text_proto(self, input_shape,
text_proto):
image_resizer_config = image_resizer_pb2.ImageResizer()
text_format.Merge(text_proto, image_resizer_config)
image_resizer_fn = image_resizer_builder.build(image_resizer_config)
images = tf.to_float(
tf.random_uniform(input_shape, minval=0, maxval=255, dtype=tf.int32))
resized_images, _ = image_resizer_fn(images)
with self.test_session() as sess:
return sess.run(resized_images).shape
示例8: _resized_image_given_text_proto
# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def _resized_image_given_text_proto(self, image, text_proto):
image_resizer_config = image_resizer_pb2.ImageResizer()
text_format.Merge(text_proto, image_resizer_config)
image_resizer_fn = image_resizer_builder.build(image_resizer_config)
image_placeholder = tf.placeholder(tf.uint8, [1, None, None, 3])
resized_image, _ = image_resizer_fn(image_placeholder)
with self.test_session() as sess:
return sess.run(resized_image, feed_dict={image_placeholder: image})
示例9: test_get_spatial_image_size_from_fixed_shape_resizer_config
# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def test_get_spatial_image_size_from_fixed_shape_resizer_config(self):
image_resizer_config = image_resizer_pb2.ImageResizer()
image_resizer_config.fixed_shape_resizer.height = 100
image_resizer_config.fixed_shape_resizer.width = 200
image_shape = config_util.get_spatial_image_size(image_resizer_config)
self.assertAllEqual(image_shape, [100, 200])
示例10: test_get_spatial_image_size_from_aspect_preserving_resizer_config
# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def test_get_spatial_image_size_from_aspect_preserving_resizer_config(self):
image_resizer_config = image_resizer_pb2.ImageResizer()
image_resizer_config.keep_aspect_ratio_resizer.min_dimension = 100
image_resizer_config.keep_aspect_ratio_resizer.max_dimension = 600
image_resizer_config.keep_aspect_ratio_resizer.pad_to_max_dimension = True
image_shape = config_util.get_spatial_image_size(image_resizer_config)
self.assertAllEqual(image_shape, [600, 600])
示例11: test_get_spatial_image_size_from_aspect_preserving_resizer_dynamic
# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def test_get_spatial_image_size_from_aspect_preserving_resizer_dynamic(self):
image_resizer_config = image_resizer_pb2.ImageResizer()
image_resizer_config.keep_aspect_ratio_resizer.min_dimension = 100
image_resizer_config.keep_aspect_ratio_resizer.max_dimension = 600
image_shape = config_util.get_spatial_image_size(image_resizer_config)
self.assertAllEqual(image_shape, [-1, -1])
示例12: _shape_of_resized_random_image_given_text_proto
# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def _shape_of_resized_random_image_given_text_proto(self, input_shape,
text_proto):
image_resizer_config = image_resizer_pb2.ImageResizer()
text_format.Merge(text_proto, image_resizer_config)
image_resizer_fn = image_resizer_builder.build(image_resizer_config)
images = tf.to_float(
tf.random_uniform(input_shape, minval=0, maxval=255, dtype=tf.int32))
resized_images = image_resizer_fn(images)
with self.test_session() as sess:
return sess.run(resized_images).shape
示例13: _resized_image_given_text_proto
# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def _resized_image_given_text_proto(self, image, text_proto):
image_resizer_config = image_resizer_pb2.ImageResizer()
text_format.Merge(text_proto, image_resizer_config)
image_resizer_fn = image_resizer_builder.build(image_resizer_config)
image_placeholder = tf.placeholder(tf.uint8, [1, None, None, 3])
resized_image = image_resizer_fn(image_placeholder)
with self.test_session() as sess:
return sess.run(resized_image, feed_dict={image_placeholder: image})