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])
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})
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
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])