Compare commits

...
7 Commits
@@ -385,12 +385,11 @@
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"IS_COLAB = \"google.colab\" in sys.modules\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
@@ -1068,7 +1067,6 @@
"- `model`: The `Model` resource.\n",
"- `deployed_model_displayed_name`: The human readable name for the deployed model instance.\n",
"- `machine_type`: The machine type for each VM instance.\n",
"- `traffic_split`: Set to `{}` to indicate no traffic split.\n",
"\n",
"Do to the requirements to provision the resource, this may take upto a few minutes."
]
@@ -1085,7 +1083,6 @@
" model=model,\n",
" deployed_model_display_name=\"example_\" + TIMESTAMP,\n",
" machine_type=DEPLOY_COMPUTE,\n",
" traffic_split={}, # no traffic split\n",
")\n",
"\n",
"print(endpoint)"
@@ -1187,62 +1184,6 @@
" f.write(json.dumps({\"instances\": [{serving_input: {\"b64\": b64str}}]}))"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "23e995c35fd6"
},
"source": [
"#### Construct the `Private Endpoint` URI\n",
"\n",
"Next, you construct the URI for the `Private Endpoint`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "97b248b2efb5"
},
"outputs": [],
"source": [
"endpoint_id = endpoint.resource_name\n",
"\n",
"ENDPOINT_URL = ! gcloud beta ai endpoints describe {endpoint_id} \\\n",
" --region={REGION} \\\n",
" --format=\"value(deployedModels.privateEndpoints.predictHttpUri)\"\n",
"\n",
"private_url = ENDPOINT_URL[1]\n",
"print(private_url)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "27605b5f0c3a"
},
"source": [
"### Make the prediction request using curl\n",
"\n",
"Use `curl` to make the prediction request to the private URI."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "6cb568e6bb49"
},
"outputs": [],
"source": [
"output = ! curl -X POST -d@instances.json $private_url\n",
"\n",
"predictions = output[5]\n",
"print(predictions)\n",
"\n",
"! rm test.jpg instances.json"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -1251,7 +1192,7 @@
"source": [
"### Make the prediction request using SDK\n",
"\n",
"Finally, use the `Vertex AI SDK` to make a prediction request."
"Next, use the `Vertex AI SDK` to make a prediction request."
]
},
{