Update the image_test to proper AST scope.

PiperOrigin-RevId: 336904200
Change-Id: I87269130e4a90bfbb0fdf9854fb55f0f32a6de01
This commit is contained in:
Scott Zhu 2020-10-13 10:25:19 -07:00 committed by TensorFlower Gardener
parent dd21d56ae8
commit 058aa3a305

View File

@ -22,6 +22,7 @@ import os
import shutil
import tempfile
from absl.testing import parameterized
import numpy as np
from tensorflow.python.data import Dataset
@ -71,14 +72,17 @@ class TestImage(keras_parameterized.TestCase):
output = preprocessing_image.smart_resize(test_input, size=(5, 15))
self.assertListEqual(list(output.shape), [5, 15, 3])
@parameterized.named_parameters(
('size1', (50, 50)),
('size2', (10, 10)),
('size3', (100, 50)),
('size4', (5, 15)))
@testing_utils.run_v2_only
def test_smart_resize_tf_dataset(self):
def test_smart_resize_tf_dataset(self, size):
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)