Compare commits

...
93 Commits
Author SHA1 Message Date
Andrew Ferlitsch fe42cb6ebd fix: one notebook rule 2023-03-14 21:46:43 +00:00
Andrew Ferlitsch f9be4f470d fix: use public image 2023-03-14 21:29:54 +00:00
Andrew Ferlitsch 309889bf6b fix: simplified linter step 2023-03-14 20:55:44 +00:00
gericdongandGitHub c0196a16b8 Merge pull request #1602 from GoogleCloudPlatform/issue_1599
fix: issue 1599
2023-03-14 16:44:17 +00:00
Andrew FerlitschandGitHub 8ecc2c25c6 Merge pull request #1591 from GoogleCloudPlatform/multicontender_vs_champion
feat: notebook for multicontender vs champion deployment
2023-03-14 01:31:18 +00:00
Andrew FerlitschandGitHub d98d427271 Merge pull request #1600 from iversonic/patch-1
Fix typo in title
2023-03-13 22:11:53 +00:00
Mark IversonandGitHub b35c2a89cb Fix typo in title 2023-03-13 14:15:02 -07:00
gericdongandGitHub bc93be1651 Merge pull request #1598 from gericdong/b267510213
chore: updated the XGBoost Dask notebook subject and text to be more specific
2023-03-13 18:01:07 +00:00
gericdong baa9c06cf7 Updated the objective 2023-03-13 13:55:35 -04:00
gericdongandGitHub 3f3ef75aba Merge pull request #1593 from GoogleCloudPlatform/bad_links_blessed
fix: bad links
2023-03-13 17:49:18 +00:00
Andrew FerlitschandGitHub 1a2a0f1d50 Update multicontender_vs_champion_deployment_method.ipynb 2023-03-13 09:07:53 -07:00
Andrew FerlitschandGitHub 93a099f65b Update challenger_vs_blessed_deployment_method.ipynb 2023-03-13 09:06:40 -07:00
gericdong b6804cdf78 chore: updated the notebook text to be more specific 2023-03-13 10:54:22 -04:00
Andrew FerlitschandGitHub b641e0857e Merge pull request #1371 from btrinh69/prediction-featurestore-integration
add an E2E notebook for Prediction and Featurestore integration
2023-03-11 01:48:11 +00:00
Andrew FerlitschandGitHub e12faf03ed Merge pull request #1597 from btrinh69/fs-integration-notebook
Add an introduction section and more details to the doc
2023-03-11 01:46:32 +00:00
btrinh69 d24f0d0f21 fix linter 2023-03-10 23:58:27 +00:00
btrinh69 c50d38e82f Add an introduction section and more details to the doc 2023-03-10 23:44:36 +00:00
gericdongandGitHub 52f458fd7d Merge pull request #1596 from gericdong/b269273823-2
fix: Incorporated Tech Writer's feedback on the PyTorch container notebook
2023-03-10 19:16:28 +00:00
gericdong eeaf34aa3b fix: address tech writer feedback on the PyTorch container notebook 2 2023-03-10 14:13:54 -05:00
gericdong 705f64dc32 fix: address tech writer feedback on the PyTorch container notebook 2023-03-10 14:04:25 -05:00
Eric SchmidtandGitHub 3830e14fd6 Merge pull request #1595 from GoogleCloudPlatform/cohost_linkback
fix: linkback
2023-03-10 18:09:11 +00:00
Eric SchmidtandGitHub bd55db1efc Merge pull request #1594 from GoogleCloudPlatform/linkback_mm
fix: linkback
2023-03-10 17:21:42 +00:00
Andrew Ferlitsch 07c0f3710f fix: linkback 2023-03-10 17:16:00 +00:00
Andrew Ferlitsch f9de0b6315 fix: linkback 2023-03-10 16:55:09 +00:00
Andrew Ferlitsch 5052d1f44d fix: bad links 2023-03-10 16:48:54 +00:00
Andrew Ferlitsch 35fbd744e2 fix: bad links 2023-03-10 16:43:30 +00:00
Andrew Ferlitsch 6d394e639c fix: bad links 2023-03-10 16:41:11 +00:00
Andrew Ferlitsch 540410ba89 fix: kfp install 2023-03-10 16:16:19 +00:00
Andrew FerlitschandGitHub 26e6548988 Merge pull request #1592 from gericdong/b269273823
feat: add a notebook sample for PyTorch image models with prebuilt containers
2023-03-09 21:34:49 +00:00
Andrew Ferlitsch 16de6f1b99 fix: review comments 2023-03-09 21:29:47 +00:00
gericdong 8cb2e868ce Updated with review commentss 2 2023-03-09 15:59:44 -05:00
gericdong 3153e24e57 Updated with review commentss 2023-03-09 15:55:08 -05:00
Andrew FerlitschandGitHub f40a81dda7 Merge pull request #1574 from inardini/inardini--experiments-autologging
feat: add notebook for experiments autologging
2023-03-09 20:45:17 +00:00
Andrew Ferlitsch 1590d1cc6f fix: install gcpc 2023-03-09 20:44:43 +00:00
gericdong 6b065f1c5a feat: add notebook for PyTorch image models with prebuilt containers 2023-03-09 15:23:41 -05:00
Andrew Ferlitsch b88fddd6bb fix: install kfp 2023-03-09 20:21:14 +00:00
Andrew Ferlitsch 22454b5318 fix: install kfp 2023-03-09 19:54:13 +00:00
Andrew FerlitschandGitHub e26190b5e3 Update get_started_with_vertex_experiments_autologging.ipynb 2023-03-09 11:49:37 -08:00
Andrew Ferlitsch e6ecd23556 feat: notebook for multicontender vs champion deployment 2023-03-09 19:17:15 +00:00
Andrew FerlitschandGitHub a342923353 Update get_started_with_vertex_experiments_autologging.ipynb 2023-03-09 10:59:34 -08:00
Andrew FerlitschandGitHub 0adcf3d60c Merge pull request #1584 from GoogleCloudPlatform/reznitskii-patch-19
Fixed title and grammar mistakes
2023-03-08 16:36:17 +00:00
Andrew FerlitschandGitHub 49547be529 Update get_started_with_vertex_experiments_autologging.ipynb 2023-03-07 17:37:33 -08:00
Andrew FerlitschandGitHub 9dbd6303b0 Update get_started_with_vertex_experiments_autologging.ipynb 2023-03-07 16:55:59 -08:00
Andrew FerlitschandGitHub ac049f3de1 Update get_started_with_vertex_experiments_autologging.ipynb 2023-03-07 16:45:16 -08:00
Andrew FerlitschandGitHub 3bca163dea Update get_started_with_vertex_experiments_autologging.ipynb 2023-03-07 16:32:06 -08:00
Andrew FerlitschandGitHub 8904b43308 Merge pull request #1580 from GoogleCloudPlatform/reznitskii-patch-15
Fixed title
2023-03-08 00:26:54 +00:00
Andrew FerlitschandGitHub 828926e9ab Update UJ15 Vertex SDK AutoML Object Tracking.ipynb 2023-03-07 16:26:15 -08:00
Ivan CheungandGitHub 851dfb72c1 Merge pull request #1590 from GoogleCloudPlatform/imkc--matching-engine-text-to-image-fix
Fixed broken markdown in matching engine notebooks
2023-03-08 00:06:42 +00:00
Andrew FerlitschandGitHub dea652ceca Merge pull request #1589 from GoogleCloudPlatform/reznitskii-patch-23
Fixed title
2023-03-08 00:06:08 +00:00
Andrew FerlitschandGitHub 56310240b3 Merge pull request #1587 from GoogleCloudPlatform/reznitskii-patch-22
Fixed title and grammar
2023-03-08 00:05:31 +00:00
Andrew FerlitschandGitHub d828534f28 Merge pull request #1586 from GoogleCloudPlatform/reznitskii-patch-21
Fixed title and grammar
2023-03-07 21:35:10 +00:00
Andrew FerlitschandGitHub 5b6340a15e Merge pull request #1585 from GoogleCloudPlatform/reznitskii-patch-20
Fixed title
2023-03-07 21:34:39 +00:00
Andrew FerlitschandGitHub 2d3a490aca Merge pull request #1583 from GoogleCloudPlatform/reznitskii-patch-18
Fixed title and grammar mistakes
2023-03-07 21:34:08 +00:00
Andrew FerlitschandGitHub 764ea292e5 Merge pull request #1582 from GoogleCloudPlatform/reznitskii-patch-17
Fixed title and typos
2023-03-07 21:33:28 +00:00
Andrew FerlitschandGitHub 867410462e Merge pull request #1581 from GoogleCloudPlatform/reznitskii-patch-16
Update UJ10 Vertex SDK Custom Scikit-Learn with pre-built training co…
2023-03-07 21:33:00 +00:00
Andrew FerlitschandGitHub 1874743d19 Merge pull request #1579 from GoogleCloudPlatform/reznitskii-patch-14
Added link
2023-03-07 21:32:17 +00:00
Andrew FerlitschandGitHub b19fcc9f66 Merge pull request #1578 from GoogleCloudPlatform/reznitskii-patch-13
Added link
2023-03-07 21:31:38 +00:00
Andrew FerlitschandGitHub 12db1f9e05 Merge pull request #1588 from GoogleCloudPlatform/autoindex_march_update
update: March update of index
2023-03-07 21:30:58 +00:00
ivanmkc@google.com 853b5c0a97 Fixed broken markdown 2023-03-07 15:40:35 -05:00
reznitskiiandGitHub 00aa9a2672 Update UJ5 Vertex SDK AutoML Image Object Detection.ipynb 2023-03-07 15:09:55 -05:00
Andrew Ferlitsch 7eb4eea074 update: march update of index 2023-03-07 20:06:00 +00:00
reznitskiiandGitHub 4b8b1e503b Update UJ4 Vertex SDK AutoML Tabular Binary Classification.ipynb 2023-03-07 14:34:47 -05:00
reznitskiiandGitHub db0f7fb6d7 Update UJ3 Vertex SDK Custom Image Classification with custom training container.ipynb 2023-03-07 14:30:15 -05:00
reznitskiiandGitHub cd04f66ac0 Update UJ2,12 Vertex SDK Custom Image Classification with pre-built training container.ipynb 2023-03-07 14:24:54 -05:00
reznitskiiandGitHub 419e01d1d3 Update UJ15 Vertex SDK AutoML Object Tracking.ipynb 2023-03-07 14:23:06 -05:00
reznitskiiandGitHub e7a51b394b Update UJ14 Vertex SDK AutoML Video Classification.ipynb 2023-03-07 14:22:16 -05:00
reznitskiiandGitHub fdfec862be Update UJ11 Vertex SDK Hyperparameter Tuning.ipynb 2023-03-07 14:21:24 -05:00
reznitskiiandGitHub 6da196a80b Update UJ10 Vertex SDK Custom Scikit-Learn with pre-built training container.ipynb 2023-03-07 14:19:24 -05:00
reznitskiiandGitHub 280f62a1d3 Update UJ1 Vertex SDK AutoML Image Classification.ipynb 2023-03-07 14:18:13 -05:00
reznitskiiandGitHub 20e524dda5 Update get_started_bq_datasets.ipynb 2023-03-07 14:16:48 -05:00
reznitskiiandGitHub b0c7c70b81 Update prophet_on_vertex_pipelines.ipynb 2023-03-07 14:14:03 -05:00
Andrew FerlitschandGitHub 1c6e4a36c1 Update get_started_with_vertex_experiments_autologging.ipynb 2023-03-07 09:32:20 -08:00
inardini 20cdcefea3 linter passed 2023-03-06 20:47:57 +00:00
inardini 26db26d100 add andy reviews 2023-03-06 20:47:26 +00:00
inardini 6e71605669 linter passed 2023-03-06 12:55:26 +00:00
inardini f8af22386c comment colab 2023-03-06 12:54:57 +00:00
inardini 9d7a744924 update codeowners 2023-03-06 08:56:07 +00:00
inardini 4f8a527f5c linter passed 2023-03-06 08:50:24 +00:00
inardini 4a987f5dcb fix linter 2023-03-06 08:49:59 +00:00
inardini a2a3de5767 add new autologging notebook tutorial 2023-03-06 08:45:18 +00:00
btrinh69 1e4b3aefdb address comments 2023-03-03 00:55:11 +00:00
btrinh69 f0112cfc9a fix variables naming 2023-01-14 07:14:56 +00:00
btrinh69 33e7d18502 add passthrough case 2023-01-14 00:15:12 +00:00
btrinh69 506a6e66d7 format file 2023-01-13 00:18:59 +00:00
btrinh69 5bd6cfe6a7 remove redundant code 2023-01-13 00:16:15 +00:00
btrinh69 ca27881ca7 Merge branch 'prediction-featurestore-integration' of https://github.com/btrinh69/vertex-ai-samples into prediction-featurestore-integration 2023-01-13 00:13:44 +00:00
btrinh69 5fa0ed6185 remove redundant code 2023-01-13 00:12:38 +00:00
btrinh69 14f58e30c5 remove redundant code 2023-01-13 00:11:14 +00:00
btrinh69andGitHub 6af94b51aa Merge branch 'main' into prediction-featurestore-integration 2023-01-13 00:07:35 +00:00
btrinh69 2f818117db add prediction_featurestore_integration to the CODEOWNER file and format the notebook 2023-01-13 00:06:23 +00:00
btrinh69 04fe89c556 Ingest Feature Store data from an exported CSV instead of querying data
from BigQuery and address comments in the previous commit

