Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions tensorflow_addons/image/distort_image_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ def adjust_hsv_in_yiq(image,
with tf.name_scope(name or "adjust_hsv_in_yiq"):
image = tf.convert_to_tensor(image, name="image")

if image.shape.rank < 3:
raise ValueError("input must be at least rank 3.")

# Remember original dtype to so we can convert back if needed
orig_dtype = image.dtype
flt_image = tf.image.convert_image_dtype(image, tf.dtypes.float32)
Expand Down
24 changes: 12 additions & 12 deletions tensorflow_addons/image/distort_image_ops_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,18 @@ def test_adjust_random_hue_in_yiq(self):
y_tf = self._adjust_hue_in_yiq_tf(x_np, delta_h)
self.assertAllClose(y_tf, y_np, rtol=2e-4, atol=1e-4)

# TODO: run in both graph and eager modes
@test_utils.run_in_graph_and_eager_modes
def test_invalid_shapes(self):
x_np = np.random.rand(2, 3) * 255.
delta_h = np.random.rand() * 2.0 - 1.0
with self.assertRaisesRegexp(ValueError,
"input must be at least rank 3."):
self._adjust_hue_in_yiq_tf(x_np, delta_h)
"Shape must be at least rank 3"):
self.evaluate(self._adjust_hue_in_yiq_tf(x_np, delta_h))
x_np = np.random.rand(4, 2, 4) * 255.
delta_h = np.random.rand() * 2.0 - 1.0
with self.assertRaisesOpError("input must have 3 channels "
"but instead has 4 channels"):
self._adjust_hue_in_yiq_tf(x_np, delta_h)
self.evaluate(self._adjust_hue_in_yiq_tf(x_np, delta_h))


class AdjustValueInYiqTest(tf.test.TestCase):
Expand Down Expand Up @@ -163,18 +163,18 @@ def test_adjust_random_value_in_yiq(self):
y_tf = self._adjust_value_in_yiq_tf(x_np, scale)
self.assertAllClose(y_tf, y_np, rtol=2e-4, atol=1e-4)

# TODO: run in both graph and eager modes
@test_utils.run_in_graph_and_eager_modes
def test_invalid_shapes(self):
x_np = np.random.rand(2, 3) * 255.
scale = np.random.rand() * 2.0 - 1.0
with self.assertRaisesRegexp(ValueError,
"input must be at least rank 3."):
self._adjust_value_in_yiq_tf(x_np, scale)
"Shape must be at least rank 3"):
self.evaluate(self._adjust_value_in_yiq_tf(x_np, scale))
x_np = np.random.rand(4, 2, 4) * 255.
scale = np.random.rand() * 2.0 - 1.0
with self.assertRaisesOpError("input must have 3 channels "
"but instead has 4 channels"):
self._adjust_value_in_yiq_tf(x_np, scale)
self.evaluate(self._adjust_value_in_yiq_tf(x_np, scale))


class AdjustSaturationInYiqTest(tf.test.TestCase):
Expand Down Expand Up @@ -228,18 +228,18 @@ def test_adjust_random_saturation_in_yiq(self):
y_tf = self._adjust_saturation_in_yiq_tf(x_np, scale)
self.assertAllClose(y_tf, y_baseline, rtol=2e-4, atol=1e-4)

# TODO: run in both graph and eager modes
@test_utils.run_in_graph_and_eager_modes
def test_invalid_shapes(self):
x_np = np.random.rand(2, 3) * 255.
scale = np.random.rand() * 2.0 - 1.0
with self.assertRaisesRegexp(ValueError,
"input must be at least rank 3."):
self._adjust_saturation_in_yiq_tf(x_np, scale)
"Shape must be at least rank 3"):
self.evaluate(self._adjust_saturation_in_yiq_tf(x_np, scale))
x_np = np.random.rand(4, 2, 4) * 255.
scale = np.random.rand() * 2.0 - 1.0
with self.assertRaisesOpError("input must have 3 channels "
"but instead has 4 channels"):
self._adjust_saturation_in_yiq_tf(x_np, scale)
self.evaluate(self._adjust_saturation_in_yiq_tf(x_np, scale))


# TODO: get rid of sessions
Expand Down