Python object_detection.protos.image_resizer_pb2.ImageResizer() Examples
The following are 30
code examples of object_detection.protos.image_resizer_pb2.ImageResizer().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
object_detection.protos.image_resizer_pb2
, or try the search function
.
Example #1
Source File: infer_from_image.py From AniSeg with Apache License 2.0 | 6 votes |
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
Example #2
Source File: image_resizer_builder.py From hands-detection with MIT License | 5 votes |
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.')
Example #3
Source File: image_resizer_builder_test.py From Elphas with Apache License 2.0 | 5 votes |
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
Example #4
Source File: config_util_test.py From AniSeg with Apache License 2.0 | 5 votes |
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])
Example #5
Source File: image_resizer_builder_test.py From AniSeg with Apache License 2.0 | 5 votes |
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
Example #6
Source File: config_util_test.py From AniSeg with Apache License 2.0 | 5 votes |
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])
Example #7
Source File: image_resizer_builder_test.py From object_detection_with_tensorflow with MIT License | 5 votes |
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
Example #8
Source File: image_resizer_builder_test.py From object_detection_with_tensorflow with MIT License | 5 votes |
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})
Example #9
Source File: image_resizer_builder_test.py From object_detection_with_tensorflow with MIT License | 5 votes |
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
Example #10
Source File: image_resizer_builder_test.py From Elphas with Apache License 2.0 | 5 votes |
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})
Example #11
Source File: image_resizer_builder_test.py From object_detection_with_tensorflow with MIT License | 5 votes |
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})
Example #12
Source File: image_resizer_builder_test.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
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.cast( tf.random_uniform(input_shape, minval=0, maxval=255, dtype=tf.int32), dtype=tf.float32) resized_images, _ = image_resizer_fn(images) with self.test_session() as sess: return sess.run(resized_images).shape
Example #13
Source File: config_util_test.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
def testGetSpatialImageSizeFromConditionalShapeResizer(self): image_resizer_config = image_resizer_pb2.ImageResizer() image_resizer_config.conditional_shape_resizer.size_threshold = 100 image_shape = config_util.get_spatial_image_size(image_resizer_config) self.assertAllEqual(image_shape, [-1, -1])
Example #14
Source File: config_util_test.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
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])
Example #15
Source File: config_util_test.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
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])
Example #16
Source File: config_util_test.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
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])
Example #17
Source File: image_resizer_builder_test.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
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.cast( tf.random_uniform(input_shape, minval=0, maxval=255, dtype=tf.int32), dtype=tf.float32) resized_images, _ = image_resizer_fn(images) with self.test_session() as sess: return sess.run(resized_images).shape
Example #18
Source File: image_resizer_builder_test.py From hands-detection with MIT License | 5 votes |
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
Example #19
Source File: image_resizer_builder.py From moveo_ros with MIT License | 5 votes |
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.')
Example #20
Source File: image_resizer_builder_test.py From moveo_ros with MIT License | 5 votes |
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
Example #21
Source File: image_resizer_builder_test.py From BMW-TensorFlow-Training-GUI with Apache License 2.0 | 5 votes |
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})
Example #22
Source File: image_resizer_builder_test.py From BMW-TensorFlow-Training-GUI with Apache License 2.0 | 5 votes |
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
Example #23
Source File: config_util_test.py From BMW-TensorFlow-Training-GUI with Apache License 2.0 | 5 votes |
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])
Example #24
Source File: config_util_test.py From BMW-TensorFlow-Training-GUI with Apache License 2.0 | 5 votes |
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])
Example #25
Source File: config_util_test.py From BMW-TensorFlow-Training-GUI with Apache License 2.0 | 5 votes |
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])
Example #26
Source File: image_resizer_builder_test.py From ros_tensorflow with Apache License 2.0 | 5 votes |
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})
Example #27
Source File: image_resizer_builder_test.py From ros_tensorflow with Apache License 2.0 | 5 votes |
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
Example #28
Source File: config_util_test.py From ros_tensorflow with Apache License 2.0 | 5 votes |
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])
Example #29
Source File: config_util_test.py From ros_tensorflow with Apache License 2.0 | 5 votes |
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])
Example #30
Source File: image_resizer_builder_test.py From DOTA_models with Apache License 2.0 | 5 votes |
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