Eager execution coverage for image_ops_test.py. Removed `run_deprecated_v1` decorators.
Part 13 (class PngTest, GifTest, ConvertImageTest)
PiperOrigin-RevId: 333790780
Change-Id: I731fd63ddfc049a4b73f1ef17affdfd59c942010
diff --git a/tensorflow/python/ops/image_ops_test.py b/tensorflow/python/ops/image_ops_test.py
index 41e8c22..3f7fdfe 100644
--- a/tensorflow/python/ops/image_ops_test.py
+++ b/tensorflow/python/ops/image_ops_test.py
@@ -4442,14 +4442,15 @@
self.assertEqual(2, image0.shape[-1])
self.assertAllEqual(image0, image1)
- @test_util.run_deprecated_v1
def testShape(self):
- with self.cached_session(use_gpu=True):
- png = constant_op.constant("nonsense")
- for channels in 0, 1, 3:
- image = image_ops.decode_png(png, channels=channels)
- self.assertEqual(image.get_shape().as_list(),
- [None, None, channels or None])
+ # Shape function requires placeholders and a graph.
+ with ops.Graph().as_default():
+ with self.cached_session(use_gpu=True):
+ png = constant_op.constant("nonsense")
+ for channels in 0, 1, 3:
+ image = image_ops.decode_png(png, channels=channels)
+ self.assertEqual(image.get_shape().as_list(),
+ [None, None, channels or None])
class GifTest(test_util.TensorFlowTestCase):
@@ -4487,12 +4488,13 @@
self._testValid("scan.gif")
self._testValid("optimized.gif")
- @test_util.run_deprecated_v1
def testShape(self):
- with self.cached_session(use_gpu=True) as sess:
- gif = constant_op.constant("nonsense")
- image = image_ops.decode_gif(gif)
- self.assertEqual(image.get_shape().as_list(), [None, None, None, 3])
+ # Shape function requires placeholders and a graph.
+ with ops.Graph().as_default():
+ with self.cached_session(use_gpu=True) as sess:
+ gif = constant_op.constant("nonsense")
+ image = image_ops.decode_gif(gif)
+ self.assertEqual(image.get_shape().as_list(), [None, None, None, 3])
class ConvertImageTest(test_util.TensorFlowTestCase):
@@ -4514,17 +4516,17 @@
self.assertTrue(y_saturate.dtype == output_dtype)
self.assertAllClose(y_saturate, y_np, atol=1e-5)
- @test_util.run_deprecated_v1
def testNoConvert(self):
- # Make sure converting to the same data type creates only an identity op
- with self.cached_session(use_gpu=True):
- image = constant_op.constant([1], dtype=dtypes.uint8)
- image_ops.convert_image_dtype(image, dtypes.uint8)
- y = image_ops.convert_image_dtype(image, dtypes.uint8)
- self.assertEqual(y.op.type, "Identity")
- self.assertEqual(y.op.inputs[0], image)
+ # Tests with Tensor.op requires a graph.
+ with ops.Graph().as_default():
+ # Make sure converting to the same data type creates only an identity op
+ with self.cached_session(use_gpu=True):
+ image = constant_op.constant([1], dtype=dtypes.uint8)
+ image_ops.convert_image_dtype(image, dtypes.uint8)
+ y = image_ops.convert_image_dtype(image, dtypes.uint8)
+ self.assertEqual(y.op.type, "Identity")
+ self.assertEqual(y.op.inputs[0], image)
- @test_util.run_deprecated_v1
def testConvertBetweenInteger(self):
# Make sure converting to between integer types scales appropriately
with self.cached_session(use_gpu=True):
@@ -4533,7 +4535,6 @@
self._convert([0, 2**32], dtypes.int64, dtypes.int32, [0, 1])
self._convert([0, 1], dtypes.int32, dtypes.int64, [0, 2**32])
- @test_util.run_deprecated_v1
def testConvertBetweenFloat(self):
# Make sure converting to between float types does nothing interesting
with self.cached_session(use_gpu=True):
@@ -4542,7 +4543,6 @@
self._convert([-1.0, 0, 1.0, 200000], dtypes.float64, dtypes.float32,
[-1.0, 0, 1.0, 200000])
- @test_util.run_deprecated_v1
def testConvertBetweenIntegerAndFloat(self):
# Make sure converting from and to a float type scales appropriately
with self.cached_session(use_gpu=True):
@@ -4551,7 +4551,6 @@
self._convert([0, 1.1 / 255.0, 1], dtypes.float32, dtypes.uint8,
[0, 1, 255])
- @test_util.run_deprecated_v1
def testConvertBetweenInt16AndInt8(self):
with self.cached_session(use_gpu=True):
# uint8, uint16