From 1b0a3e8f90cf4afe582fe28e0609b6954d366bc8 Mon Sep 17 00:00:00 2001 From: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com> Date: Tue, 16 Nov 2021 17:05:26 -0600 Subject: [PATCH] Linting updates for PR #154 (#155) * Removed extra scaling call in image notebooks * formatting/linting updates --- .../showcase_custom_image_classification_batch.ipynb | 3 +-- ...e_custom_image_classification_batch_explain.ipynb | 3 +-- ...showcase_custom_image_classification_online.ipynb | 3 +-- ...stom_image_classification_online_ab_testing.ipynb | 12 +++++------- ...ustom_image_classification_online_container.ipynb | 3 +-- ..._custom_image_classification_online_explain.ipynb | 3 +-- ...tom_image_classification_online_exported_ds.ipynb | 3 +-- ...custom_image_classification_online_pipeline.ipynb | 6 +----- ...ustom_image_classification_online_tfserving.ipynb | 3 +-- ...e_custom_image_super_resolution_online_post.ipynb | 3 +-- 10 files changed, 14 insertions(+), 28 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 02dc40068..746d0ea36 100644 --- a/notebooks/community/gapic/custom/showcase_custom_image_classification_batch.ipynb +++ b/notebooks/community/gapic/custom/showcase_custom_image_classification_batch.ipynb @@ -480,8 +480,7 @@ "\n", "from google.cloud.aiplatform import gapic as aip\n", "from google.protobuf import json_format\n", - "from google.protobuf.json_format import MessageToJson, ParseDict\n", - "from google.protobuf.struct_pb2 import Struct, Value" + "from google.protobuf.struct_pb2 import Value" ] }, { 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 3ad70735e..fe91ee98d 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 @@ -505,8 +505,7 @@ "\n", "import google.cloud.aiplatform_v1beta1 as aip\n", "from google.protobuf import json_format\n", - "from google.protobuf.json_format import MessageToJson, ParseDict\n", - "from google.protobuf.struct_pb2 import Struct, Value" + "from google.protobuf.struct_pb2 import Value" ] }, { 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 cc6c19136..840af4d19 100644 --- a/notebooks/community/gapic/custom/showcase_custom_image_classification_online.ipynb +++ b/notebooks/community/gapic/custom/showcase_custom_image_classification_online.ipynb @@ -482,8 +482,7 @@ "\n", "from google.cloud.aiplatform import gapic as aip\n", "from google.protobuf import json_format\n", - "from google.protobuf.json_format import MessageToJson, ParseDict\n", - "from google.protobuf.struct_pb2 import Struct, Value" + "from google.protobuf.struct_pb2 import Value" ] }, { 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 e26d94c94..60de10634 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 @@ -483,8 +483,7 @@ "\n", "from google.cloud.aiplatform import gapic as aip\n", "from google.protobuf import json_format\n", - "from google.protobuf.json_format import MessageToJson, ParseDict\n", - "from google.protobuf.struct_pb2 import Struct, Value" + "from google.protobuf.struct_pb2 import Value" ] }, { @@ -1710,7 +1709,7 @@ "outputs": [], "source": [ "import tensorflow as tf\n", - "from tensorflow.keras import Input, Model\n", + "from tensorflow.keras import Model\n", "from tensorflow.keras.layers import Lambda\n", "\n", "softmax = model_A.outputs[0]\n", @@ -1822,16 +1821,15 @@ "CONCRETE_INPUT = \"numpy_inputs\"\n", "\n", "\n", - "def _preprocess(bytes_input):\n", + "def _preprocess(bytes_input): # noqa: 811\n", " 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", - "def preprocess_fn(bytes_inputs):\n", + "def preprocess_fn(bytes_inputs): # noqa: 811\n", " decoded_images = tf.map_fn(\n", " _preprocess, bytes_inputs, dtype=tf.float32, back_prop=False\n", " )\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 90395cea7..9925d43c9 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 @@ -482,8 +482,7 @@ "\n", "from google.cloud.aiplatform import gapic as aip\n", "from google.protobuf import json_format\n", - "from google.protobuf.json_format import MessageToJson, ParseDict\n", - "from google.protobuf.struct_pb2 import Struct, Value" + "from google.protobuf.struct_pb2 import Value" ] }, { 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 b01495a7d..a55506daa 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 @@ -507,8 +507,7 @@ "\n", "import google.cloud.aiplatform_v1beta1 as aip\n", "from google.protobuf import json_format\n", - "from google.protobuf.json_format import MessageToJson, ParseDict\n", - "from google.protobuf.struct_pb2 import Struct, Value" + "from google.protobuf.struct_pb2 import Value" ] }, { 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 37ceac1ef..0b9d6dd6c 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 @@ -484,8 +484,7 @@ "\n", "from google.cloud.aiplatform import gapic as aip\n", "from google.protobuf import json_format\n", - "from google.protobuf.json_format import MessageToJson, ParseDict\n", - "from google.protobuf.struct_pb2 import Struct, Value" + "from google.protobuf.struct_pb2 import Value" ] }, { 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 afac8ab2d..e420f343a 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 @@ -483,8 +483,7 @@ "\n", "from google.cloud.aiplatform import gapic as aip\n", "from google.protobuf import json_format\n", - "from google.protobuf.json_format import MessageToJson, ParseDict\n", - "from google.protobuf.struct_pb2 import Struct, Value" + "from google.protobuf.struct_pb2 import Value" ] }, { @@ -1247,9 +1246,6 @@ }, "outputs": [], "source": [ - "from google.protobuf import json_format\n", - "from google.protobuf.struct_pb2 import Value\n", - "\n", "MODEL_NAME = \"custom_pipeline-\" + TIMESTAMP\n", "PIPELINE_DISPLAY_NAME = \"custom-training-pipeline\" + TIMESTAMP\n", "\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 f87c53a65..ccbd62e6c 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 @@ -482,8 +482,7 @@ "\n", "from google.cloud.aiplatform import gapic as aip\n", "from google.protobuf import json_format\n", - "from google.protobuf.json_format import MessageToJson, ParseDict\n", - "from google.protobuf.struct_pb2 import Struct, Value" + "from google.protobuf.struct_pb2 import Value" ] }, { 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 6e50f5b21..e8c87fb3c 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 @@ -483,8 +483,7 @@ "\n", "from google.cloud.aiplatform import gapic as aip\n", "from google.protobuf import json_format\n", - "from google.protobuf.json_format import MessageToJson, ParseDict\n", - "from google.protobuf.struct_pb2 import Struct, Value" + "from google.protobuf.struct_pb2 import Value" ] }, {