message: add test coverage for smart_resize on tf.data dataset
diff: @@ -30,6 +30,7 @@ from tensorflow.python.keras import layers
  from tensorflow.python.keras.engine import sequential
  from tensorflow.python.keras.preprocessing import image as preprocessing_image
  from tensorflow.python.platform import test
  +from tensorflow.python.data import Dataset
  try:
  import PIL # pylint:disable=g-import-not-at-top
  @@ -70,6 +71,21 @@ class TestImage(keras_parameterized.TestCase):
  output = preprocessing_image.smart_resize(test_input, size=(5, 15))
  self.assertListEqual(list(output.shape), [5, 15, 3])
  +
  + @test_util.run_v2_only
  + def test_smart_resize_tf_dataset(self):
  + test_input_np = np.random.random((2, 20, 40, 3))
  + test_ds = Dataset.from_tensor_slices(test_input_np)
  +
  + resize = lambda img: preprocessing_image.smart_resize(img, size=size)
  +
  + for size in [(50, 50), (10, 10), (100, 50), (5, 15)]:
  + test_ds = test_ds.map(resize)
  + for sample in test_ds.as_numpy_iterator():
  + self.assertIsInstance(sample, np.ndarray)
  + self.assertListEqual(list(sample.shape), [size[0], size[1], 3])
  +
  +
  def test_smart_resize_errors(self):
  with self.assertRaisesRegex(ValueError, 'a tuple of 2 integers'):
  preprocessing_image.smart_resize(
  