aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Dan Osipov <danospv@gmail.com>2018-06-05 16:39:47 -0700
committerGravatar Dan Osipov <danospv@gmail.com>2018-06-05 16:39:47 -0700
commit7edb417cd05fe438d587372fcf07e7c45e1dd8f8 (patch)
treeba257cbcbb24d9da0d0559160ffd898da0cc04e9
parent7eaef86f7766e7c0577614e646dc8d6a972b91f9 (diff)
Fix lint errors
-rw-r--r--tensorflow/python/ops/image_ops_impl.py18
-rw-r--r--tensorflow/python/ops/image_ops_test.py8
2 files changed, 15 insertions, 11 deletions
diff --git a/tensorflow/python/ops/image_ops_impl.py b/tensorflow/python/ops/image_ops_impl.py
index f3f9a02f01..231b49fbf5 100644
--- a/tensorflow/python/ops/image_ops_impl.py
+++ b/tensorflow/python/ops/image_ops_impl.py
@@ -971,7 +971,7 @@ def resize_images(images,
@tf_export('image.resize_image_with_pad')
def resize_image_with_pad(image, target_height, target_width,
- method=ResizeMethod.BILINEAR):
+ method=ResizeMethod.BILINEAR):
"""
Resizes and pads an image to a target width and height.
@@ -1038,17 +1038,21 @@ def resize_image_with_pad(image, target_height, target_width,
ratio = max_(f_width / f_target_width, f_height / f_target_height)
resized_height_float = f_height / ratio
resized_width_float = f_width / ratio
- resized_height = math_ops.cast(math_ops.floor(resized_height_float), dtype=dtypes.int32)
- resized_width = math_ops.cast(math_ops.floor(resized_width_float), dtype=dtypes.int32)
-
- f_padding_height = math_ops.floor((f_target_height - resized_height_float) / 2)
- f_padding_width = math_ops.floor((f_target_width - resized_width_float) / 2)
+ resized_height = math_ops.cast(math_ops.floor(resized_height_float),
+ dtype=dtypes.int32)
+ resized_width = math_ops.cast(math_ops.floor(resized_width_float),
+ dtype=dtypes.int32)
+
+ padding_height = (f_target_height - resized_height_float) / 2
+ padding_width = (f_target_width - resized_width_float) / 2
+ f_padding_height = math_ops.floor(padding_height)
+ f_padding_width = math_ops.floor(padding_width)
p_height = max_(0, math_ops.cast(f_padding_height, dtype=dtypes.int32))
p_width = max_(0, math_ops.cast(f_padding_width, dtype=dtypes.int32))
# Resize first, then pad to meet requested dimensions
resized = resize_images(image, [resized_height, resized_width], method)
-
+
padded = pad_to_bounding_box(resized, p_height, p_width,
target_height, target_width)
diff --git a/tensorflow/python/ops/image_ops_test.py b/tensorflow/python/ops/image_ops_test.py
index e98d16e6d3..ce46a4e59e 100644
--- a/tensorflow/python/ops/image_ops_test.py
+++ b/tensorflow/python/ops/image_ops_test.py
@@ -2461,7 +2461,7 @@ class ResizeImagesTest(test_util.TensorFlowTestCase):
class ResizeImageWithPadTest(test_util.TensorFlowTestCase):
def _ResizeImageWithPad(self, x, target_height, target_width,
- use_tensor_inputs):
+ use_tensor_inputs):
if use_tensor_inputs:
target_height = ops.convert_to_tensor(target_height)
target_width = ops.convert_to_tensor(target_width)
@@ -2472,7 +2472,7 @@ class ResizeImageWithPadTest(test_util.TensorFlowTestCase):
feed_dict = {}
y = image_ops.resize_image_with_pad(x_tensor, target_height,
- target_width)
+ target_width)
if not use_tensor_inputs:
self.assertTrue(y.get_shape().is_fully_defined())
@@ -2492,7 +2492,7 @@ class ResizeImageWithPadTest(test_util.TensorFlowTestCase):
for use_tensor_inputs in use_tensor_inputs_options:
y_tf = self._ResizeImageWithPad(x, target_height, target_width,
- use_tensor_inputs)
+ use_tensor_inputs)
self.assertAllClose(y, y_tf)
def _assertRaises(self,
@@ -2508,7 +2508,7 @@ class ResizeImageWithPadTest(test_util.TensorFlowTestCase):
for use_tensor_inputs in use_tensor_inputs_options:
try:
self._ResizeImageWithPad(x, target_height, target_width,
- use_tensor_inputs)
+ use_tensor_inputs)
except Exception as e:
if err_msg not in str(e):
raise