Compare commits

..
Author SHA1 Message Date
Eric Schmidt 36df462615 chore: revisions to Stable Diffusion and TorchServe nb 2023-02-15 02:32:02 +00:00
Andrew FerlitschandGitHub 909f771bfd Merge pull request #1514 from abcdefgs0324/pytorch_ga
Update wording for pre-built pytorch images on Vertex Prediction.
2023-02-14 17:07:03 +00:00
Eric SchmidtandGitHub e9bef3542d Merge pull request #1510 from GoogleCloudPlatform/stable-diffusion-try2
feat: adds stable diffusion notebook with PyTorch serving
2023-02-13 20:33:24 +00:00
Chun-Hsiang Wang 52385a6071 samples: Updated wording and removed preview email. 2023-02-10 00:43:43 +00:00
Chun-Hsiang WangandGitHub 2365d733c4 Merge branch 'GoogleCloudPlatform:main' into pytorch_ga 2023-02-09 12:55:15 -08:00
Andrew FerlitschandGitHub 6ef111144d fix: lost updates (#1513) 2023-02-08 18:35:05 -05:00
Chun-Hsiang Wang 7c123e68d3 samples: Remove experimental text from Pytorch sample. 2022-11-30 07:46:08 +00:00
3 changed files with 36 additions and 51 deletions
@@ -31,17 +31,7 @@
"source": [
"# Deploying a PyTorch Text Classification Model on [Vertex AI](https://cloud.google.com/vertex-ai)\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",
"\n",
"Experiments 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.\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",
"\n",
"The usage of the product is free during the Experimental release period: you will still incur charges for other GCP products usage, such as storage.\n",
"\n",
"The projects need to be added to the allowlist in order to deploy PyTorch models using Vertex AI Prediction pre-built PyTorch images. If you are interested in the feature, please send an email to vertexai-prediction-preview-feedback@google.com to provide your project numbers OR project ids."
"**Kindly reach out to Vertex AI before you run any scale tests or you have any questions.**\n"
]
},
{
@@ -90,7 +90,7 @@
"\n",
"+ Create a `torchserve` handler for responding to prediction requests.\n",
"+ Upload a Stable Diffusion 1.5 model on a prebuilt PyTorch container in Vertex AI.\n",
"+ Deploy a custom model to a Vertex AI Endpoint.\n",
"+ Deploy a model to a Vertex AI Endpoint.\n",
"+ Send requests to the endpoint and parse the responses using Vertex AI Prediction service."
]
},
@@ -100,7 +100,7 @@
"id": "c6deba5a8557"
},
"source": [
"### Dataset\n",
"### Model\n",
"\n",
"This notebook uses a collection of model artifacts fine-tuned to generate images of a small dog. These are the same images used in the original [DreamBooth paper](https://dreambooth.github.io/)."
]
@@ -118,7 +118,7 @@
"* Vertex AI models\n",
"* Vertex AI endpoints\n",
"* Vertex AI prediction\n",
"* Google Cloud Storage\n",
"* Cloud Storage\n",
"* (Optionally) Vertex AI Workbench\n",
"\n",
"Learn about [Vertex AI pricing](https://cloud.google.com/vertex-ai/pricing) and [Cloud Storage pricing](https://cloud.google.com/storage/pricing), and use the [Pricing Calculator](https://cloud.google.com/products/calculator/) to generate a cost estimate based on your projected usage."
@@ -420,7 +420,6 @@
"outputs": [],
"source": [
"import base64\n",
"import gc\n",
"import math\n",
"\n",
"import torch\n",
@@ -437,9 +436,9 @@
"id": "697566b5f660"
},
"source": [
"## View model inferences\n",
"## Optional: View model inferences\n",
"\n",
"Before uploading the model to Vertex AI, you can review the expected output from the model. The model used in this notebook is available for your use and can be downloaded from Google Cloud Storage. This download may take a few minutes to complete."
"Before uploading the model to Vertex AI, you can review the expected output from the model. The model used in this notebook is available for your use and can be downloaded from Cloud Storage. This download may take a few minutes to complete."
]
},
{
@@ -574,31 +573,6 @@
"grid"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "cf8d545a135b"
},
"source": [
"### Re-training the model\n",
"\n",
"If you aren't satisfied with the inference outputs from the model, you can retrain it. Before you can do that, you might need to release the GPU memory."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "5621b7a927f8"
},
"outputs": [],
"source": [
"# Run this cell _only_ if you want to release the GPU memory.\n",
"pipe = None\n",
"gc.collect()\n",
"torch.cuda.empty_cache()"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -607,10 +581,10 @@
"source": [
"## Deploy the model to Vertex AI\n",
"\n",
"You can host your Stable Diffusion 2.0 model on a Vertex AI endpoint where you can get inferences from it online. Uploading your model is a four step process: \n",
"You can host your Stable Diffusion 1.5 model on a Vertex AI endpoint where you can get inferences from it online. Uploading your model is a four step process: \n",
"\n",
"1. Create a custom TorchServe handler.\n",
"1. Upload the model artifacts onto Google Cloud Storage.\n",
"1. Upload the model artifacts onto Cloud Storage.\n",
"2. Create a Vertex AI model with the model artifacts and a prebuilt PyTorch container image.\n",
"3. Deploy the Vertex AI model onto an endpoint."
]
@@ -740,9 +714,9 @@
"id": "ffab030f4bc8"
},
"source": [
"### Upload the model artifacts to Google Cloud Storage\n",
"### Upload the model artifacts to Cloud Storage\n",
"\n",
"Create a new folder in your Google Cloud Storage bucket to hold the model artifacts"
"Create a new folder in your Cloud Storage bucket to hold the model artifacts"
]
},
{
@@ -838,6 +812,16 @@
"aiplatform.init(project=PROJECT_ID, location=REGION, staging_bucket=BUCKET_NAME)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "FAPoU8Sm5E6e"
},
"source": [
"<div style=\"background:#e3effe; padding:5px; color:#0000aa\">\n",
"<strong>Note:</strong> The next cell fails if you haven't <a href=\"https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com\"><u>enabled the Vertex API</u></a>.</div>"
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -907,7 +891,7 @@
"id": "c9fc560df0a9"
},
"source": [
"The previous cell, which deploys your model to the nedpoint, can take a while to complete. If the previous cell times out before returning, your endpoint might still be successfully deployed ot an end point. Check the [Cloud Console](https://console.cloud.google.com/vertex-ai/endpoints) to verify the results.\n",
"The previous cell, which deploys your model to the endpoint, can take a while to complete. If the previous cell times out before returning, your endpoint might still be successfully deployed to an endpoint. Check the [Cloud Console](https://console.cloud.google.com/vertex-ai/endpoints) to verify the results.\n",
"\n",
"You can also extend the time to wait for deployment by changing the `deploy_request_timeout` argument passed to `model.deploy()`."
]
@@ -920,7 +904,7 @@
"source": [
"## Get online predictions\n",
"\n",
"Finally, with your Stable Diffusion 2.0 model deployed to a Vertex AI endpoint, you can now get online predictions from it. Using the Vertex AI SDK, you only need a few lines of code to get an inference."
"Finally, with your Stable Diffusion 1.5 model deployed to a Vertex AI endpoint, you can now get online predictions from it. Using the Vertex AI SDK, you only need a few lines of code to get an inference."
]
},
{
+14 -3
View File
@@ -1140,7 +1140,7 @@ def add_index(path: str,
print(f' {tag.strip()}<br/>\n')
print(' </td>')
print(' <td>')
print(f' <b>{title}</b>.\n')
print(f' <b>{title}</b>. ')
if args.desc:
desc = replace_cl(desc.replace('`', ''))
print('<br/>')
@@ -1172,8 +1172,19 @@ def add_index(path: str,
print(f' Learn more about <a href="{linkbacks[_]}." target="_blank">{replace_cl(tags[_])}</a>.\n')
if args.steps:
steps = replace_cl(steps.replace('\n', '<br/>').replace('-', '&nbsp;&nbsp;-').replace('**', '').replace('*', '&nbsp;&nbsp;-').replace('`', ''))
print('<br/><br/>' + steps + '<br/>')
print("<devsite-expandable>\n")
print(' <h6 class="showalways">Notebook steps</h6>\n')
print(' <ul>\n')
if ":" in steps:
steps = steps.split(':')[1].replace('*', '').replace('-', '').strip().split('\n')
else:
steps = []
for step in steps:
print(f' <li>{replace_cl(step)}</li>\n')
print(' </ul>\n')
print("</devsite-expandable>\n")
print(' </td>')
print(' <td>')