Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No public description #3

Closed
wants to merge 1 commit into from
Closed
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,26 @@
"source": [
"# Vertex AI Model Garden: Google Proprietary Model Image Classification\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/model_garden/model_garden_proprietary_image_classification.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
"\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/model_garden/model_garden_proprietary_image_classification.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
"\u003ctable align=\"left\"\u003e\n",
" \u003ctd\u003e\n",
" \u003ca href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/model_garden/model_garden_proprietary_image_classification.ipynb\"\u003e\n",
" \u003cimg src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"\u003e Run in Colab\n",
" \u003c/a\u003e\n",
" \u003c/td\u003e\n",
"\n",
" \u003ctd\u003e\n",
" \u003ca href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/model_garden/model_garden_proprietary_image_classification.ipynb\"\u003e\n",
" \u003cimg src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\"\u003e\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/notebooks/deploy-notebook?download_url=https://github.com/raw/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/model_garden/model_garden_proprietary_image_classification.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" \u003c/a\u003e\n",
" \u003c/td\u003e\n",
" \u003ctd\u003e\n",
" \u003ca href=\"https://console.cloud.google.com/vertex-ai/notebooks/deploy-notebook?download_url=https://github.com/raw/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/model_garden/model_garden_proprietary_image_classification.ipynb\"\u003e\n",
" \u003cimg src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\"\u003e\n",
"Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>"
" \u003c/a\u003e\n",
" \u003c/td\u003e\n",
"\u003c/table\u003e"
]
},
{
Expand Down Expand Up @@ -128,9 +128,9 @@
"app = IPython.Application.instance()\n",
"app.kernel.do_shutdown(True)\n",
"if \"google.colab\" in str(get_ipython()):\n",
" from google.colab import auth as google_auth\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()"
" google_auth.authenticate_user()"
]
},
{
Expand Down Expand Up @@ -176,11 +176,11 @@
"# You can choose a region from https://cloud.google.com/about/locations.\n",
"# Only regions prefixed by \"us\", \"europe\", or \"asia\" are supported.\n",
"REGION = \"us-central1\" # @param {type:\"string\"}\n",
"REGION_PREFIX = REGION.split(\"-\")[0]\n",
"REGION_PREFIX = REGION.split('-')[0]\n",
"assert REGION_PREFIX in (\n",
" \"us\",\n",
" \"europe\",\n",
" \"asia\",\n",
" \"asia\"\n",
"), f'{REGION} is not supported. It must be prefixed by \"us\", \"europe\", or \"asia\".'\n",
"\n",
"! gcloud config set project $PROJECT_ID\n",
Expand Down Expand Up @@ -270,7 +270,7 @@
"\n",
"\n",
"def get_prediction_instances(test_filepath, new_width=-1):\n",
" if new_width <= 0:\n",
" if new_width \u003c= 0:\n",
" with tf.io.gfile.GFile(test_filepath, \"rb\") as input_file:\n",
" encoded_string = base64.b64encode(input_file.read()).decode(\"utf-8\")\n",
" else:\n",
Expand Down Expand Up @@ -557,7 +557,7 @@
"source": [
"# @title Run online predictions\n",
"\n",
"# test image file path from a Cloud Storage bucket\n",
"# test image file path from a GCS bucket\n",
"test_filepath = \"\" # @param {type:\"string\"}\n",
"\n",
"with tf.io.gfile.GFile(test_filepath, \"rb\") as f:\n",
Expand All @@ -583,8 +583,8 @@
"Now that your Model resource is trained, you can make a batch prediction by invoking the `batch_predict()` method, with the following parameters:\n",
"\n",
"* `job_display_name`: The human readable name for the batch prediction job.\n",
"* `gcs_source`: A jsonl file path from a Cloud Storage bucket, with a list of one or more images.\n",
"* `gcs_destination_prefix`: The Cloud Storage location for storing the batch prediction resuls.\n",
"* `gcs_source`: A jsonl file path from a GCS bucket, with a list of one or more images.\n",
"* `gcs_destination_prefix`: The GCS location for storing the batch prediction resuls.\n",
"* `sync`: If set to True, the call block while waiting for the asynchronous batch job to complete."
]
},
Expand All @@ -596,7 +596,7 @@
},
"outputs": [],
"source": [
"# A jsonl file path from a Cloud Storage bucket, with all the to-be-predicted images.\n",
"# A jsonl file path from a GCS bucket, with all the to-be-predicted images.\n",
"gcs_source = \"\" # @param {type:\"string\"}\n",
"\n",
"batch_predict_job = model.batch_predict(\n",
Expand All @@ -613,7 +613,6 @@
"\n",
"# Get the batch prediction results\n",
"import json\n",
"\n",
"import tensorflow as tf\n",
"\n",
"bp_iter_outputs = batch_predict_job.iter_outputs()\n",
Expand Down Expand Up @@ -671,7 +670,8 @@
],
"metadata": {
"colab": {
"name": "model_garden_proprietary_image_classification.ipynb",
"private_outputs": true,
"provenance": [],
"toc_visible": true
},
"kernelspec": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,26 @@
"source": [
"# Vertex AI Model Garden: Google Proprietary Model Image Object Detection\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/model_garden/model_garden_proprietary_image_object_detection.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
"\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/model_garden/model_garden_proprietary_image_object_detection.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
"\u003ctable align=\"left\"\u003e\n",
" \u003ctd\u003e\n",
" \u003ca href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/model_garden/model_garden_proprietary_image_object_detection.ipynb\"\u003e\n",
" \u003cimg src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"\u003e Run in Colab\n",
" \u003c/a\u003e\n",
" \u003c/td\u003e\n",
"\n",
" \u003ctd\u003e\n",
" \u003ca href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/model_garden/model_garden_proprietary_image_object_detection.ipynb\"\u003e\n",
" \u003cimg src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\"\u003e\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/notebooks/deploy-notebook?download_url=https://github.com/raw/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/model_garden/model_garden_proprietary_image_object_detection.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" \u003c/a\u003e\n",
" \u003c/td\u003e\n",
" \u003ctd\u003e\n",
" \u003ca href=\"https://console.cloud.google.com/vertex-ai/notebooks/deploy-notebook?download_url=https://github.com/raw/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/model_garden/model_garden_proprietary_image_object_detection.ipynb\"\u003e\n",
" \u003cimg src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\"\u003e\n",
"Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>"
" \u003c/a\u003e\n",
" \u003c/td\u003e\n",
"\u003c/table\u003e"
]
},
{
Expand Down Expand Up @@ -176,11 +176,11 @@
"# You can choose a region from https://cloud.google.com/about/locations.\n",
"# Only regions prefixed by \"us\", \"europe\", or \"asia\" are supported.\n",
"REGION = \"us-central1\" # @param {type:\"string\"}\n",
"REGION_PREFIX = REGION.split(\"-\")[0]\n",
"REGION_PREFIX = REGION.split('-')[0]\n",
"assert REGION_PREFIX in (\n",
" \"us\",\n",
" \"europe\",\n",
" \"asia\",\n",
" \"asia\"\n",
"), f'{REGION} is not supported. It must be prefixed by \"us\", \"europe\", or \"asia\".'\n",
"\n",
"! gcloud config set project $PROJECT_ID\n",
Expand Down Expand Up @@ -292,7 +292,7 @@
" # Each display_str has a top and bottom margin of 0.05x.\n",
" total_display_str_height = (1 + 2 * 0.05) * sum(display_str_heights)\n",
"\n",
" if top > total_display_str_height:\n",
" if top \u003e total_display_str_height:\n",
" text_bottom = top\n",
" else:\n",
" text_bottom = top + total_display_str_height\n",
Expand Down Expand Up @@ -328,7 +328,7 @@
" font = ImageFont.load_default()\n",
"\n",
" for i in range(min(len(boxes), max_boxes)):\n",
" if scores[i] >= min_score:\n",
" if scores[i] \u003e= min_score:\n",
" ymin, xmin, ymax, xmax = boxes[i]\n",
" display_str = \"{}: {}%\".format(class_names[i], int(100 * scores[i]))\n",
" color = colors[hash(class_names[i]) % len(colors)]\n",
Expand Down Expand Up @@ -630,7 +630,7 @@
"source": [
"# @title Run online predictions\n",
"\n",
"# test image file path from a Cloud Storage bucket\n",
"# test image file path from a GCS bucket\n",
"test_filepath = \"\" # @param {type:\"string\"}\n",
"\n",
"with tf.io.gfile.GFile(test_filepath, \"rb\") as f:\n",
Expand All @@ -656,8 +656,8 @@
"Now that your Model resource is trained, you can make a batch prediction by invoking the `batch_predict()` method, with the following parameters:\n",
"\n",
"* `job_display_name`: The human readable name for the batch prediction job.\n",
"* `gcs_source`: A jsonl file path from a Cloud Storage bucket, with a list of one or more images.\n",
"* `gcs_destination_prefix`: The Cloud Storage location for storing the batch prediction resuls.\n",
"* `gcs_source`: A jsonl file path from a GCS bucket, with a list of one or more images.\n",
"* `gcs_destination_prefix`: The GCS location for storing the batch prediction resuls.\n",
"* `sync`: If set to True, the call block while waiting for the asynchronous batch job to complete."
]
},
Expand All @@ -669,7 +669,7 @@
},
"outputs": [],
"source": [
"# A jsonl file path from a Cloud Storage bucket, with all the to-be-predicted images.\n",
"# A jsonl file path from a GCS bucket, with all the to-be-predicted images.\n",
"gcs_source = \"\" # @param {type:\"string\"}\n",
"\n",
"batch_predict_job = model.batch_predict(\n",
Expand All @@ -686,7 +686,6 @@
"\n",
"# Get the batch prediction results\n",
"import json\n",
"\n",
"import tensorflow as tf\n",
"\n",
"bp_iter_outputs = batch_predict_job.iter_outputs()\n",
Expand All @@ -703,7 +702,7 @@
" for line in gfile.readlines():\n",
" line = json.loads(line)\n",
" print(line)\n",
" break"
" break\n"
]
},
{
Expand Down Expand Up @@ -745,6 +744,7 @@
"metadata": {
"colab": {
"name": "model_garden_proprietary_image_object_detection.ipynb",
"provenance": [],
"toc_visible": true
},
"kernelspec": {
Expand Down
Loading
Loading