From a72b7e2653b70a610c717f67f4359b00dac602e5 Mon Sep 17 00:00:00 2001 From: Rick Wierenga <rick_wierenga@icloud.com> Date: Mon, 20 Jan 2020 09:09:24 +0100 Subject: [PATCH 1/6] Add usage example to pad_to_bounding_box --- tensorflow/python/ops/image_ops_impl.py | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tensorflow/python/ops/image_ops_impl.py b/tensorflow/python/ops/image_ops_impl.py index fb560fc7da2..13ed09042dd 100644 --- a/tensorflow/python/ops/image_ops_impl.py +++ b/tensorflow/python/ops/image_ops_impl.py @@ -849,6 +849,34 @@ def pad_to_bounding_box(image, offset_height, offset_width, target_height, This op does nothing if `offset_*` is zero and the image already has size `target_height` by `target_width`. + + Usage Example: + >>> x = [[[1.0, 2.0, 3.0], + ... [4.0, 5.0, 6.0]], + ... [[7.0, 8.0, 9.0], + ... [10.0, 11.0, 12.0]]] + >>> padded_image = tf.image.pad_to_bounding_box(x, 1, 1, 4, 4) + >>> print(padded_image) + <tf.Tensor: shape=(4, 4, 3), dtype=float32, numpy= + array([[[ 0., 0., 0.], + [ 0., 0., 0.], + [ 0., 0., 0.], + [ 0., 0., 0.]], + + [[ 0., 0., 0.], + [ 1., 2., 3.], + [ 4., 5., 6.], + [ 0., 0., 0.]], + + [[ 0., 0., 0.], + [ 7., 8., 9.], + [10., 11., 12.], + [ 0., 0., 0.]], + + [[ 0., 0., 0.], + [ 0., 0., 0.], + [ 0., 0., 0.], + [ 0., 0., 0.]]], dtype=float32)> Args: image: 4-D Tensor of shape `[batch, height, width, channels]` or 3-D Tensor From 5cf792e402b1e08e423a6588111a5210b71bbd54 Mon Sep 17 00:00:00 2001 From: Rick Wierenga <rick_wierenga@icloud.com> Date: Mon, 20 Jan 2020 11:33:55 +0100 Subject: [PATCH 2/6] remove redundant 0's --- tensorflow/python/ops/image_ops_impl.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tensorflow/python/ops/image_ops_impl.py b/tensorflow/python/ops/image_ops_impl.py index 13ed09042dd..f66f9b9659d 100644 --- a/tensorflow/python/ops/image_ops_impl.py +++ b/tensorflow/python/ops/image_ops_impl.py @@ -851,10 +851,10 @@ def pad_to_bounding_box(image, offset_height, offset_width, target_height, `target_height` by `target_width`. Usage Example: - >>> x = [[[1.0, 2.0, 3.0], - ... [4.0, 5.0, 6.0]], - ... [[7.0, 8.0, 9.0], - ... [10.0, 11.0, 12.0]]] + >>> x = [[[1., 2., 3.], + ... [4., 5., 6.]], + ... [[7., 8., 9.], + ... [10., 11., 12.]]] >>> padded_image = tf.image.pad_to_bounding_box(x, 1, 1, 4, 4) >>> print(padded_image) <tf.Tensor: shape=(4, 4, 3), dtype=float32, numpy= From 60596fa2be2b3b537464d03686816c6049dc7ecd Mon Sep 17 00:00:00 2001 From: Rick Wierenga <rick_wierenga@icloud.com> Date: Mon, 20 Jan 2020 11:43:03 +0100 Subject: [PATCH 3/6] remove empty lines --- tensorflow/python/ops/image_ops_impl.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tensorflow/python/ops/image_ops_impl.py b/tensorflow/python/ops/image_ops_impl.py index f66f9b9659d..267c9f942d8 100644 --- a/tensorflow/python/ops/image_ops_impl.py +++ b/tensorflow/python/ops/image_ops_impl.py @@ -862,17 +862,14 @@ def pad_to_bounding_box(image, offset_height, offset_width, target_height, [ 0., 0., 0.], [ 0., 0., 0.], [ 0., 0., 0.]], - [[ 0., 0., 0.], [ 1., 2., 3.], [ 4., 5., 6.], [ 0., 0., 0.]], - [[ 0., 0., 0.], [ 7., 8., 9.], [10., 11., 12.], [ 0., 0., 0.]], - [[ 0., 0., 0.], [ 0., 0., 0.], [ 0., 0., 0.], From f1c5f136e664510c41e9cf09b1160d68ac2ec58b Mon Sep 17 00:00:00 2001 From: Rick Wierenga <rick_wierenga@icloud.com> Date: Tue, 21 Jan 2020 09:06:29 +0100 Subject: [PATCH 4/6] Update image_ops_impl.py --- tensorflow/python/ops/image_ops_impl.py | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/tensorflow/python/ops/image_ops_impl.py b/tensorflow/python/ops/image_ops_impl.py index 267c9f942d8..60e4fc7a74e 100644 --- a/tensorflow/python/ops/image_ops_impl.py +++ b/tensorflow/python/ops/image_ops_impl.py @@ -856,24 +856,8 @@ def pad_to_bounding_box(image, offset_height, offset_width, target_height, ... [[7., 8., 9.], ... [10., 11., 12.]]] >>> padded_image = tf.image.pad_to_bounding_box(x, 1, 1, 4, 4) - >>> print(padded_image) - <tf.Tensor: shape=(4, 4, 3), dtype=float32, numpy= - array([[[ 0., 0., 0.], - [ 0., 0., 0.], - [ 0., 0., 0.], - [ 0., 0., 0.]], - [[ 0., 0., 0.], - [ 1., 2., 3.], - [ 4., 5., 6.], - [ 0., 0., 0.]], - [[ 0., 0., 0.], - [ 7., 8., 9.], - [10., 11., 12.], - [ 0., 0., 0.]], - [[ 0., 0., 0.], - [ 0., 0., 0.], - [ 0., 0., 0.], - [ 0., 0., 0.]]], dtype=float32)> + >>> padded_image + <tf.Tensor: shape=(4, 4, 3), numpy=..., dtype=float32)> Args: image: 4-D Tensor of shape `[batch, height, width, channels]` or 3-D Tensor From eeef19c2719e52f197472720e4c6e8a484beb0c9 Mon Sep 17 00:00:00 2001 From: Rick Wierenga <rick_wierenga@icloud.com> Date: Tue, 21 Jan 2020 09:11:56 +0100 Subject: [PATCH 5/6] fix numpy array formatting --- tensorflow/python/ops/image_ops_impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/ops/image_ops_impl.py b/tensorflow/python/ops/image_ops_impl.py index 60e4fc7a74e..52bfb1cb004 100644 --- a/tensorflow/python/ops/image_ops_impl.py +++ b/tensorflow/python/ops/image_ops_impl.py @@ -857,7 +857,7 @@ def pad_to_bounding_box(image, offset_height, offset_width, target_height, ... [10., 11., 12.]]] >>> padded_image = tf.image.pad_to_bounding_box(x, 1, 1, 4, 4) >>> padded_image - <tf.Tensor: shape=(4, 4, 3), numpy=..., dtype=float32)> + <tf.Tensor: shape=(4, 4, 3), dtype=float32, numpy=array([...], dtype=float32)> Args: image: 4-D Tensor of shape `[batch, height, width, channels]` or 3-D Tensor From 8c60c55e350079c68a316cff967d0e6b17887c57 Mon Sep 17 00:00:00 2001 From: Rick Wierenga <rick_wierenga@icloud.com> Date: Tue, 21 Jan 2020 18:00:44 +0100 Subject: [PATCH 6/6] add numbers again --- tensorflow/python/ops/image_ops_impl.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tensorflow/python/ops/image_ops_impl.py b/tensorflow/python/ops/image_ops_impl.py index 52bfb1cb004..75d48379862 100644 --- a/tensorflow/python/ops/image_ops_impl.py +++ b/tensorflow/python/ops/image_ops_impl.py @@ -857,7 +857,23 @@ def pad_to_bounding_box(image, offset_height, offset_width, target_height, ... [10., 11., 12.]]] >>> padded_image = tf.image.pad_to_bounding_box(x, 1, 1, 4, 4) >>> padded_image - <tf.Tensor: shape=(4, 4, 3), dtype=float32, numpy=array([...], dtype=float32)> + <tf.Tensor: shape=(4, 4, 3), dtype=float32, numpy= + array([[[ 0., 0., 0.], + [ 0., 0., 0.], + [ 0., 0., 0.], + [ 0., 0., 0.]], + [[ 0., 0., 0.], + [ 1., 2., 3.], + [ 4., 5., 6.], + [ 0., 0., 0.]], + [[ 0., 0., 0.], + [ 7., 8., 9.], + [10., 11., 12.], + [ 0., 0., 0.]], + [[ 0., 0., 0.], + [ 0., 0., 0.], + [ 0., 0., 0.], + [ 0., 0., 0.]]], dtype=float32)> Args: image: 4-D Tensor of shape `[batch, height, width, channels]` or 3-D Tensor