From 644612fde948c301e2dfd6b0bb11c0ed3bedd8be Mon Sep 17 00:00:00 2001 From: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com> Date: Mon, 15 Nov 2021 19:45:02 -0600 Subject: [PATCH] Removed extra scaling call in image notebooks (#154) --- .../custom/showcase_custom_image_classification_batch.ipynb | 6 ++---- ...showcase_custom_image_classification_batch_explain.ipynb | 6 ++---- .../showcase_custom_image_classification_online.ipynb | 6 ++---- ...case_custom_image_classification_online_ab_testing.ipynb | 6 ++---- ...wcase_custom_image_classification_online_container.ipynb | 6 ++---- ...howcase_custom_image_classification_online_explain.ipynb | 6 ++---- ...ase_custom_image_classification_online_exported_ds.ipynb | 6 ++---- ...owcase_custom_image_classification_online_pipeline.ipynb | 6 ++---- ...wcase_custom_image_classification_online_tfserving.ipynb | 6 ++---- ...showcase_custom_image_super_resolution_online_post.ipynb | 6 ++---- 10 files changed, 20 insertions(+), 40 deletions(-) diff --git a/notebooks/community/gapic/custom/showcase_custom_image_classification_batch.ipynb b/notebooks/community/gapic/custom/showcase_custom_image_classification_batch.ipynb index 325b00367..02dc40068 100644 --- a/notebooks/community/gapic/custom/showcase_custom_image_classification_batch.ipynb +++ b/notebooks/community/gapic/custom/showcase_custom_image_classification_batch.ipynb @@ -1496,9 +1496,8 @@ "\n", "When you send a prediction or explanation request, the content of the request is base 64 decoded into a Tensorflow string (`tf.string`), which is passed to the serving function (`serving_fn`). The serving function preprocesses the `tf.string` into raw (uncompressed) numpy bytes (`preprocess_fn`) to match the input requirements of the model:\n", "- `io.decode_jpeg`- Decompresses the JPG image which is returned as a Tensorflow tensor with three channels (RGB).\n", - "- `image.convert_image_dtype` - Changes integer pixel values to float 32.\n", + "- `image.convert_image_dtype` - Changes integer pixel values to float 32, and rescales pixel data between 0 and 1.\n", "- `image.resize` - Resizes the image to match the input shape for the model.\n", - "- `resized / 255.0` - Rescales (normalization) the pixel data between 0 and 1.\n", "\n", "At this point, the data can be passed to the model (`m_call`)." ] @@ -1518,8 +1517,7 @@ " decoded = tf.io.decode_jpeg(bytes_input, channels=3)\n", " decoded = tf.image.convert_image_dtype(decoded, tf.float32)\n", " resized = tf.image.resize(decoded, size=(32, 32))\n", - " rescale = tf.cast(resized / 255.0, tf.float32)\n", - " return rescale\n", + " return resized\n", "\n", "\n", "@tf.function(input_signature=[tf.TensorSpec([None], tf.string)])\n", diff --git a/notebooks/community/gapic/custom/showcase_custom_image_classification_batch_explain.ipynb b/notebooks/community/gapic/custom/showcase_custom_image_classification_batch_explain.ipynb index d536ba245..3ad70735e 100644 --- a/notebooks/community/gapic/custom/showcase_custom_image_classification_batch_explain.ipynb +++ b/notebooks/community/gapic/custom/showcase_custom_image_classification_batch_explain.ipynb @@ -1521,9 +1521,8 @@ "\n", "When you send a prediction or explanation request, the content of the request is base 64 decoded into a Tensorflow string (`tf.string`), which is passed to the serving function (`serving_fn`). The serving function preprocesses the `tf.string` into raw (uncompressed) numpy bytes (`preprocess_fn`) to match the input requirements of the model:\n", "- `io.decode_jpeg`- Decompresses the JPG image which is returned as a Tensorflow tensor with three channels (RGB).\n", - "- `image.convert_image_dtype` - Changes integer pixel values to float 32.\n", + "- `image.convert_image_dtype` - Changes integer pixel values to float 32, and rescales pixel data between 0 and 1.\n", "- `image.resize` - Resizes the image to match the input shape for the model.\n", - "- `resized / 255.0` - Rescales (normalization) the pixel data between 0 and 1.\n", "\n", "At this point, the data can be passed to the model (`m_call`).\n", "\n", @@ -1552,8 +1551,7 @@ " decoded = tf.io.decode_jpeg(bytes_input, channels=3)\n", " decoded = tf.image.convert_image_dtype(decoded, tf.float32)\n", " resized = tf.image.resize(decoded, size=(32, 32))\n", - " rescale = tf.cast(resized / 255.0, tf.float32)\n", - " return rescale\n", + " return resized\n", "\n", "\n", "@tf.function(input_signature=[tf.TensorSpec([None], tf.string)])\n", diff --git a/notebooks/community/gapic/custom/showcase_custom_image_classification_online.ipynb b/notebooks/community/gapic/custom/showcase_custom_image_classification_online.ipynb index 108a4cb84..cc6c19136 100644 --- a/notebooks/community/gapic/custom/showcase_custom_image_classification_online.ipynb +++ b/notebooks/community/gapic/custom/showcase_custom_image_classification_online.ipynb @@ -1498,9 +1498,8 @@ "\n", "When you send a prediction or explanation request, the content of the request is base 64 decoded into a Tensorflow string (`tf.string`), which is passed to the serving function (`serving_fn`). The serving function preprocesses the `tf.string` into raw (uncompressed) numpy bytes (`preprocess_fn`) to match the input requirements of the model:\n", "- `io.decode_jpeg`- Decompresses the JPG image which is returned as a Tensorflow tensor with three channels (RGB).\n", - "- `image.convert_image_dtype` - Changes integer pixel values to float 32.\n", + "- `image.convert_image_dtype` - Changes integer pixel values to float 32, and rescales pixel data between 0 and 1.\n", "- `image.resize` - Resizes the image to match the input shape for the model.\n", - "- `resized / 255.0` - Rescales (normalization) the pixel data between 0 and 1.\n", "\n", "At this point, the data can be passed to the model (`m_call`)." ] @@ -1520,8 +1519,7 @@ " decoded = tf.io.decode_jpeg(bytes_input, channels=3)\n", " decoded = tf.image.convert_image_dtype(decoded, tf.float32)\n", " resized = tf.image.resize(decoded, size=(32, 32))\n", - " rescale = tf.cast(resized / 255.0, tf.float32)\n", - " return rescale\n", + " return resized\n", "\n", "\n", "@tf.function(input_signature=[tf.TensorSpec([None], tf.string)])\n", diff --git a/notebooks/community/gapic/custom/showcase_custom_image_classification_online_ab_testing.ipynb b/notebooks/community/gapic/custom/showcase_custom_image_classification_online_ab_testing.ipynb index e62fbabb0..e26d94c94 100644 --- a/notebooks/community/gapic/custom/showcase_custom_image_classification_online_ab_testing.ipynb +++ b/notebooks/community/gapic/custom/showcase_custom_image_classification_online_ab_testing.ipynb @@ -1761,9 +1761,8 @@ "\n", "When you send a prediction or explanation request, the content of the request is base 64 decoded into a Tensorflow string (`tf.string`), which is passed to the serving function (`serving_fn`). The serving function preprocesses the `tf.string` into raw (uncompressed) numpy bytes (`preprocess_fn`) to match the input requirements of the model:\n", "- `io.decode_jpeg`- Decompresses the JPG image which is returned as a Tensorflow tensor with three channels (RGB).\n", - "- `image.convert_image_dtype` - Changes integer pixel values to float 32.\n", + "- `image.convert_image_dtype` - Changes integer pixel values to float 32, and rescales pixel data between 0 and 1.\n", "- `image.resize` - Resizes the image to match the input shape for the model.\n", - "- `resized / 255.0` - Rescales (normalization) the pixel data between 0 and 1.\n", "\n", "At this point, the data can be passed to the model (`m_call`)." ] @@ -1783,8 +1782,7 @@ " decoded = tf.io.decode_jpeg(bytes_input, channels=3)\n", " decoded = tf.image.convert_image_dtype(decoded, tf.float32)\n", " resized = tf.image.resize(decoded, size=(32, 32))\n", - " rescale = tf.cast(resized / 255.0, tf.float32)\n", - " return rescale\n", + " return resized\n", "\n", "\n", "@tf.function(input_signature=[tf.TensorSpec([None], tf.string)])\n", diff --git a/notebooks/community/gapic/custom/showcase_custom_image_classification_online_container.ipynb b/notebooks/community/gapic/custom/showcase_custom_image_classification_online_container.ipynb index 93b6586ec..90395cea7 100644 --- a/notebooks/community/gapic/custom/showcase_custom_image_classification_online_container.ipynb +++ b/notebooks/community/gapic/custom/showcase_custom_image_classification_online_container.ipynb @@ -1600,9 +1600,8 @@ "\n", "When you send a prediction or explanation request, the content of the request is base 64 decoded into a Tensorflow string (`tf.string`), which is passed to the serving function (`serving_fn`). The serving function preprocesses the `tf.string` into raw (uncompressed) numpy bytes (`preprocess_fn`) to match the input requirements of the model:\n", "- `io.decode_jpeg`- Decompresses the JPG image which is returned as a Tensorflow tensor with three channels (RGB).\n", - "- `image.convert_image_dtype` - Changes integer pixel values to float 32.\n", + "- `image.convert_image_dtype` - Changes integer pixel values to float 32, and rescales pixel data between 0 and 1.\n", "- `image.resize` - Resizes the image to match the input shape for the model.\n", - "- `resized / 255.0` - Rescales (normalization) the pixel data between 0 and 1.\n", "\n", "At this point, the data can be passed to the model (`m_call`)." ] @@ -1622,8 +1621,7 @@ " decoded = tf.io.decode_jpeg(bytes_input, channels=3)\n", " decoded = tf.image.convert_image_dtype(decoded, tf.float32)\n", " resized = tf.image.resize(decoded, size=(32, 32))\n", - " rescale = tf.cast(resized / 255.0, tf.float32)\n", - " return rescale\n", + " return resized\n", "\n", "\n", "@tf.function(input_signature=[tf.TensorSpec([None], tf.string)])\n", diff --git a/notebooks/community/gapic/custom/showcase_custom_image_classification_online_explain.ipynb b/notebooks/community/gapic/custom/showcase_custom_image_classification_online_explain.ipynb index b7fcf5b0c..b01495a7d 100644 --- a/notebooks/community/gapic/custom/showcase_custom_image_classification_online_explain.ipynb +++ b/notebooks/community/gapic/custom/showcase_custom_image_classification_online_explain.ipynb @@ -1523,9 +1523,8 @@ "\n", "When you send a prediction or explanation request, the content of the request is base 64 decoded into a Tensorflow string (`tf.string`), which is passed to the serving function (`serving_fn`). The serving function preprocesses the `tf.string` into raw (uncompressed) numpy bytes (`preprocess_fn`) to match the input requirements of the model:\n", "- `io.decode_jpeg`- Decompresses the JPG image which is returned as a Tensorflow tensor with three channels (RGB).\n", - "- `image.convert_image_dtype` - Changes integer pixel values to float 32.\n", + "- `image.convert_image_dtype` - Changes integer pixel values to float 32, and rescales pixel data between 0 and 1.\n", "- `image.resize` - Resizes the image to match the input shape for the model.\n", - "- `resized / 255.0` - Rescales (normalization) the pixel data between 0 and 1.\n", "\n", "At this point, the data can be passed to the model (`m_call`).\n", "\n", @@ -1554,8 +1553,7 @@ " decoded = tf.io.decode_jpeg(bytes_input, channels=3)\n", " decoded = tf.image.convert_image_dtype(decoded, tf.float32)\n", " resized = tf.image.resize(decoded, size=(32, 32))\n", - " rescale = tf.cast(resized / 255.0, tf.float32)\n", - " return rescale\n", + " return resized\n", "\n", "\n", "@tf.function(input_signature=[tf.TensorSpec([None], tf.string)])\n", diff --git a/notebooks/community/gapic/custom/showcase_custom_image_classification_online_exported_ds.ipynb b/notebooks/community/gapic/custom/showcase_custom_image_classification_online_exported_ds.ipynb index ee142b5b7..37ceac1ef 100644 --- a/notebooks/community/gapic/custom/showcase_custom_image_classification_online_exported_ds.ipynb +++ b/notebooks/community/gapic/custom/showcase_custom_image_classification_online_exported_ds.ipynb @@ -2103,9 +2103,8 @@ "\n", "When you send a prediction or explanation request, the content of the request is base 64 decoded into a Tensorflow string (`tf.string`), which is passed to the serving function (`serving_fn`). The serving function preprocesses the `tf.string` into raw (uncompressed) numpy bytes (`preprocess_fn`) to match the input requirements of the model:\n", "- `io.decode_jpeg`- Decompresses the JPG image which is returned as a Tensorflow tensor with three channels (RGB).\n", - "- `image.convert_image_dtype` - Changes integer pixel values to float 32.\n", + "- `image.convert_image_dtype` - Changes integer pixel values to float 32, and rescales pixel data between 0 and 1.\n", "- `image.resize` - Resizes the image to match the input shape for the model.\n", - "- `resized / 255.0` - Rescales (normalization) the pixel data between 0 and 1.\n", "\n", "At this point, the data can be passed to the model (`m_call`)." ] @@ -2125,8 +2124,7 @@ " decoded = tf.io.decode_jpeg(bytes_input, channels=3)\n", " decoded = tf.image.convert_image_dtype(decoded, tf.float32)\n", " resized = tf.image.resize(decoded, size=(128, 128))\n", - " rescale = tf.cast(resized / 255.0, tf.float32)\n", - " return rescale\n", + " return resized\n", "\n", "\n", "@tf.function(input_signature=[tf.TensorSpec([None], tf.string)])\n", diff --git a/notebooks/community/gapic/custom/showcase_custom_image_classification_online_pipeline.ipynb b/notebooks/community/gapic/custom/showcase_custom_image_classification_online_pipeline.ipynb index bf6fd660e..afac8ab2d 100644 --- a/notebooks/community/gapic/custom/showcase_custom_image_classification_online_pipeline.ipynb +++ b/notebooks/community/gapic/custom/showcase_custom_image_classification_online_pipeline.ipynb @@ -1567,9 +1567,8 @@ "\n", "When you send a prediction or explanation request, the content of the request is base 64 decoded into a Tensorflow string (`tf.string`), which is passed to the serving function (`serving_fn`). The serving function preprocesses the `tf.string` into raw (uncompressed) numpy bytes (`preprocess_fn`) to match the input requirements of the model:\n", "- `io.decode_jpeg`- Decompresses the JPG image which is returned as a Tensorflow tensor with three channels (RGB).\n", - "- `image.convert_image_dtype` - Changes integer pixel values to float 32.\n", + "- `image.convert_image_dtype` - Changes integer pixel values to float 32, and rescales pixel data between 0 and 1.\n", "- `image.resize` - Resizes the image to match the input shape for the model.\n", - "- `resized / 255.0` - Rescales (normalization) the pixel data between 0 and 1.\n", "\n", "At this point, the data can be passed to the model (`m_call`)." ] @@ -1589,8 +1588,7 @@ " decoded = tf.io.decode_jpeg(bytes_input, channels=3)\n", " decoded = tf.image.convert_image_dtype(decoded, tf.float32)\n", " resized = tf.image.resize(decoded, size=(32, 32))\n", - " rescale = tf.cast(resized / 255.0, tf.float32)\n", - " return rescale\n", + " return resized\n", "\n", "\n", "@tf.function(input_signature=[tf.TensorSpec([None], tf.string)])\n", diff --git a/notebooks/community/gapic/custom/showcase_custom_image_classification_online_tfserving.ipynb b/notebooks/community/gapic/custom/showcase_custom_image_classification_online_tfserving.ipynb index 54b9c632b..f87c53a65 100644 --- a/notebooks/community/gapic/custom/showcase_custom_image_classification_online_tfserving.ipynb +++ b/notebooks/community/gapic/custom/showcase_custom_image_classification_online_tfserving.ipynb @@ -1559,9 +1559,8 @@ "\n", "When you send a prediction or explanation request, the content of the request is base 64 decoded into a Tensorflow string (`tf.string`), which is passed to the serving function (`serving_fn`). The serving function preprocesses the `tf.string` into raw (uncompressed) numpy bytes (`preprocess_fn`) to match the input requirements of the model:\n", "- `io.decode_jpeg`- Decompresses the JPG image which is returned as a Tensorflow tensor with three channels (RGB).\n", - "- `image.convert_image_dtype` - Changes integer pixel values to float 32.\n", + "- `image.convert_image_dtype` - Changes integer pixel values to float 32, and rescales pixel data between 0 and 1.\n", "- `image.resize` - Resizes the image to match the input shape for the model.\n", - "- `resized / 255.0` - Rescales (normalization) the pixel data between 0 and 1.\n", "\n", "At this point, the data can be passed to the model (`m_call`)." ] @@ -1581,8 +1580,7 @@ " decoded = tf.io.decode_jpeg(bytes_input, channels=3)\n", " decoded = tf.image.convert_image_dtype(decoded, tf.float32)\n", " resized = tf.image.resize(decoded, size=(32, 32))\n", - " rescale = tf.cast(resized / 255.0, tf.float32)\n", - " return rescale\n", + " return resized\n", "\n", "\n", "@tf.function(input_signature=[tf.TensorSpec([None], tf.string)])\n", diff --git a/notebooks/community/gapic/custom/showcase_custom_image_super_resolution_online_post.ipynb b/notebooks/community/gapic/custom/showcase_custom_image_super_resolution_online_post.ipynb index 028a9cd5c..6e50f5b21 100644 --- a/notebooks/community/gapic/custom/showcase_custom_image_super_resolution_online_post.ipynb +++ b/notebooks/community/gapic/custom/showcase_custom_image_super_resolution_online_post.ipynb @@ -1501,9 +1501,8 @@ "\n", "When you send a prediction or explanation request, the content of the request is base 64 decoded into a Tensorflow string (`tf.string`), which is passed to the serving function (`serving_fn`). The serving function preprocesses the `tf.string` into raw (uncompressed) numpy bytes (`preprocess_fn`) to match the input requirements of the model:\n", "- `io.decode_jpeg`- Decompresses the JPG image which is returned as a Tensorflow tensor with three channels (RGB).\n", - "- `image.convert_image_dtype` - Changes integer pixel values to float 32.\n", + "- `image.convert_image_dtype` - Changes integer pixel values to float 32, and rescales pixel data between 0 and 1.\n", "- `image.resize` - Resizes the image to match the input shape for the model.\n", - "- `resized / 255.0` - Rescales (normalization) the pixel data between 0 and 1.\n", "\n", "At this point, the data can be passed to the model (`m_call`).\n", "\n", @@ -1529,8 +1528,7 @@ " decoded = tf.io.decode_jpeg(bytes_input, channels=3)\n", " decoded = tf.image.convert_image_dtype(decoded, tf.float32)\n", " resized = tf.image.resize(decoded, size=(16, 16))\n", - " rescale = tf.cast(resized / 255.0, tf.float32)\n", - " return rescale\n", + " return resized\n", "\n", "\n", "@tf.function(input_signature=[tf.TensorSpec([None], tf.string)])\n",