End-to-End Model Development with Vertex AI: Building, Deploying, and Testing via Postman.

Jasmine Elamblakatt
4 min readOct 11, 2023

--

Vertex AI is a machine learning platform by Google Cloud that simplifies and accelerates the development and deployment of AI models. It offer a suite of tools and services to streamline the end-to-end machine learning workflow.

To create model only 3 steps are required

  1. Upload Images and assign Labels.

2. Train

3. Assign Endpoint

Upload Images and assign Labels

First we need to setup dataset for training data for model

First enable Vertex Api from cloud.google account.

Then create dataset as shown below

Once dataset is created, import training images to the dataset. Minimum requirement is 2 labels with 10 images in each label.

Vertex AI requires cloud storage bucket to add images so while importing create a storage bucket as below

Once images are uploaded, add labels and assign images in each labels

Here I am creating 3 labels cables, laptops and monitor and adding 25 images each in the labels.

We have 3 labels with 25 images each. Next let’s create a model with these training data. Click TRAIN NEW MODEL

Select the budget as 8, as minimum of 8 node hours is required.

Training will take some hours to get completed, my model took around 3 hour to get completed.

Once the training is completed, we can view all the details of the model as above.(I renamed my model to demo_model).

Create endpoint and Deploy:

To create endpoint, select “Deploy and Test” and create a new endpoint to consume the model created.

Once the endpoint is successfully created, go to the model select “Deploy and Test” and upload a image and test the model.

Hurray its detecting cables 😎😎😃😀

Next lets try to invoke this from the Postman console;

We need to authenticate the user in order to invoke the endpoint from client side

Search for Api & services in cloud console and create OAuth client ID

Select OAuth Client Id and fill the contest screen, once that is done select web Application for Postman client testing.

Add the redirect URI as below:

Browser: https://oauth.pstmn.io/v1/browser-callback

Desktop: https://oauth.pstmn.io/v1/callback

Once created copy the clientId, client secret etc.

Now open Postman and select POST request with Authorisation section and add below fields

Auth URL : https://accounts.google.com/o/oauth2/auth
Access Token URL :
https://accounts.google.com/o/oauth2/token
Client ID : CLIENTIDHERE.googleusercontent.com
Client Secret : CLIENTSECRETHERE
Scope :
https://www.googleapis.com/auth/cloud-platform

Scroll down and select “Get New Access Token” as below

Now it will open up google Account page in browser, give it access so that the call is authenticated.

If you face error while giving access, go to cloud console and add test user with the logged in mail id;

Once you get the access token, use it in request and invoke the model as below

Post request URL :

https://us-central1-aiplatform.googleapis.com/v1/projects/${project-id}/locations/us-central1/endpoints/${endpoint-id}:predict

Add below in body section, also add in headers the content type.

Content-Type: application/json”

{
"instances": [{
"content": "YOUR_IMAGE_BYTES"
}],
"parameters": {
"confidenceThreshold": 0.5,
"maxPredictions": 5
}
}

There we go!!! It detect the image as “cables”😎😀.

--

--