2121import numpy as np
2222import tensorflow as tf
2323
24- from tensorflow .python .framework import test_util as tf_test_util
2524from tensorflow .python .ops import gradient_checker
2625from tensorflow_addons .custom_ops .image .python import transform as transform_ops
26+ from tensorflow_addons .utils .python import test_utils
2727
2828_DTYPES = set ([
2929 tf .dtypes .uint8 , tf .dtypes .int32 , tf .dtypes .int64 , tf .dtypes .float16 ,
3232
3333
3434class ImageOpsTest (tf .test .TestCase ):
35- @tf_test_util . run_all_in_graph_and_eager_modes
35+ @test_utils . run_in_graph_and_eager_modes
3636 def test_compose (self ):
3737 for dtype in _DTYPES :
3838 image = tf .constant (
@@ -51,7 +51,7 @@ def test_compose(self):
5151 [[0 , 0 , 0 , 0 ], [0 , 1 , 0 , 1 ], [0 , 1 , 0 , 1 ], [0 , 1 , 1 , 1 ]],
5252 image_transformed )
5353
54- @tf_test_util . run_all_in_graph_and_eager_modes
54+ @test_utils . run_in_graph_and_eager_modes
5555 def test_extreme_projective_transform (self ):
5656 for dtype in _DTYPES :
5757 image = tf .constant (
@@ -64,7 +64,6 @@ def test_extreme_projective_transform(self):
6464 [[1 , 0 , 0 , 0 ], [0 , 0 , 0 , 0 ], [1 , 0 , 0 , 0 ], [0 , 0 , 0 , 0 ]],
6565 image_transformed )
6666
67- @tf_test_util .run_all_in_graph_and_eager_modes
6867 def test_transform_static_output_shape (self ):
6968 image = tf .constant ([[1. , 2. ], [3. , 4. ]])
7069 result = transform_ops .transform (
@@ -118,7 +117,7 @@ def _test_grad_different_shape(self, input_shape, output_shape):
118117 self .assertLess (left_err , 1e-10 )
119118
120119 # TODO: switch to TF2 later.
121- @tf_test_util .run_deprecated_v1
120+ @test_utils .run_deprecated_v1
122121 def test_grad (self ):
123122 self ._test_grad ([16 , 16 ])
124123 self ._test_grad ([4 , 12 , 12 ])
@@ -127,16 +126,15 @@ def test_grad(self):
127126 self ._test_grad_different_shape ([4 , 12 , 3 ], [8 , 24 , 3 ])
128127 self ._test_grad_different_shape ([3 , 4 , 12 , 3 ], [3 , 8 , 24 , 3 ])
129128
130- @tf_test_util . run_all_in_graph_and_eager_modes
129+ @test_utils . run_in_graph_and_eager_modes
131130 def test_transform_data_types (self ):
132131 for dtype in _DTYPES :
133132 image = tf .constant ([[1 , 2 ], [3 , 4 ]], dtype = dtype )
134- with self .test_session (use_gpu = True ):
135- self .assertAllEqual (
136- np .array ([[4 , 4 ], [4 , 4 ]]).astype (dtype .as_numpy_dtype ()),
137- transform_ops .transform (image , [1 ] * 8 ))
133+ self .assertAllEqual (
134+ np .array ([[4 , 4 ], [4 , 4 ]]).astype (dtype .as_numpy_dtype ()),
135+ transform_ops .transform (image , [1 ] * 8 ))
138136
139- @tf_test_util . run_all_in_graph_and_eager_modes
137+ @test_utils . run_in_graph_and_eager_modes
140138 def test_transform_eager (self ):
141139 image = tf .constant ([[1. , 2. ], [3. , 4. ]])
142140 self .assertAllEqual (
0 commit comments