This commit does:
- Shorten the Feature Store creation process by using an exported CSV to
  populate FS instead of querying from BigQuery
- Add the Feature fetch config proto to the description
- Grant the service account `Storage Admin` and `Vertex Ai Feature Store
  Data Viewer` role instead of `Vertex AI Service Agent`
- Address nit comments in the previous commit
2023-01-12 23:47:27 +00:00
btrinh69 7715f79807 format prediction_featurestore_integration.ipynb. 2022-12-19 23:21:59 +00:00
btrinh69 6caffbe5c3 add an E2E notebook for Prediction and Featurestore integration 2022-12-19 22:52:30 +00:00
44 changed files with 5311 additions and 606 deletions
+3 -5
View File
@@ -44,12 +44,10 @@ Finally, run this code block to check for errors. Each step will attempt to
automatically fix any issues. If the fixes can't be performed automatically,
then you will need to manually address them before submitting your PR.
Note: For official, only submit one notebook per PR.
```shell
nbqa black "$notebook"
nbqa pyupgrade "$notebook"
nbqa isort "$notebook"
nbqa flake8 "$notebook" --extend-ignore=W391,E501,F821,E402,F404,W503,E203,E722,W293,W291
python3 -m tensorflow_docs.tools.nbfmt --remove_outputs "$notebook"
docker run -v ${PWD}:/setup/app gcr.io/cloud-devrel-public-resources/notebook_linter:latest your_notebook
```
## Code Reviews
+1
View File
@@ -9,3 +9,4 @@
/Train_tabular_models_with_many_frameworks_and_import_to_Vertex_AI_using_Pipelines @Ark-kun
/pipeline_components @Ark-kun
/pipeline_components/image_ml_model_training @lakeyk
/prediction_featurestore_integration @googleapis/vertex-prediction-team
@@ -53,12 +53,14 @@
"source": [
"## Overview\n",
"\n",
"This notebook demonstrates how to use Vertex AI Prediction with Feature Store integration. This integration enables feature values to be fetched directly from Feature Store during a `predict` request, instead of having to specify feature values explicitly in the predict request.\n",
"This notebook demonstrates how to deploy and serve models on Vertex AI with Feature Store integration. This integration enables feature values to be fetched directly from Feature Store during a `predict` request, instead of having to specify feature values explicitly in the predict request.\n",
"\n",
"**This is an Experimental release**, covered by the Pre-GA Offerings Terms of your Google Cloud Platform [Terms of Service](https://cloud.google.com/terms).\n",
"**This is an Experimental release**, covered by the [Pre-GA Offerings](https://cloud.google.com/terms/service-terms) Terms of your Google Cloud Platform [Terms of Service](https://cloud.google.com/terms).\n",
"\n",
"Experimental features are focused on validating a prototype and are not guaranteed to be released. They are not intended for production use or covered by any SLA, support obligation, or deprecation policy and might be subject to backward-incompatible changes. They also may not be at the same reliability standards as a GA product.\n",
"\n",
"The usage of the product for model deployment and serving is free during the Experimental release period: you will still incur charges for other GCP products usage, such as Feature store, storage, etc.\n",
"\n",
"**Kindly drop us a note before you run any scale tests.**\n",
"\n",
"**Do not hesitate to contact vertexai-prediction-preview-feedback@google.com if you have any questions or run into any issues.**\n",
@@ -68,6 +70,27 @@
"The dataset and model used in this notebook is based on this [Prediction and Feature Store Online Serving notebook](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/feature_store/mobile_gaming/mobile_gaming_feature_store.ipynb) and [this blog post](https://cloud.google.com/blog/topics/developers-practitioners/churn-prediction-game-developers-using-google-analytics-4-ga4-and-bigquery-ml)."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "04c030a6aefc"
},
"source": [
"## Introduction\n",
"\n",
"Prior to this, when using Vertex AI Feature Store to store and fetch features for prediction, users had to first call Feature Store to fetch the features and then send those features to Vertex AI Prediction Service in a prediction request. Users frequently also performed feature transformations before or after sending the prediction instance to the prediction container. This led to a lot of orchestration on the user's end. \n",
"\n",
"\n",
"To make it easier for our users to use Feature Store and Prediction service together, we are offering a built-in integration between Feature Store and Prediction service. Users can now upload a config when they upload their model to the model registry. This config has information on what features the model takes, where are those feature stored in Vertex AI Feature Store and how the prediction request to the deployed models should be built. On the prediction path, users just give the IDs of the entities stored in the Feature Store, or any features they want to override. Vertex AI will take care of reading all the features, constructing and executing the prediction request and returning the final prediction response.\n",
"\n",
"\n",
"**Why should I care about this integration?**\n",
"- Make predictions with a single call to online prediction service, instead of calling two separate services (one or more calls to feature store and one call to Prediction service)\n",
"- Less code to be written and maintained by users, as they don't have to convert Feature Store's response to the format that the deployed model accepts.\n",
"- Clients that send prediction requests to the deployed models do not have to worry about the features that a model accepts. As a result, data science teams building the models can continue to experiment without requiring every client to change their code every time a feature is added/deleted/modified. Therefore, it leads to faster iterations in organizations.\n",
"- Model-Feature lineage can be easily and explicitly tracked.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -92,7 +115,7 @@
"source": [
"### Dataset\n",
"\n",
"The dataset is the public sample export data from an actual mobile game app called \"Flood It!\" (Android, iOS)."
"The dataset is the public sample export data from an actual mobile game app called \"Flood It!\" ([Android](https://play.google.com/store/apps/details?id=com.labpixies.flood&pli=1), [iOS](https://apps.apple.com/us/app/flood-it/id476943146))."
]
},
{
@@ -103,14 +126,38 @@
"source": [
"### Model\n",
"\n",
"The model used in this notebook is based on [this blog post](https://cloud.google.com/blog/topics/developers-practitioners/churn-prediction-game-developers-using-google-analytics-4-ga4-and-bigquery-ml). The model predicts user churn for game developers. The raw data contains the following categories of information:\n",
"The model used in this notebook is based on [this blog post](https://cloud.google.com/blog/topics/developers-practitioners/churn-prediction-game-developers-using-google-analytics-4-ga4-and-bigquery-ml). The model predicts the probability of a user churning. The [raw data](https://console.cloud.google.com/bigquery?p=firebase-public-project&d=analytics_153293282&t=events_20181003&page=table&_ga=2.214026135.-1049105954.1678419790) contains the following categories of information:\n",
"\n",
"- identity - unique player identity numbers.\n",
"- demographic features - information about the player, such as the geographic region in which a player is located.\n",
"- behavioral features - counts of the number of times a player has triggered certain game events, such as reaching a new level.\n",
"- churn propensity - this is the label or target feature, it provides an estimated probability that this player will churn, i.e. stop being an active player.\n",
"\n",
"The blog article referenced above explains how to use BigQuery to store the raw data, pre-process the data for machine learning, and train the corresponding model. Because this notebook focuses on Vertex Prediction, we're going to reuse a pre-trained version of this model, which can be downloaded from `gs://featurestore_integration/model`."
"The blog article referenced above explains how to use BigQuery to store the raw data, pre-process the data for machine learning, and train the corresponding model. Because this notebook focuses on Vertex Prediction, we're going to reuse a pre-trained version of this model, which can be downloaded from `gs://featurestore_integration/model`.\n",
"\n",
"The model's list of features by category:\n",
"- Demographic features:\n",
" - `country`\n",
" - `operating_system`\n",
" - `language`\n",
" - `user_pseudo_id`\n",
"- Behavioral features:\n",
" - `cnt_user_engagement`\n",
" - `cnt_level_start_quickplay`\n",
" - `cnt_level_end_quickplay`\n",
" - `cnt_level_complete_quickplay`\n",
" - `cnt_level_reset_quickplay`\n",
" - `cnt_post_score`\n",
" - `cnt_spend_virtual_currency`\n",
" - `cnt_ad_reward`\n",
" - `cnt_challenge_a_friend`\n",
" - `cnt_completed_5_levels`\n",
" - `cnt_use_extra_steps`\n",
" - `month`\n",
" - `julianday`\n",
" - `dayofweek`\n",
"- Label:\n",
" - `churned`"
]
},
{
+1
View File
@@ -40,3 +40,4 @@
/model_evaluation/custom_tabular_classification_model_evaluation.ipynb @soheilazangeneh
/sdk/SDK_FBProphet_Forecasting_Online.ipynb @brianchunkang
/pipelines/Train_tabular_models_with_many_frameworks_and_import_to_Vertex_AI_using_Pipelines @Ark-kun
/experiments/get_started_with_vertex_experiments_autologging.ipynb @inardini
-438
View File
@@ -4,441 +4,3 @@ The official notebooks are a collection of curated and non-curated notebooks aut
The official notebooks are organized by Google Cloud Vertex AI services.
## Manifest of Curated Notebooks
### AutoML Text data
[Create, train, and deploy an AutoML text classification model](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/automl-text-classification.ipynb)
Learn how to use `AutoML` to train a text classification model.
The steps performed include:
* Create a `Vertex AI Dataset`.
* Train an `AutoML` text classification `Model` resource.
* Obtain the evaluation metrics for the `Model` resource.
* Create an `Endpoint` resource.
* Deploy the `Model` resource to the `Endpoint` resource.
* Make an online prediction
* Make a batch prediction
### AutoML Tabular data
[AutoML tabular forecasting model for batch prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_tabular_forecasting_batch.ipynb)
Learn how to create an `AutoML` tabular forecasting model from a Python script, and then do a batch prediction using the Vertex AI SDK.
The steps performed include:
- Create a `Vertex AI Dataset` resource.
- Train an `AutoML` tabular forecasting `Model` resource.
- Obtain the evaluation metrics for the `Model` resource.
- Make a batch prediction.
### BigQuery ML Vertex AI Model Registry Batch prediction
[Deploy BiqQuery ML Model on Vertex AI Model Registry and make predictions](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/model-registry/bqml-vertexai-model-registry.ipynb)
Learn how to use `Vertex AI Model Registry` with `BigQuery ML` and make batch predictions:
The steps performed include:
- Train a model with `BigQuery ML`
- Upload the model to `Vertex AI Model Registry`
- Create a `Vertex AI Endpoint` resource
- Deploy the `Model` resource to the `Endpoint` resource
- Make `prediction` requests to the model endpoint
- Run `batch prediction` job on the `Model` resource
### BigQuery ML Vertex AI Model Registry Online prediction
[Online prediction with BigQuery ML](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/bigquery_ml/bqml-online-prediction.ipynb)
Learn how to train and deploy a churn prediction model for real-time inference, with the data in BigQuery and model trained using BigQuery ML, registered to Vertex AI Model Registry, and deployed to an endpoint on Vertex AI for online predictions.
The steps performed include:
- Using Python & SQL to query the public data in BigQuery
- Preparing the data for modeling
- Training a classification model using BigQuery ML and registering it to Vertex AI Model Registry
- Inspecting the model on Vertex AI Model Registry
- Deploying the model to an endpoint on Vertex AI
- Making sample online predictions to the model endpoint
### Custom Training
[Custom training and batch prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/custom/sdk-custom-image-classification-batch.ipynb)
Learn to use `Vertex AI Training` to create a custom trained model and use `Vertex AI Batch Prediction` to do a batch prediction on the trained model.
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- Upload the trained model artifacts as a `Model` resource.
- Make a batch prediction.
[Custom training and online prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/custom/sdk-custom-image-classification-online.ipynb)
Learn to use `Vertex AI Training` to create a custom-trained model from a Python script in a Docker container, and learn to use `Vertex AI Prediction` to do a prediction on the deployed model by sending data.
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- Upload the trained model artifacts to a `Model` resource.
- Create a serving `Endpoint` resource.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make a prediction.
- Undeploy the `Model` resource.
### Tabular Data
[Compare Vertex AI Forecasting and BigQuery ML ARIMA_PLUS](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/automl_forecasting_bqml_arima_plus_comparison.ipynb)
Learn how to create an BQML ARIMA_PLUS model using a training [Vertex AI Pipeline](https://cloud.
The steps performed are:
- Train the BQML ARIMA_PLUS model.
- View BQML model evaluation.
- Make a batch prediction with the BQML model.
- Create a Vertex AI `Dataset` resource.
- Train the Vertex AI Forecasting model.
- View the Model evaluation.
- Make a batch prediction with the Model.
### AutoML Tabular Data
[AutoML Tabular Pipeline](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/automl_tabular_on_vertex_pipelines.ipynb)
Learn how to create two regression models using [Vertex Pipelines](https://cloud.
The steps performed are:
- Create a training pipeline that reduces the search space from the default to save time.
- Create a training pipeline that reuses the architecture search results from the previous pipeline to save time.
### Vertex AI Experiments
[Compare pipeline runs with Vertex AI Experiments](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/experiments/comparing_pipeline_runs.ipynb)
Learn how to use `Vertex AI Experiments` to log a pipeline job and compare different pipeline jobs.
[Build Vertex AI Experiment lineage for custom training](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/experiments/build_model_experimentation_lineage_with_prebuild_code.ipynb)
Learn how to integrate preprocessing code in a Vertex AI experiments.
[Track parameters and metrics for locally trained models](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/experiments/comparing_local_trained_models.ipynb)
Learn how to use Vertex AI Experiments to compare and evaluate model experiments.
The steps performed include:
- log the model parameters
- log the loss and metrics on every epoch to TensorBoard
- log the evaluation metrics
### Vertex AI Feature Store
[Online and Batch predictions using Vertex AI Feature Store](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/feature_store/sdk-feature-store.ipynb)
Learn how to use `Vertex AI Feature Store` to import feature data, and to access the feature data for both online serving and offline tasks, such as training.
The steps performed include:
- Create featurestore, entity type, and feature resources.
- Import feature data into `Vertex AI Feature Store` resource.
- Serve online prediction requests using the imported features.
- Access imported features in offline jobs, such as training jobs.
### Matching Engine
[Create Vertex AI Matching Engine index](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/matching_engine/sdk_matching_engine_for_indexing.ipynb)
Learn how to create Approximate Nearest Neighbor (ANN) Index, query against indexes, and validate the performance of the index.
The steps performed include:
* Create ANN Index and Brute Force Index
* Create an IndexEndpoint with VPC Network
* Deploy ANN Index and Brute Force Index
* Perform online query
* Compute recall
### Model Monitoring
[Vertex AI Model Monitoring with Explainable AI Feature Attributions](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/model_monitoring/model_monitoring.ipynb)
Learn to use the `Vertex AI Model Monitoring` service to detect drift and anomalies in prediction requests from a deployed `Vertex AI Model` resource.
The steps performed include:
- Upload a pre-trained model as a `Vertex AI Model` resource.
- Create an `Vertex AI Endpoint` resource.
- Deploy the `Model` resource to the `Endpoint` resource.
- Configure the `Endpoint` resource for model monitoring.
- Initialize the baseline distribution for model monitoring.
- Generate synthetic prediction requests.
- Understand how to interpret the statistics, visualizations, other data reported by the model monitoring feature.
### Vertex AI Pipelines
[Lightweight Python function-based components, and component I/O](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/lightweight_functions_component_io_kfp.ipynb)
Learn to use the KFP SDK to build lightweight Python function-based components, and then you learn to use `Vertex AI Pipelines` to execute the pipeline.
The steps performed include:
- Build Python function-based KFP components.
- Construct a KFP pipeline.
- Pass *Artifacts* and *parameters* between components, both by path reference and by value.
- Use the `kfp.dsl.importer` method.
- Compile the KFP pipeline.
- Execute the KFP pipeline using `Vertex AI Pipelines`
### Vertex AI Pipelines Image data
[AutoML image classification pipelines using google-cloud-pipeline-components](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/google_cloud_pipeline_components_automl_images.ipynb)
Learn how to use `Vertex AI Pipelines` and `Google Cloud Pipeline Components` to build an `AutoML` image classification model.
The steps performed include:
- Create a KFP pipeline:
- Create a `Dataset` resource.
- Train an AutoML image classification `Model` resource.
- Create an `Endpoint` resource.
- Deploys the `Model` resource to the `Endpoint` resource.
- Compile the KFP pipeline.
- Execute the KFP pipeline using `Vertex AI Pipelines`
### Vertex AI Pipelines Tabular data
[AutoML Tabular pipelines using google-cloud-pipeline-components](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/automl_tabular_classification_beans.ipynb)
Learn to use `Vertex AI Pipelines` and `Google Cloud Pipeline Components` to build an `AutoML` tabular classification model.
The steps performed include:
- Create a KFP pipeline:
- Create a `Dataset` resource.
- Train an AutoML tabular classification `Model` resource.
- Create an `Endpoint` resource.
- Deploys the `Model` resource to the `Endpoint` resource.
- Compile the KFP pipeline.
- Execute the KFP pipeline using `Vertex AI Pipelines`
[AutoML tabular regression pipelines using google-cloud-pipeline-components](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/google_cloud_pipeline_components_automl_tabular.ipynb)
Learn to use `Vertex AI Pipelines` and `Google Cloud Pipeline Components` to build an `AutoML` tabular regression model.
The steps performed include:
- Create a KFP pipeline:
- Create a `Dataset` resource.
- Train an AutoML tabular regression `Model` resource.
- Create an `Endpoint` resource.
- Deploys the `Model` resource to the `Endpoint` resource.
- Compile the KFP pipeline.
- Execute the KFP pipeline using `Vertex AI Pipelines`
### Vertex AI Pipelines Text data
[AutoML text classification pipelines using google-cloud-pipeline-components](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/google_cloud_pipeline_components_automl_text.ipynb)
Learn to use `Vertex AI Pipelines` and `Google Cloud Pipeline Components` to build an `AutoML` text classification model.
The steps performed include:
- Create a KFP pipeline:
- Create a `Dataset` resource.
- Train an AutoML text classification `Model` resource.
- Create an `Endpoint` resource.
- Deploys the `Model` resource to the `Endpoint` resource.
- Compile the KFP pipeline.
- Execute the KFP pipeline using `Vertex AI Pipelines`
### Vertex AI Pipelines
[Custom training with pre-built Google Cloud Pipeline Components](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/custom_model_training_and_batch_prediction.ipynb)
Learn to use `Vertex AI Pipelines` and `Google Cloud Pipeline Components` to build a custom model.
The steps performed include:
- Create a KFP pipeline:
- Train a custom model.
- Upload the trained model as a `Model` resource.
- Create an `Endpoint` resource.
- Deploy the `Model` resource to the `Endpoint` resource.
- Make a batch prediction request.
[Pipeline control structures using the KFP SDK](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/control_flow_kfp.ipynb)
Learn how to use the KFP SDK to build pipelines that use loops and conditionals, including nested examples.
The steps performed include:
- Create a KFP pipeline:
- Use control flow components
- Compile the KFP pipeline.
- Execute the KFP pipeline using `Vertex AI Pipelines`
[Metrics visualization and run comparison using the KFP SDK](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/metrics_viz_run_compare_kfp.ipynb)
Learn how to use the KFP SDK to build pipelines that generate evaluation metrics.
The steps performed include:
- Create KFP components:
- Generate ROC curve and confusion matrix visualizations for classification results
- Write metrics
- Create KFP pipelines.
- Execute KFP pipelines
- Compare metrics across pipeline runs
[Pipelines introduction for KFP](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/pipelines_intro_kfp.ipynb)
Learn how to use the KFP SDK to build pipelines that generate evaluation metrics.
The steps performed include:
- Define and compile a `Vertex AI` pipeline.
- Specify which service account to use for a pipeline run.
### Vertex AI Vizier
[Optimizing multiple objectives with Vertex AI Vizier](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/vizier/gapic-vizier-multi-objective-optimization.ipynb)
Learn how to use `Vertex AI Vizier` to optimize a multi-objective study.
### Vertex Explainable AI Tabular data
[AutoML training tabular binary classification model for batch explanation](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_automl_tabular_binary_classification_batch_explain.ipynb)
Learn to use `AutoML` to create a tabular binary classification model from a Python script, and then learn to use `Vertex AI Batch Prediction` to make predictions with explanations.
The steps performed include:
- Create a `Vertex Dataset` resource.
- Train an `AutoML` tabular binary classification model.
- View the model evaluation metrics for the trained model.
- Make a batch prediction request with explainability.
* Prediction Service: Does an on-demand prediction for the entire set of instances (i.e., one or more data items) and returns the results in real-time.
* Batch Prediction Service: Does a queued (batch) prediction for the entire set of instances in the background and stores the results in a Cloud Storage bucket when ready.
[AutoML training tabular classification model for online explanation](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_automl_tabular_classification_online_explain.ipynb)
Learn how to use `AutoML` to create a tabular binary classification model from a Python script, and then learn to use `Vertex AI Online Prediction` to make online predictions with explanations.
The steps performed include:
- Create a `Vertex Dataset` resource.
- Train an `AutoML` tabular binary classification model.
- View the model evaluation metrics for the trained model.
- Create a serving `Endpoint` resource.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make an online prediction request with explainability.
- Undeploy the `Model` resource.
### Vertex Explainable AI Image data
[Custom training image classification model for batch prediction with explainabilty](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_custom_image_classification_batch_explain.ipynb)
Learn to use `Vertex AI Training and Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Batch Prediction` to make a batch prediction request with explanations.
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- View the model evaluation for the trained model.
- Set explanation parameters for when the model is deployed.
- Upload the trained model artifacts and explanation parameters as a `Model` resource.
- Make a batch prediction with explanations.
[Custom training image classification model for online prediction with explainabilty](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_custom_image_classification_online_explain.ipynb)
Learn how to use `Vertex AI Training and Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Prediction` to make an online prediction request with explanations.
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- View the model evaluation for the trained model.
- Set explanation parameters for when the model is deployed.
- Upload the trained model artifacts and explanations as a `Model` resource.
- Create a serving `Endpoint` resource.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make a prediction with explanation.
- Undeploy the `Model` resource.
### Vertex Explainable AI Tabular data
[Custom training tabular regression model for batch prediction with explainabilty](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_custom_tabular_regression_batch_explain.ipynb)
Learn how to use `Vertex AI Training and Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Batch Prediction` to make a batch prediction request with explanations.
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- View the model evaluation for the trained model.
- Set explanation parameters for when the model is deployed.
- Upload the trained model artifacts and explanations as a `Model` resource.
- Make a batch prediction with explanations.
### Vertex ML Metadata
[Track parameters and metrics for custom training jobs](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/ml_metadata/sdk-metric-parameter-tracking-for-custom-jobs.ipynb)
Learn how to use Vertex AI SDK for Python to:
The steps performed include:
- Track training parameters and prediction metrics for a custom training job.
- Extract and perform analysis for all parameters and metrics within an Experiment.
+3 -3
View File
@@ -40,7 +40,7 @@ The steps performed include:
[Compare Vertex AI Forecasting and BigQuery ML ARIMA_PLUS](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/automl_forecasting_bqml_arima_plus_comparison.ipynb)
```
Learn how to create an BigQuery ML ARIMA_PLUS model using a training [Vertex AI Pipeline](https://cloud.
Learn how to create an BigQuery ML ARIMA_PLUS model using a training Vertex AI Pipeline from Google Cloud Pipeline Components , and then do a batch prediction using the corresponding prediction pipeline.
The steps performed are:
@@ -60,7 +60,7 @@ The steps performed are:
[AutoML Tabular Workflow pipelines](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/automl_tabular_on_vertex_pipelines.ipynb)
```
Learn how to create two regression models using [Vertex AI Pipelines](https://cloud.
Learn how to create two regression models using Vertex AI Pipelines downloaded from Google Cloud Pipeline Components .
The steps performed are:
@@ -88,7 +88,7 @@ The steps performed include:
```
   Learn more about [Vertex AI for AutoML](https://cloud.google.com/vertex-ai/docs/start/automl-users).
   Learn more about [AutoML training](https://cloud.google.com/vertex-ai/docs/training-overview).
[AutoML training hierarchical forecasting for batch prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_forecasting_hierarchical_batch.ipynb)
+4 -4
View File
@@ -14,7 +14,7 @@ The steps performed include:
```
   Learn more about [Vertex AI Training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
   Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
   Learn more about [Vertex AI Prediction](https://cloud.google.com/vertex-ai/docs/predictions/get-predictions).
@@ -37,7 +37,7 @@ The steps performed include:
```
   Learn more about [Vertex AI Training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
   Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
   Learn more about [Vertex AI Prediction](https://cloud.google.com/vertex-ai/docs/predictions/get-predictions).
@@ -90,7 +90,7 @@ The steps performed include:
```
   Learn more about [Vertex AI Training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
   Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
   Learn more about [Vertex AI Batch Prediction](https://cloud.google.com/vertex-ai/docs/tabular-data/classification-regression/get-batch-predictions).
@@ -111,7 +111,7 @@ The steps performed include:
```
   Learn more about [Vertex AI Training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
   Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
   Learn more about [Vertex AI Prediction](https://cloud.google.com/vertex-ai/docs/predictions/get-predictions).
@@ -62,21 +62,9 @@
"## Overview\n",
"\n",
"\n",
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers: get started with Endpoints and shared VM for co-hosting models."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:flowers,icn"
},
"source": [
"### Pre-trained Models\n",
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers: get started with Endpoints and shared VM for co-hosting models.\n",
"\n",
"The pre-trained models used for this tutorial are from the [TensorFlow Hub](https://tfhub.dev/) repository:\n",
"\n",
"- [image classification](https://tfhub.dev/google/imagenet/inception_v3/classification/5): trained with ImageNet.\n",
"- [text sentence encoder](https://tfhub.dev/google/universal-sentence-encoder/4): Google's universal sentence encoder"
"Learn more about [Shared resources across deployments](https://cloud.google.com/vertex-ai/docs/predictions/model-co-hosting)."
]
},
{
@@ -110,6 +98,20 @@
"- Make a prediction request with second deployed model (model B)."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:flowers,icn"
},
"source": [
"### Model\n",
"\n",
"The pre-trained models used for this tutorial are from the [TensorFlow Hub](https://tfhub.dev/) repository:\n",
"\n",
"- [image classification](https://tfhub.dev/google/imagenet/inception_v3/classification/5): trained with ImageNet.\n",
"- [text sentence encoder](https://tfhub.dev/google/universal-sentence-encoder/4): Google's universal sentence encoder"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -63,7 +63,7 @@
"\n",
"This tutorial demonstrates how to use Vertex AI in production. This tutorial covers data management: get started with BigQuery datasets.\n",
"\n",
"Learn more about [BigQuery Datasets](https://cloud.google.com/bigquery/docs/datasets-intro)."
"Learn more about [BigQuery Datasets](https://cloud.google.com/bigquery/docs/datasets-intro) and [Vertex AI for BigQuery users](https://cloud.google.com/vertex-ai/docs/beginner/bqml)."
]
},
{
+1 -1
View File
@@ -86,5 +86,5 @@ The steps performed include:
   Learn more about [Vertex ML Metadata](https://cloud.google.com/vertex-ai/docs/ml-metadata).
   Learn more about [Vertex AI Training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
   Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
+22 -2
View File
@@ -13,7 +13,7 @@ The steps performed include:
```
   Learn more about [AutoML Tabular](https://cloud.google.com/vertex-ai/docs/tabular-data/overview).
   Learn more about [Classification for tabular data](https://cloud.google.com/vertex-ai/docs/tabular-data/classification-regression/overview).
   Learn more about [Vertex Explainable AI](https://cloud.google.com/vertex-ai/docs/explainable-ai/overview).
@@ -35,7 +35,7 @@ The steps performed include:
```
   Learn more about [AutoML Tabular](https://cloud.google.com/vertex-ai/docs/tabular-data/overview).
   Learn more about [Classification for tabular data](https://cloud.google.com/vertex-ai/docs/tabular-data/classification-regression/overview).
   Learn more about [Vertex Explainable AI](https://cloud.google.com/vertex-ai/docs/explainable-ai/overview).
@@ -149,3 +149,23 @@ The steps performed include:
   Learn more about [Vertex AI Prediction](https://cloud.google.com/vertex-ai/docs/predictions/get-predictions).
[Explaining image classification with Vertex Explainable AI](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/xai_image_classification_feature_attributions.ipynb)
```
Learn how to configure feature-based explanations on a pre-trained image classification model and make online and batch predictions with explanations.
The steps performed include:
- Download pretrained model from TensorFlow Hub
- Upload model for deployment
- Deploy model for online prediction
- Make online prediction with explanations
- Make batch predictions with explanations
```
   Learn more about [Vertex Explainable AI](https://cloud.google.com/vertex-ai/docs/explainable-ai/overview).
   Learn more about [Vertex AI Prediction](https://cloud.google.com/vertex-ai/docs/predictions/get-predictions).
@@ -29,7 +29,7 @@
"id": "title"
},
"source": [
"# Vertex SDK: Custom training image classification model for online prediction with explainabilty\n",
"# Vertex SDK: Custom training image classification model for online prediction with explainability\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
+24 -28
View File
@@ -1,17 +1,32 @@
[Introduction to builtin Swivel embedding algorithm](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/matching_engine/intro-swivel.ipynb)
[Using Vertex AI Matching Engine for StackOverflow Questions](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/matching_engine/sdk_matching_engine_create_stack_overflow_embeddings.ipynb)
```
Learn how to train custom embeddings using Vertex AI Pipelines and deploy the model for serving.
Learn how to encode custom text embeddings, create an Approximate Nearest Neighbor index, and query against indexes.
The steps performed include:
1. **Setup**: Importing the required libraries and setting your global variables.
2. **Configure parameters**: Setting the appropriate parameter values for the pipeline job.
3. **Train on Vertex AI Pipelines**: Create a Swivel job to Vertex Pipelines using pipeline template.
4. **Deploy on Vertex AI Prediction**: Importing and deploying the trained model to a callable endpoint.
5. **Predict**: Calling the deployed endpoint using online prediction.
6. **Cleaning up**: Deleting resources created by this tutorial.
* Create ANN index
* Create an index endpoint with VPC Network
* Deploy ANN index
* Perform online query
```
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Matching Engine](https://cloud.google.com/vertex-ai/docs/matching-engine/overview).
[Using Vertex AI Matching Engine for Text-to-Image Embeddings](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/matching_engine/sdk_matching_engine_create_text_to_image_embeddings.ipynb)
```
Learn how to encode custom text embeddings, create an Approximate Nearest Neighbor index, and query against indexes.
The steps performed include:
* Create ANN index
* Create an index endpoint with VPC Network
* Deploy ANN index
* Perform online query
```
@@ -21,7 +36,7 @@ The steps performed include:
[Create Vertex AI Matching Engine index](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/matching_engine/sdk_matching_engine_for_indexing.ipynb)
```
Learn how to create Approximate Nearest Neighbor (ANN) Index, query against indexes, and validate the performance of the index.
Learn how to create Approximate Nearest Neighbor Index, query against indexes, and validate the performance of the index.
The steps performed include:
@@ -35,22 +50,3 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Matching Engine](https://cloud.google.com/vertex-ai/docs/matching-engine/overview).
[Introduction to builtin Two-Towers embedding algorithm](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/matching_engine/two-tower-model-introduction.ipynb)
```
Learn how to run the Two-Tower model.
The steps performed include:
1. **Setup**: Importing the required libraries and setting your global variables.
2. **Configure parameters**: Setting the appropriate parameter values for the training job.
3. **Train on Vertex AI Training**: Submitting a training job.
4. **Deploy on Vertex AI Prediction**: Importing and deploying the trained model to a callable endpoint.
5. **Predict**: Calling the deployed endpoint using online or batch prediction.
6. **Hyperparameter tuning**: Running a hyperparameter tuning job.
7. **Cleaning up**: Deleting resources created by this tutorial.
```
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Matching Engine](https://cloud.google.com/vertex-ai/docs/matching-engine/overview).
@@ -629,6 +629,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "ba45d58bf96e"
@@ -638,7 +639,7 @@
"\n",
"Encode a subset of data and see if the embeddings and distance metrics make sense.\n",
"\n",
"According to (sentence-T5 research paper)[https://arxiv.org/pdf/2108.08877.pdf], the similarity of embeddings is calculated using the dot-product. "
"According to the [sentence-T5 research paper](https://arxiv.org/pdf/2108.08877.pdf), the similarity of embeddings is calculated using the dot-product. "
]
},
{
@@ -614,6 +614,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "ba45d58bf96e"
@@ -623,7 +624,7 @@
"\n",
"Encode a subset of data and see if the embeddings and distance metrics make sense.\n",
"\n",
"According to the (CLIP research paper)[https://arxiv.org/pdf/2103.00020.pdf], the similarities of embeddings are calculated using the cosine similarity."
"According to the [CLIP research paper](https://arxiv.org/pdf/2103.00020.pdf), the similarities of embeddings are calculated using the cosine similarity."
]
},
{
@@ -933,22 +934,11 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": null,
"metadata": {
"id": "17jrQi501QyX"
},
"outputs": [
{
"data": {
"text/plain": [
"'projects/1012616486416/locations/us-central1/indexes/1027779489179893760'"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"INDEX_RESOURCE_NAME = tree_ah_index.resource_name\n",
"INDEX_RESOURCE_NAME"
+18 -18
View File
@@ -15,7 +15,7 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Migrate to Vertex AI](https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai).
&nbsp;&nbsp;&nbsp;Learn more about [AutoML Image](https://cloud.google.com/vertex-ai/docs/tutorials/image-recognition-automl/training).
&nbsp;&nbsp;&nbsp;Learn more about [Classification for image data](https://cloud.google.com/vertex-ai/docs/training-overview#classification_for_images).
[Custom Scikit-Learn model with pre-built training container](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ10 Vertex SDK Custom Scikit-Learn with pre-built training container.ipynb)
@@ -35,7 +35,7 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Migrate to Vertex AI](https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai).
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
&nbsp;&nbsp;&nbsp;Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
[Hyperparameter Tuning](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ11 Vertex SDK Hyperparameter Tuning.ipynb)
@@ -51,10 +51,10 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Migrate to Vertex AI](https://cloud.google.com/vertex-ai/docs/training/hyperparameter-tuning-overview).
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
&nbsp;&nbsp;&nbsp;Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
[AutoML Video Classificaton](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ14 Vertex SDK AutoML Video Classification.ipynb)
[AutoML Video Classification](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ14 Vertex SDK AutoML Video Classification.ipynb)
```
Learn to use `AutoML` to train a video model and use `Vertex AI Batch Prediction` to do batch predictions.
@@ -68,7 +68,7 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Migrate to Vertex AI](https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai).
&nbsp;&nbsp;&nbsp;Learn more about [AutoML Video](https://cloud.google.com/vertex-ai/docs/tutorials/video-classification-automl/training).
&nbsp;&nbsp;&nbsp;Learn more about [Classification for video data](https://cloud.google.com/vertex-ai/docs/training-overview#classification_for_videos).
[AutoML Video Object Tracking](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ15 Vertex SDK AutoML Object Tracking.ipynb)
@@ -85,7 +85,7 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Migrate to Vertex AI](https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai).
&nbsp;&nbsp;&nbsp;Learn more about [AutoML Video](https://cloud.google.com/video-intelligence/automl/object-tracking/docs/index-object-tracking).
&nbsp;&nbsp;&nbsp;Learn more about [Object tracking for video data](https://cloud.google.com/vertex-ai/docs/training-overview#object_tracking_for_videos).
[Custom Image Classification w/pre-built training container](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ2,12 Vertex SDK Custom Image Classification with pre-built training container.ipynb)
@@ -109,7 +109,7 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Migrate to Vertex AI](https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai).
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
&nbsp;&nbsp;&nbsp;Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
[Custom Image Classification w/custom training container](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ3 Vertex SDK Custom Image Classification with custom training container.ipynb)
@@ -133,7 +133,7 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Migrate to Vertex AI](https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai).
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
&nbsp;&nbsp;&nbsp;Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
[AutoML Tabular Binary Classification](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ4 Vertex SDK AutoML Tabular Binary Classification.ipynb)
@@ -154,7 +154,7 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Migrate to Vertex AI](https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai).
&nbsp;&nbsp;&nbsp;Learn more about [AutoML Tabular](https://cloud.google.com/vertex-ai/docs/start/automl-users#tables).
&nbsp;&nbsp;&nbsp;Learn more about [Classification for tabular data](https://cloud.google.com/vertex-ai/docs/tabular-data/classification-regression/overview).
[AutoML Image Object Detection](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ5 Vertex SDK AutoML Image Object Detection.ipynb)
@@ -173,35 +173,35 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Migrate to Vertex AI](https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai).
&nbsp;&nbsp;&nbsp;Learn more about [AutoML Image](https://cloud.google.com/vertex-ai/docs/tutorials/image-recognition-automl/training).
&nbsp;&nbsp;&nbsp;Learn more about [Object detection for image data](https://cloud.google.com/vertex-ai/docs/training-overview#object_detection_for_images).
[AutoML Text Classification](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ6 Vertex SDK AutoML Text Classification.ipynb)
```
The objective of this notebook is to build a AutoML Video Classification Model.
The objective of this notebook is to build a AutoML Text Classification Model.
The steps performed include the following:
* Set your task name, and GCS prefix
* Copy AutoML video demo train data for creating managed dataset
* Copy AutoML text demo train data for creating managed dataset
* Create a dataset on Vertex AI.
* Configure a training job
* Launch a training job and create a model on Vertex AI
* Copy AutoML Video Demo Prediction Data for creating batch prediction job
* Copy AutoML Text Demo Prediction Data for creating batch prediction job
* Perform batch prediction job on the model
```
&nbsp;&nbsp;&nbsp;Learn more about [Migrate to Vertex AI](https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai).
&nbsp;&nbsp;&nbsp;Learn more about [AutoML Text](https://cloud.google.com/vertex-ai/docs/text-data/classification/prepare-data).
&nbsp;&nbsp;&nbsp;Learn more about [Classification for text data](https://cloud.google.com/vertex-ai/docs/training-overview#classification_for_text).
[AutoML Text Entity Extraction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ7 Vertex SDK AutoML Text Entity Extraction.ipynb)
```
The objective of this notebook is to build a AutoML Text Entity Extraction Model.
The objective of this notebook is to build a AutoML Text Entity Extraction model.
The steps performed include the following:
@@ -217,7 +217,7 @@ The steps performed include the following:
&nbsp;&nbsp;&nbsp;Learn more about [Migrate to Vertex AI](https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai).
&nbsp;&nbsp;&nbsp;Learn more about [AutoML Text](https://cloud.google.com/vertex-ai/docs/text-data/entity-extraction/prepare-data).
&nbsp;&nbsp;&nbsp;Learn more about [Entity extraction for text data](https://cloud.google.com/vertex-ai/docs/training-overview#entity_extraction_for_text).
[AutoML Text Sentiment Analysis](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ8 Vertex SDK AutoML Text Sentiment Analysis.ipynb)
@@ -238,7 +238,7 @@ The steps performed include the following:
&nbsp;&nbsp;&nbsp;Learn more about [Migrate to Vertex AI](https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai).
&nbsp;&nbsp;&nbsp;Learn more about [AutoML Text](https://cloud.google.com/vertex-ai/docs/text-data/sentiment-analysis/prepare-data).
&nbsp;&nbsp;&nbsp;Learn more about [Sentiment analysis for text data](https://cloud.google.com/vertex-ai/docs/training-overview#sentiment_analysis_for_text).
[Custom XGBoost model with pre-built training container](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ9 Vertex SDK Custom XGBoost with pre-built training container.ipynb)
@@ -258,5 +258,5 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Migrate to Vertex AI](https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai).
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
&nbsp;&nbsp;&nbsp;Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
@@ -29,7 +29,7 @@
"id": "title:migration,new"
},
"source": [
"# Vertex AI: Vertex AI Migration: AutoML Image Classification\n",
"# Vertex AI Migration: AutoML Image Classification\n",
"\n",
"<table align=\"left\">\n",
"\n",
@@ -29,7 +29,7 @@
"id": "title:migration,new"
},
"source": [
"# Vertex AI: Vertex AI Migration: Custom Scikit-Learn model with pre-built training container\n",
"# Vertex AI Migration: Custom Scikit-Learn model with pre-built training container\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
@@ -29,7 +29,7 @@
"id": "title:migration,new"
},
"source": [
"# Vertex AI: Vertex AI Migration: Hyperparameter Tuning\n",
"# Vertex AI Migration: Hyperparameter Tuning\n",
"\n",
"<table align=\"left\">\n",
"\n",
@@ -63,7 +63,7 @@
"## Overview\n",
"\n",
"\n",
"This tutorial demonstrates how to use the Vertex AI SDK for Python to hyperparamer tune a custom tabular classification TemsorFlow model.\n",
"This tutorial demonstrates how to use the Vertex AI SDK for Python to tune hyperparameters in a custom tabular classification TensorFlow model.\n",
"\n",
"Learn more about [Migrate to Vertex AI](https://cloud.google.com/vertex-ai/docs/training/hyperparameter-tuning-overview) and [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training)."
]
@@ -29,7 +29,7 @@
"id": "title:migration,new"
},
"source": [
"# Vertex AI: Vertex AI Migration: AutoML Video Classification\n",
"# Vertex AI Migration: AutoML Video Classification\n",
"\n",
"<table align=\"left\">\n",
"\n",
@@ -62,7 +62,7 @@
"source": [
"## Overview\n",
"\n",
"This tutorial demonstrates how to use the Vertex AI SDK for Python to train a AutoML video classification model and do a batch prediction.\n",
"This tutorial demonstrates how to use the Vertex AI SDK for Python to train an AutoML video classification model and do batch prediction.\n",
"\n",
"Learn more about [Migrate to Vertex AI](https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai) and [Classification for video data](https://cloud.google.com/vertex-ai/docs/training-overview#classification_for_videos)."
]
@@ -29,7 +29,7 @@
"id": "title:migration,new"
},
"source": [
"# Vertex AI: Vertex AI Migration: AutoML Video Object Tracking\n",
"# Vertex AI Migration: AutoML Video Object Tracking\n",
"\n",
"<table align=\"left\">\n",
"\n",
@@ -62,7 +62,7 @@
"source": [
"## Overview\n",
"\n",
"This tutorial demonstrates how to use the Vertex AI SDK for Python to train a AutoML video object tracking model and do a batch prediction.\n",
"This tutorial demonstrates how to use the Vertex AI SDK for Python to train an AutoML video object tracking model and do batch prediction.\n",
"\n",
"Learn more about [Migrate to Vertex AI](https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai) and [Object tracking for video data](https://cloud.google.com/vertex-ai/docs/training-overview#object_tracking_for_videos)."
]
@@ -633,6 +633,9 @@
" gcs_source=[IMPORT_FILE],\n",
" import_schema_uri=aip.schema.dataset.ioformat.video.object_tracking,\n",
")\n",
"if os.getenv('IS_TESTING'):\n",
" import time\n",
" time.sleep(30)\n",
"\n",
"print(dataset.resource_name)"
]
@@ -29,7 +29,7 @@
"id": "title:migration,new"
},
"source": [
"# Vertex AI: Vertex AI Migration: Custom Image Classification w/pre-built training container\n",
"# Vertex AI Migration: Custom image classification with a pre-built training container\n",
"\n",
"<table align=\"left\">\n",
"\n",
@@ -29,7 +29,7 @@
"id": "title:migration,new"
},
"source": [
"# Vertex AI: Vertex AI Migration: Custom Image Classification w/custom training container\n",
"# Vertex AI migration: Custom image classification with a custom training container\n",
"\n",
"<table align=\"left\">\n",
"\n",
@@ -61,7 +61,7 @@
"source": [
"## Overview\n",
"\n",
"This notebook demonstrates training a custom image classification model using Tensorflow and Vertex AI SDK by creating a custom training container. Additionally, the notebooks also deploys the trained model to Vertex AI and predictions are generated from it.\n",
"This notebook demonstrates how to train a custom image classification model by creating a custom training container with TensorFlow and the Vertex AI SDK. The notebook also demonstrates how to deploys the trained model to Vertex AI and generate predictions from it.\n",
"\n",
"Learn more about [Migrate to Vertex AI](https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai) and [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training)."
]
@@ -29,7 +29,7 @@
"id": "title:migration,new"
},
"source": [
"# Vertex AI: Vertex AI Migration: AutoML Tabular Binary Classification\n",
"# Vertex AI migration: AutoML tabular binary classification\n",
"\n",
"<table align=\"left\">\n",
"\n",
@@ -62,7 +62,7 @@
"## Overview\n",
"\n",
"\n",
"This tutorial demonstrates how to use the Vertex AI SDK to create tabular binary classification models and do online prediction using a Google Cloud [AutoML](https://cloud.google.com/vertex-ai/docs/start/automl-users) model.\n",
"This tutorial demonstrates how to use the Vertex AI SDK to create tabular binary classification models and do online prediction using an AutoML model.\n",
"\n",
"Learn more about [Migrate to Vertex AI](https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai). Learn more about [Classification for tabular data](https://cloud.google.com/vertex-ai/docs/tabular-data/classification-regression/overview)."
]
@@ -29,7 +29,7 @@
"id": "title:migration,new"
},
"source": [
"# Vertex AI: Vertex AI Migration: AutoML Image Object Detection\n",
"# Vertex AI migration: AutoML image object detection\n",
"\n",
"<table align=\"left\">\n",
"\n",
+1 -1
View File
@@ -12,7 +12,7 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Vertex ML Metadata](https://cloud.google.com/vertex-ai/docs/ml-metadata).
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
&nbsp;&nbsp;&nbsp;Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
[Track parameters and metrics for locally trained models](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/ml_metadata/sdk-metric-parameter-tracking-for-locally-trained-models.ipynb)
+25 -7
View File
@@ -17,7 +17,7 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Model Evaluation](https://cloud.google.com/vertex-ai/docs/evaluation/introduction).
&nbsp;&nbsp;&nbsp;Learn more about [AutoML Tabular](https://cloud.google.com/vertex-ai/docs/start/automl-users#tables).
&nbsp;&nbsp;&nbsp;Learn more about [Classification for tabular data](https://cloud.google.com/vertex-ai/docs/tabular-data/classification-regression/overview).
[Evaluating batch prediction results from AutoML Tabular regression model](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/model_evaluation/automl_tabular_regression_model_evaluation.ipynb)
@@ -32,14 +32,14 @@ The steps performed include:
- Run the `AutoMLTabularTrainingJob` which returns a model
- Import a pre-trained `AutoML model resource` into the pipeline
- Run a `batch prediction` job in the pipeline
- Evaulate the AutoML model using the `regression evaluation component`
- Evaluate the AutoML model using the `regression evaluation component`
- Import the Regression Metrics to the AutoML model resource
```
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Model Evaluation](https://cloud.google.com/vertex-ai/docs/evaluation/introduction).
&nbsp;&nbsp;&nbsp;Learn more about [AutoML Tabular](https://cloud.google.com/vertex-ai/docs/start/automl-users#tables).
&nbsp;&nbsp;&nbsp;Learn more about [Regression for tabular data](https://cloud.google.com/vertex-ai/docs/tabular-data/classification-regression/overview).
[AutoML text classification pipelines using google-cloud-pipeline-components](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/model_evaluation/automl_text_classification_model_evaluation.ipynb)
@@ -74,14 +74,14 @@ The steps performed include:
- Train a Automl Video Classification model on the `Vertex AI Dataset` resource.
- Import the trained `AutoML Vertex AI Model resource` into the pipeline.
- Run a batch prediction job inside the pipeline.
- Evaulate the AutoML model using the classification evaluation component.
- Evaluate the AutoML model using the classification evaluation component.
- Import the classification metrics to the AutoML Vertex AI Model resource.
```
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Model Evaluation](https://cloud.google.com/vertex-ai/docs/evaluation/introduction).
&nbsp;&nbsp;&nbsp;Learn more about [AutoML Video](https://cloud.google.com/vertex-ai/docs/video-data/classification/prepare-data).
&nbsp;&nbsp;&nbsp;Learn more about [Classification for video data](https://cloud.google.com/vertex-ai/docs/training-overview#classification_for_videos).
[Evaluating BatchPrediction results from a Custom Tabular classification model](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/model_evaluation/custom_tabular_classification_model_evaluation.ipynb)
@@ -125,12 +125,30 @@ The steps performed include:
- Upload the model as a Vertex AI Model resource.
- Import a pre-trained `Vertex AI model resource` into the pipeline.
- Run a `batch prediction` job in the pipeline.
- Evaulate the model using the `regression evaluation component`.
- Evaluate the model using the `regression evaluation component`.
- Import the Regression Metrics to the Vertex AI model resource.
```
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Model Evaluation](https://cloud.google.com/vertex-ai/docs/evaluation/introduction).
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
&nbsp;&nbsp;&nbsp;Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
[Get started with importing a custom model evaluation to the Vertex AI Model Registry](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/model_evaluation/get_started_with_custom_model_evaluation_import.ipynb)
```
Learn how to construct and upload a custom model evaluation, and upload the custom model evaluation to a Model resource entry in Vertex AI Model Registry.
The steps performed include:
- Import a pretrained (blessed) model to the Vertex AI Model Registry.
- Construct a custom model evaluation.
- Import the model evaluation metrics to the corresponding model in the Vertex AI Model Registry.
- List the model evaluation for the corresponding model in the Vertex AI Model Registry.
- Construct a second custom model evaluation.
- Import the second model evaluation metrics to the corresponding model in the Vertex AI Model Registry.
- List the second model evaluation for the corresponding model in the Vertex AI Model Registry.
```
@@ -72,7 +72,9 @@
"source": [
"## Overview\n",
"\n",
"This tutorial shows how to use Vertex AI Model Evaluation to import a custom model evaluation to an existing Vertex AI Model Registry entry."
"This tutorial shows how to use Vertex AI Model Evaluation to import a custom model evaluation to an existing Vertex AI Model Registry entry.\n",
"\n",
"Learn more about [Model evaluation in Vertex AI](https://cloud.google.com/vertex-ai/docs/evaluation/introduction)."
]
},
{
+19 -1
View File
@@ -26,7 +26,6 @@ The steps performed include:
- Deploy the `Model` resource to the `Endpoint` resource.
- Configure the `Endpoint` resource for model monitoring.
- Generate synthetic prediction requests for skew.
- Wait for email alert notification.
- Generate synthetic prediction requests for drift.
- Wait for email alert notification.
@@ -52,6 +51,25 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Model Monitoring](https://cloud.google.com/vertex-ai/docs/model-monitoring).
[Vertex AI Model Monitoring for online prediction in AutoML image models](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/model_monitoring/get_started_with_model_monitoring_automl_image_online.ipynb)
```
Learn how to use `Vertex AI Model Monitoring` with `Vertex AI Online Prediction` with an AutoML image classification model to detect an out of distribution image.
The steps performed include:
1. Train an AutoML image classification model.
2. Create an endpoint.
3. Deploy the model to the endpoint, and configure for model monitoring.
4. Submit a online prediction containing both in and out of distribution images.
5. Use Model Monitoring to calculate anomaly score on each image.
6. Identify the images in the online prediction request that are out of distribution.
```
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Model Monitoring](https://cloud.google.com/vertex-ai/docs/model-monitoring).
[Vertex AI Model Monitoring for custom tabular models](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/model_monitoring/get_started_with_model_monitoring_custom.ipynb)
```
@@ -19,3 +19,21 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [BigQuery ML](https://cloud.google.com/vertex-ai/docs/beginner/bqml).
[Get started with Vertex AI Model Registry](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/model_registry/get_started_with_model_registry.ipynb)
```
Learn how to use `Vertex AI Model Registry` to create and register multiple versions of a model.
The steps performed include:
- Create and register a first version of a model to `Vertex AI Model Registry`.
- Create and register a second version of a model to `Vertex AI Model Registry`.
- Updating the model version which is the default (blessed).
- Deleting a model version.
- Retraining the next model version.
```
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Model Registry](https://cloud.google.com/vertex-ai/docs/model-registry/introduction).
+30 -27
View File
@@ -20,6 +20,31 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [AutoML components](https://cloud.google.com/vertex-ai/docs/pipelines/vertex-automl-component).
&nbsp;&nbsp;&nbsp;Learn more about [Classification for tabular data](https://cloud.google.com/vertex-ai/docs/tabular-data/classification-regression/overview).
[Challenger vs Blessed methodology for model deployment into production](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/pipelines/challenger_vs_blessed_deployment_method.ipynb)
```
Learn how to construct a Vertex AI pipeline, which trains a new challenger version of a model, evaluates the model and compares the evaluation to the existing blessed model in production, to determine whether the challenger model becomes the blessed model for replacement in production.
The steps performed include:
- Import a pretrained (blessed) model to the `Vertex AI Model Registry`.
- Import synthetic model evaluation metrics to the corresponding (blessed) model.
- Create a `Vertex AI Endpoint` resource
- Deploy the blessed model to the `Endpoint` resource.
- Create a Vertex AI Pipeline
- Get the blessed model.
- Import another instance (challenger) of the pretrained model.
- Register the pretrained (challenger) model as a new version of the existing blessed model.
- Create a synthetic model evaluation.
- Import the synthetic model evaluation metrics to the corresponding challenger model.
- Compare the evaluations and set the blessed or challenger as the default.
- Deploy the new blessed model.
```
[Pipeline control structures using the KFP SDK](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/control_flow_kfp.ipynb)
@@ -56,7 +81,7 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Pipelines](https://cloud.google.com/vertex-ai/docs/pipelines/introduction).
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Training components](https://cloud.google.com/vertex-ai/docs/training/create-training-pipeline).
&nbsp;&nbsp;&nbsp;Learn more about [Custom training components](https://cloud.google.com/vertex-ai/docs/training/create-training-pipeline).
[Training and batch prediction with BigQuery source and destinantion for a custom tabular classification model](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/custom_tabular_train_batch_pred_bq_pipeline.ipynb)
@@ -128,6 +153,8 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [AutoML components](https://cloud.google.com/vertex-ai/docs/pipelines/vertex-automl-component).
&nbsp;&nbsp;&nbsp;Learn more about [Regression for tabular data](https://cloud.google.com/vertex-ai/docs/tabular-data/classification-regression/overview).
[AutoML text classification pipelines using google-cloud-pipeline-components](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/google_cloud_pipeline_components_automl_text.ipynb)
@@ -211,7 +238,7 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Pipelines](https://cloud.google.com/vertex-ai/docs/pipelines/introduction).
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Training components](https://cloud.google.com/vertex-ai/docs/pipelines/customjob-component).
&nbsp;&nbsp;&nbsp;Learn more about [Custom training components](https://cloud.google.com/vertex-ai/docs/pipelines/customjob-component).
[Model upload, predict, and evaluate using google-cloud-pipeline-components](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/google_cloud_pipeline_components_model_upload_predict_evaluate.ipynb)
@@ -304,29 +331,5 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [AutoML components](https://cloud.google.com/vertex-ai/docs/pipelines/vertex-automl-component).
[Train custom tabular ML models with many frameworks and import to Vertex AI using Vertex Pipelines](https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/main/notebooks/official/pipelines/Train_tabular_models_with_many_frameworks_and_import_to_Vertex_AI_using_Pipelines)
&nbsp;&nbsp;&nbsp;Learn more about [BigQuery ML components](https://cloud.google.com/vertex-ai/docs/pipelines/bigqueryml-component).
Learn how to build a pipeline that does the following:
* Ingest data
* Transform data
* Clean up data
* Split data into train/test subsets
* Configure model
* Train model using multiple ML frameworks
* Import model into Vertex Model Registry
* [Optional] Deploy model to Vertex Endpoints for serving
Included pipelines:
* Train ML model
* * Tabular classification
* * * TensorFlow
* * * PyTorch
* * * XGBoost
* * * Scikit-learn
* * Tabular regression
* * * TensorFlow
* * * PyTorch
* * * XGBoost
* * * Scikit-learn
@@ -39,13 +39,13 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/pipelines/challenger_vs_blessed_deployment_method.ipynb\">\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/challenger_vs_blessed_deployment_method.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/pipelines/challenger_vs_blessed_deployment_method.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/pipelines/official/challenger_vs_blessed_deployment_method.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
@@ -72,7 +72,9 @@
"source": [
"## Overview\n",
"\n",
"This tutorial shows how to use Vertex AI Pipeline for deploying the next version of a model into production using the challenger vs blessed method."
"This tutorial shows how to use Vertex AI Pipeline for deploying the next version of a model into production using the challenger vs blessed method.\n",
"\n",
"Learn more about [Vertex AI Pipelines](https://cloud.google.com/vertex-ai/docs/pipelines/introduction) and [Model evaluation in Vertex AI](https://cloud.google.com/vertex-ai/docs/evaluation/introduction)."
]
},
{
@@ -163,8 +165,8 @@
"# Install the packages\n",
"USER=''\n",
"! pip3 install {USER} --upgrade google-cloud-aiplatform \\\n",
" google-cloud-pipeline-components \\\n",
" tensorflow==2.5 \\\n",
" google-cloud-pipeline-components\n",
"! pip3 install {USER} tensorflow==2.5 \\\n",
" tensorflow_hub\n",
" \n",
"! pip3 install {USER} --upgrade kfp"
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,892 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ur8xi4C7S06n"
},
"outputs": [],
"source": [
"# Copyright 2023 Google LLC\n",
"#\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"#\n",
"# https://www.apache.org/licenses/LICENSE-2.0\n",
"#\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "JAPoU8Sm5E6e"
},
"source": [
"# Serving PyTorch image models with prebuilt containers on Vertex AI\n",
"\n",
"\n",
"<table align=\"left\">\n",
"\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/prediction/pytorch_image_classification_with_prebuilt_serving_containers.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",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/prediction/pytorch_image_classification_with_prebuilt_serving_containers.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/official/prediction/pytorch_image_classification_with_prebuilt_serving_containers.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "tvgnzT1CKxrO"
},
"source": [
"## Overview\n",
"\n",
"This tutorial demonstrates how to upload and deploy a PyTorch image model using a prebuilt serving container and how to make online and batch predictions.\n",
"\n",
"Vertex AI provides prebuilt containers for serving predictions and explanations from trained model artifacts. Using a pre-built container is generally simpler than creating your own custom container for prediction.\n",
"\n",
"Learn more about [Pre-built containers for prediction](https://cloud.google.com/vertex-ai/docs/predictions/pre-built-containers)."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "d975e698c9a4"
},
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn how to package and deploy a PyTorch image classification model using a prebuilt Vertex AI container with TorchServe for serving online and batch predictions.\n",
"\n",
"This tutorial uses the following Google Cloud ML services and resources:\n",
"\n",
"- `Vertex AI Model Registry`\n",
"- `Vertex AI Model` resources\n",
"- `Vertex AI Endpoint` resources\n",
"\n",
"The steps performed include:\n",
"\n",
"- Download a pretrained image model from PyTorch\n",
"- Create a custom model handler\n",
"- Package model artifacts in a model archive file\n",
"- Upload model for deployment\n",
"- Deploy model for prediction\n",
"- Make online predictions\n",
"- Make batch predictions"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "08d289fa873f"
},
"source": [
"### Model\n",
"\n",
"This tutorial uses a pretrained image model [resnet18](https://pytorch.org/vision/master/models/generated/torchvision.models.resnet18.html) from the PyTorch TorchVision."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "aed92deeb4a0"
},
"source": [
"### Costs\n",
"\n",
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"* Vertex AI\n",
"* Cloud Storage\n",
"\n",
"Learn about [Vertex AI pricing](https://cloud.google.com/vertex-ai/pricing),\n",
"and [Cloud Storage pricing](https://cloud.google.com/storage/pricing),\n",
"and use the [Pricing Calculator](https://cloud.google.com/products/calculator/)\n",
"to generate a cost estimate based on your projected usage."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "i7EUnXsZhAGF"
},
"source": [
"## Installation\n",
"\n",
"Install the following packages required to execute this notebook."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "2b4ef9b72d43"
},
"outputs": [],
"source": [
"! pip3 install --upgrade --quiet google-cloud-aiplatform \\\n",
" tensorflow \\\n",
" torch \\\n",
" torchvision \\\n",
" torch-model-archiver"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "58707a750154"
},
"source": [
"### Colab only: Uncomment the following cell to restart the kernel."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "f200f10a1da3"
},
"outputs": [],
"source": [
"# Automatically restart kernel after installs so that your environment can access the new packages\n",
"# import IPython\n",
"\n",
"# app = IPython.Application.instance()\n",
"# app.kernel.do_shutdown(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "BF1j6f9HApxa"
},
"source": [
"## Before you begin\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"2. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"3. [Enable the Vertex AI API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com).\n",
"\n",
"4. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk)."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "WReHDGG5g0XY"
},
"source": [
"#### Set your project ID\n",
"\n",
"**If you don't know your project ID**, see the support page: [Locate the project ID](https://support.google.com/googleapi/answer/7014113)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "oM1iC_MfAts1"
},
"outputs": [],
"source": [
"PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}\n",
"\n",
"# Set the project id\n",
"! gcloud config set project {PROJECT_ID}"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "region"
},
"source": [
"#### Region\n",
"\n",
"You can also change the `REGION` variable used by Vertex AI. Learn more about [Vertex AI regions](https://cloud.google.com/vertex-ai/docs/general/locations)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "tTy1gX11kCJY"
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "sBCra4QMA2wR"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"Depending on your Jupyter environment, you may have to manually authenticate. Follow the relevant instructions below."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "74ccc9e52986"
},
"source": [
"**1. Vertex AI Workbench**\n",
"* Do nothing as you are already authenticated."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "de775a3773ba"
},
"source": [
"**2. Local JupyterLab instance, uncomment and run:**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "254614fa0c46"
},
"outputs": [],
"source": [
"# ! gcloud auth login"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ef21552ccea8"
},
"source": [
"**3. Colab, uncomment and run:**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "603adbbf0532"
},
"outputs": [],
"source": [
"# from google.colab import auth\n",
"# auth.authenticate_user()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "zgPO1eR3CYjk"
},
"source": [
"### Create a Cloud Storage bucket\n",
"\n",
"Create a storage bucket to store intermediate artifacts such as datasets."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "MzGDU7TWdts_"
},
"outputs": [],
"source": [
"BUCKET_URI = \"gs://your-bucket-name-unique\" # @param {type:\"string\"}"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "-EcIXiGsCePi"
},
"source": [
"**Only if your bucket doesn't already exist**: Run the following cell to create your Cloud Storage bucket."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "NIq7R4HZCfIc"
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION -p $PROJECT_ID $BUCKET_URI"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "960505627ddf"
},
"source": [
"### Import libraries"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "PyQmSRbKA8r-"
},
"outputs": [],
"source": [
"import base64\n",
"import json\n",
"import os\n",
"import pathlib\n",
"import urllib.request\n",
"\n",
"import tensorflow as tf\n",
"import torch\n",
"from google.cloud import aiplatform\n",
"from PIL import Image\n",
"from torchvision import models"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "init_aip:mbsdk,all"
},
"source": [
"### Initialize Vertex AI SDK for Python\n",
"\n",
"Initialize the Vertex AI SDK for Python for your project."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "BnBAXs5XkCJZ"
},
"outputs": [],
"source": [
"aiplatform.init(project=PROJECT_ID, location=REGION, staging_bucket=BUCKET_URI)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "_McUaTTABIqu"
},
"source": [
"## Download a pre-trained image model\n",
"\n",
"Download the pretrained image model [resnet18](https://pytorch.org/vision/master/models/generated/torchvision.models.resnet18.html) from the PyTorch TorchVision."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "9Ss_3SGpqOWy"
},
"outputs": [],
"source": [
"# Create a local directory for model artifacts\n",
"model_path = \"model\"\n",
"\n",
"!rm -r $model_path\n",
"!mkdir $model_path\n",
"\n",
"model_name = \"resnet-18-custom-handler\"\n",
"model_file = f\"{model_path}/{model_name}.pt\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "z62_eZEcEBKt"
},
"outputs": [],
"source": [
"# Use scripted mode to save the PyTorch model locally\n",
"model = models.resnet18(pretrained=True)\n",
"script_module = torch.jit.script(model)\n",
"script_module.save(model_file)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "FZpKK4FgDHeu"
},
"source": [
"## Create a custom model handler\n",
"\n",
"A custom model handler is a Python script that you package with the model when you use the model archiver. The script typically defines how to pre-process input data, invoke the model and post-process the output.\n",
"\n",
"TorchServe has [default handlers](https://pytorch.org/serve/default_handlers.html) for `image_classifier`, `image_segmenter`, `object_detector` and `text_classifier`. In this tutorial, you create a custom handler extending the default [`image_classifier`](https://github.com/pytorch/serve/blob/master/ts/torch_handler/image_classifier.py) handler.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "0jW_oUKNs0vQ"
},
"outputs": [],
"source": [
"hander_file = f\"{model_path}/custom_handler.py\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "toIO7mTus453"
},
"outputs": [],
"source": [
"%%writefile {hander_file}\n",
"\n",
"import torch\n",
"import torch.nn.functional as F\n",
"from ts.torch_handler.image_classifier import ImageClassifier\n",
"from ts.utils.util import map_class_to_label\n",
"\n",
"\n",
"class CustomImageClassifier(ImageClassifier):\n",
"\n",
" # Only return the top 3 predictions\n",
" topk = 3\n",
"\n",
" def postprocess(self, data):\n",
" ps = F.softmax(data, dim=1)\n",
" probs, classes = torch.topk(ps, self.topk, dim=1)\n",
" probs = probs.tolist()\n",
" classes = classes.tolist()\n",
" return map_class_to_label(probs, self.mapping, classes)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "sD9ttWmqhPME"
},
"source": [
"## Download an index_to_name.json file\n",
"\n",
"PyTorch `image_classifier`, `text_classifier` and `object_detector` can all automatically map from numeric classes (0,1,2...) to friendly strings. To do this, simply include `index_to_name.json` that contains a mapping of class number to friendly name in your model archive file."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "m19wquufqOaL"
},
"outputs": [],
"source": [
"index_to_name_file = f\"{model_path}/index_to_name.json\"\n",
"\n",
"urllib.request.urlretrieve(\n",
" \"https://github.com/pytorch/serve/raw/master/examples/image_classifier/index_to_name.json\",\n",
" index_to_name_file,\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "MJe1luzPjPCJ"
},
"source": [
"## Package the model artifacts in a model archive file\n",
"\n",
"You package all the model artifacts in a model archive file using the [`Torch model archiver`](https://github.com/pytorch/serve/tree/master/model-archiver).\n",
"\n",
"Note that the prebuilt PyTorch serving containers require the model archive file named as `model.mar` so you need to set the model-name as `model` in the `torch-model-archiver` command."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "mtP3s0MLqOL8"
},
"outputs": [],
"source": [
"# Add torch-model-archiver to the PATH\n",
"os.environ[\"PATH\"] = f'{os.environ.get(\"PATH\")}:~/.local/bin'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "pN1BqokBtHAS"
},
"outputs": [],
"source": [
"!torch-model-archiver -f \\\n",
" --model-name model \\\n",
" --version 1.0 \\\n",
" --serialized-file $model_file \\\n",
" --handler $hander_file \\\n",
" --extra-files $index_to_name_file \\\n",
" --export-path $model_path"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "8qXVlPVTlRgP"
},
"source": [
"## Copy the model artifacts to Cloud Storage\n",
"\n",
"Next, use `gsutil` to copy the model artifacts to your Cloud Storage bucket."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "hsJ6YVaitHVW"
},
"outputs": [],
"source": [
"MODEL_URI = f\"{BUCKET_URI}/{model_name}\"\n",
"\n",
"!gsutil rm -r $MODEL_URI\n",
"!gsutil cp -r $model_path $MODEL_URI\n",
"!gsutil ls -al $MODEL_URI"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "B9Ep0eANl7te"
},
"source": [
"## Upload model for deployment\n",
"\n",
"Next, you upload the [model](https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.models) to `Vertex AI Model Registry`, which will create a `Vertex AI Model` resource for your model. This tutorial uses the PyTorch v1.11 container, but for your own use case, you can choose from the list of [PyTorch prebuilt containers](https://cloud.google.com/vertex-ai/docs/predictions/pre-built-containers#pytorch)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "igJgzA6btPL7"
},
"outputs": [],
"source": [
"DEPLOY_IMAGE_URI = \"us-docker.pkg.dev/vertex-ai/prediction/pytorch-cpu.1-11:latest\"\n",
"\n",
"deployed_model = aiplatform.Model.upload(\n",
" display_name=model_name,\n",
" serving_container_image_uri=DEPLOY_IMAGE_URI,\n",
" artifact_uri=MODEL_URI,\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Tys97v6XpLmF"
},
"source": [
"## Deploy model for prediction\n",
"\n",
"Next, deploy your model for online prediction. You set the variable `DEPLOY_COMPUTE` to configure the machine type for the [compute resources](https://cloud.google.com/vertex-ai/docs/predictions/configure-compute) you will use for prediction."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ka_zUL6-tPxW"
},
"outputs": [],
"source": [
"DEPLOY_COMPUTE = \"n1-standard-4\"\n",
"\n",
"endpoint = deployed_model.deploy(\n",
" deployed_model_display_name=model_name,\n",
" machine_type=DEPLOY_COMPUTE,\n",
" accelerator_type=None,\n",
" accelerator_count=0,\n",
")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "Dp2oUReOpx7X"
},
"source": [
"## Make online predictions\n",
"\n",
"### Download an image dataset\n",
"In this example, you use the TensorFlow flowers dataset for the input for both online and batch predictions."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "nwKmNS-UqOP3"
},
"outputs": [],
"source": [
"data_dir = tf.keras.utils.get_file(\n",
" \"flower_photos\",\n",
" origin=\"https://storage.googleapis.com/download.tensorflow.org/example_images/flower_photos.tgz\",\n",
" untar=True,\n",
")\n",
"\n",
"data_dir = pathlib.Path(data_dir)\n",
"images_files = list(data_dir.glob(\"daisy/*\"))"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "0xRXkbxZqDkc"
},
"source": [
"### Get online predictions\n",
"\n",
"You send a `predict` request with encoded input image data to the `endpoint` and get prediction."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "lzooJLwUtXiU"
},
"outputs": [],
"source": [
"with open(images_files[0], \"rb\") as f:\n",
" data = {\"data\": base64.b64encode(f.read()).decode(\"utf-8\")}\n",
"\n",
"response = endpoint.predict(instances=[data])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "w3qgFiMyuUb3"
},
"outputs": [],
"source": [
"prediction = response.predictions[0]\n",
"prediction = dict(sorted(prediction.items(), key=lambda item: item[1], reverse=True))\n",
"\n",
"print(prediction)\n",
"image = Image.open(images_files[0])\n",
"image"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "6o93-TkuqXS-"
},
"source": [
"## Make batch predictions\n",
"\n",
"### Create the batch input file\n",
"\n",
"You create a batch input file in JSONL format and store the input file in your Cloud Storage bucket.\n",
"\n",
"Learn more about [Input data requirements](https://cloud.google.com/vertex-ai/docs/predictions/get-predictions#input_data_requirements)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ChsjFzwW0rBj"
},
"outputs": [],
"source": [
"TEST_IMAGE_SIZE = 2\n",
"test_image_list = []\n",
"for i in range(TEST_IMAGE_SIZE):\n",
" test_image_list.append(str(images_files[i]))\n",
"\n",
"gcs_input_uri = f\"{BUCKET_URI}/test_images.json\"\n",
"\n",
"with tf.io.gfile.GFile(gcs_input_uri, \"w\") as f:\n",
" for test_image in test_image_list:\n",
" with open(test_image, \"rb\") as image_f:\n",
" data = {\"data\": base64.b64encode(image_f.read()).decode(\"utf-8\")}\n",
" f.write(json.dumps(data) + \"\\n\")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "_Ap-UO4tsJiO"
},
"source": [
"### Submit a batch prediction job"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "HhH6KyIk0t3n"
},
"outputs": [],
"source": [
"JOB_DISPLAY_NAME = f\"{model_name}_batch_predict_job_unique\"\n",
"\n",
"batch_predict_job = deployed_model.batch_predict(\n",
" job_display_name=JOB_DISPLAY_NAME,\n",
" gcs_source=gcs_input_uri,\n",
" gcs_destination_prefix=BUCKET_URI,\n",
" instances_format=\"jsonl\",\n",
" model_parameters=None,\n",
" machine_type=DEPLOY_COMPUTE,\n",
")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "2gVBOadysOSY"
},
"source": [
"### Get batch predictions\n",
"\n",
"After the batch job completes, the results are written to the Cloud Storage output bucket you specified in the batch request. You call the method `iter_outputs()` to get a list of each Cloud Storage file generated with the results."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "wXcrGXrf0yVb"
},
"outputs": [],
"source": [
"bp_iter_outputs = batch_predict_job.iter_outputs()\n",
"\n",
"prediction_files = list()\n",
"for blob in bp_iter_outputs:\n",
" if blob.name.split(\"/\")[-1].startswith(\"prediction.results\"):\n",
" prediction_files.append(blob.name)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "4f7nXK1Y0vmd"
},
"outputs": [],
"source": [
"prediction_file = prediction_files[0]\n",
"\n",
"results = []\n",
"gfile_name = f\"{BUCKET_URI}/{prediction_file}\"\n",
"with tf.io.gfile.GFile(name=gfile_name, mode=\"r\") as gfile:\n",
" for line in gfile.readlines():\n",
" results.append(json.loads(line))\n",
"\n",
"# Take one result as an example and print out the prediction.\n",
"prediction = results[0][\"prediction\"]\n",
"prediction = dict(sorted(prediction.items(), key=lambda item: item[1], reverse=True))\n",
"print(prediction)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "TpV-iwP9qw9c"
},
"source": [
"## Cleaning up\n",
"\n",
"To clean up all Google Cloud resources used in this project, you can [delete the Google Cloud\n",
"project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#shutting_down_projects) you used for the tutorial.\n",
"\n",
"Otherwise, you can delete the individual resources you created in this tutorial."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "sx_vKniMq9ZX"
},
"outputs": [],
"source": [
"endpoint.undeploy_all()\n",
"endpoint.delete()\n",
"\n",
"deployed_model.delete()\n",
"batch_predict_job.delete()\n",
"\n",
"delete_bucket = False\n",
"if delete_bucket:\n",
" ! gsutil -m rm -r $BUCKET_URI"
]
}
],
"metadata": {
"colab": {
"name": "pytorch_image_classification_with_prebuilt_serving_containers.ipynb",
"toc_visible": true
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
+2 -2
View File
@@ -16,7 +16,7 @@ The steps performed include the following:
```
&nbsp;&nbsp;&nbsp;Learn more about [AutoML Video](https://cloud.google.com/vertex-ai/docs/tutorials/video-classification-automl/training).
&nbsp;&nbsp;&nbsp;Learn more about [Classification for video data](https://cloud.google.com/vertex-ai/docs/training-overview#classification_for_videos).
[Custom training using Python package, managed text dataset, and TF Serving container](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/sdk/SDK_Custom_Training_Python_Package_Managed_Text_Dataset_Tensorflow_Serving_Container.ipynb)
@@ -38,5 +38,5 @@ The steps performed include:
```
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
&nbsp;&nbsp;&nbsp;Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
+2 -2
View File
@@ -1,11 +1,11 @@
[Vertex AI Explainations with TabNet models](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/tabnet/ai-explanations-tabnet-algorithm.ipynb)
[Vertex AI Explanations with TabNet models](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/tabnet/ai-explanations-tabnet-algorithm.ipynb)
```
Learn how to provide a sample plotting tool to visualize the output of TabNet, which is helpful in explaining the algorithm.
The steps performed are:
* Setup the the project.
* Setup the project.
* Download the prediction data of pretrain model onf Syn2 data.
* Visualize and understand the feature importance based on the masks output.
* Clean up the resource created by this tutorial.
@@ -1,4 +1,20 @@
[Train a Prophet Model using Vertex AI Tabular Workflows](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/tabular_workflows/prophet_on_vertex_pipelines.ipynb)
```
Learn how to create several Prophet models using a training Vertex AI Pipeline from Google Cloud Pipeline Components , and then do a batch prediction using the corresponding prediction pipeline.
The steps performed are:
1. Train the Prophet models.
1. View the evaluation metrics.
1. Make a batch prediction with the Prophet models.
```
&nbsp;&nbsp;&nbsp;Learn more about [Google Cloud Pipeline Components](https://cloud.google.com/vertex-ai/docs/pipelines/components-introduction).
[TabNet Pipeline](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/tabular_workflows/tabnet_on_vertex_pipelines.ipynb)
```
@@ -78,7 +78,7 @@
"\n",
"Although Prophet is a multivariate model, Vertex AI does not yet have support for external regressors, so it can only be used as a univariate model.\n",
"\n",
"Learn more about [Google Cloud Pipeline Components](https://cloud.google.com/vertex-ai/docs/pipelines/components-introduction)."
"Learn more about [Google Cloud Pipeline Components](https://cloud.google.com/vertex-ai/docs/pipelines/components-introduction) and [Prophet for tabular data](https://cloud.google.com/vertex-ai/docs/tabular-data/forecasting-prophet)."
]
},
{
+34 -2
View File
@@ -15,7 +15,7 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI TensorBoard](https://cloud.google.com/vertex-ai/docs/experiments/tensorboard-overview).
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
&nbsp;&nbsp;&nbsp;Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
[Vertex AI TensorBoard custom training with prebuilt container](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/tensorboard/tensorboard_custom_training_with_prebuilt_container.ipynb)
@@ -34,7 +34,23 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI TensorBoard](https://cloud.google.com/vertex-ai/docs/experiments/tensorboard-overview).
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
&nbsp;&nbsp;&nbsp;Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
[Vertex AI TensorBoard Hyperparameter Tuning with the HParams Dashboard](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/tensorboard/tensorboard_hyperparameter_tuning_with_hparams.ipynb)
```
This tutorial shows you how to log hyperparameter experiment results in TensorFlow and visualize the results in TensorBoard's Hparams dashboard.
The steps performed include:
* Adapt TensorFlow runs to log hyperparameters and metrics.
* Start runs and log them all under one parent directory.
* Visualize the results in TensorBoard's HParams dashboard.
```
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI TensorBoard](https://cloud.google.com/vertex-ai/docs/experiments/tensorboard-overview).
[Profile model training performance using Vertex AI TensorBoard Profiler](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/tensorboard/tensorboard_profiler_custom_training.ipynb)
@@ -54,6 +70,22 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI TensorBoard Profiler](https://cloud.google.com/vertex-ai/docs/experiments/tensorboard-profiler).
[Profile model training performance using Vertex AI TensorBoard Profiler in custom training with prebuilt container](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/tensorboard/tensorboard_profiler_custom_training_with_prebuilt_container.ipynb)
```
Learn how to enable the TensorBoard Profiler in Vertex AI for custom training jobs with a prebuilt container.
The steps performed include:
- Prepare your custom training code and load your training code as a Python package to a prebuilt container
- Create and run a custom training job that enables the TensorBoard Profiler
- View the TensorBoard Profiler dashboard to debug your model training performance
```
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI TensorBoard Profiler](https://cloud.google.com/vertex-ai/docs/experiments/tensorboard-profiler).
[Vertex AI TensorBoard integration with Vertex AI Pipelines](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/tensorboard/tensorboard_vertex_ai_pipelines_integration.ipynb)
```
+23 -3
View File
@@ -2,7 +2,7 @@
[Get started with Vertex AI Distributed Training](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/training/get_started_with_vertex_distributed_training.ipynb)
```
Learn how to use `Vertex AI Distributed Training` for when training with `Vertex AI`.
Learn how to use `Vertex AI Distributed Training` when training with `Vertex AI`.
The steps performed include:
@@ -66,7 +66,27 @@ The steps performed include:
```
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
&nbsp;&nbsp;&nbsp;Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
[Training, tuning and deploying a PyTorch text sentiment classification model on Vertex AI](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/training/pytorch-text-sentiment-classification-custom-train-deploy.ipynb)
```
Learn to build, train, tune and deploy a PyTorch model on Vertex AI.
The steps performed include:
- Create training package for the text classification model.
- Train the model with custom training on Vertex AI.
- Check the created model artifacts.
- Create a custom container for predictions.
- Deploy the trained model to a Vertex AI Endpoint using the custom container for predictions.
- Send online prediction requests to the deployed model and validate.
- Clean up the resources created in this notebook.
```
&nbsp;&nbsp;&nbsp;Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
[Create a distributed custom training job](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/training/xgboost_data_parallel_training_on_cpu_using_dask.ipynb)
@@ -83,5 +103,5 @@ The steps performed include:
```
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
&nbsp;&nbsp;&nbsp;Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
@@ -29,7 +29,7 @@
"id": "eoXf8TfQoVth"
},
"source": [
"# Create a distributed custom training job\n",
"# Distributed XGBoost training with Dask\n",
"\n",
"<table align=\"left\">\n",
"\n",
@@ -61,12 +61,13 @@
"source": [
"## Overview\n",
"\n",
"This tutorial shows you how to create a distributed custom training job on Vertex AI that can handle large amounts of training data.\n",
"This tutorial shows you how to create a distributed custom training job using XGBoost with Dask on Vertex AI that can handle large amounts of training data.\n",
"\n",
"Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training)."
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "AksIKBzZ-nre"
@@ -74,7 +75,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn how to create a distributed training job using Vertex AI SDK for Python. You build a custom docker container with simple Dask configuration to run a custom training job.\n",
"In this tutorial, you learn how to create a distributed training job using XGBoost with Dask. You build a custom docker container with simple Dask configuration to run a custom training job. When your training job is running, you can access the Dask dashboard to monitor the real-time status of your cluster, resources, and computations.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
+2 -2
View File
@@ -55,7 +55,7 @@ The steps performed include:
* Model with BigQuery and the ARIMA model
* Evaluate the model
* Evaluate the model results using BigQuery ML (on training data)
* Evalute the model results - MAE, MAPE, MSE, RMSE (on test data)
* Evaluate the model results - MAE, MAPE, MSE, RMSE (on test data)
* Use the executor feature
```
@@ -107,7 +107,7 @@ The steps performed include:
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Workbench](https://cloud.google.com/vertex-ai/docs/workbench/introduction).
&nbsp;&nbsp;&nbsp;Learn more about [Vertex AI Training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
&nbsp;&nbsp;&nbsp;Learn more about [Custom training](https://cloud.google.com/vertex-ai/docs/training/custom-training).
[Churn prediction for game developers using Google Analytics 4 and BigQuery ML](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/workbench/gaming_churn_prediction/churn_prediction_for_game_developers.ipynb)