Build an application

This page shows you how to create an app and combine components - such as input streams, models for analysis, and warehouses for storage - for use on Gemini Enterprise Agent Platform Vision's app platform.

To build an app you must consider your data sources, the analysis you want to perform, and how you want to store the results. An end-to-end app can have different forms depending on your use case. Consequently, how you build an app will depend on your objective.

Before beginning, assess your use case and objective from a Responsible AI perspective and consider what impact your models and applications could have on your end users when things go wrong. Read more on first steps in assessing your use case for fairness. Also ensure that your use of Gemini Enterprise Agent Platform Vision is in compliance with Google Cloud's Terms of Service or an offline variant, and the incorporated URL Terms like Google Cloud's Acceptable Use Policy.

As you create your application, keep in mind that AI vision technologies carry the potential to reinforce or introduce unfair bias and to impact fundamental human rights. Developing your application should involve ethical reflection based on your company's values, and legal due diligence for your particular use case including high risk use cases. As with all technologies, you must consider all applicable laws and regulations governing your use of AI/ML technologies in the region you are implementing the technology. Customers are responsible for due diligence required to implement use cases that are considered high risk in a particular region.

Create a new application

Before you can add components like a stream or models to an app you must create the app itself. All apps must contain the following to be deployed:

  • A stream input node (data source).
  • At least one other component node, such as a model or warehouse.

Create a new custom application

Console

Create an app in the Google Cloud console.

  1. Open the Applications tab of the Gemini Enterprise Agent Platform Vision dashboard.

    Go to the Applications tab

  2. Click the Create button.

  3. Enter an app name and choose your region. Supported regions.

  4. Click Create.

Create an application with a template

Console

Create an app in the Google Cloud console.

  1. Open the Applications tab of the Gemini Enterprise Agent Platform Vision dashboard.

    Go to the Applications tab

  2. Click the Create button.

  3. Enter an app name and choose your region. Supported regions.

  4. Click Create.

  5. In the application builder page, click the Application template node.

  6. From the side settings panel, click the Select model button.

  7. Select a model from the dropdown menu.

Add stream input

An application must contain a video stream node. You are unable to deploy the application if you don't add a Streams node.

If your application is not deployed, your stream input update will be automatically applied to the application. If your app is already deployed you must undeploy it and update it for changes to be applied. See the update an app section for more details.

Console

Add a stream to an app in the Google Cloud console.

  1. Open the Applications tab of the Gemini Enterprise Agent Platform Vision dashboard.

    Go to the Applications tab

  2. Click View app for your app.

  3. From the side list of components, choose Video streams from the list of Connectors. The stream node is added to the app graph and a side Video streams menu opens.

  4. Select Add video streams.

  5. If you choose to Select from existing streams, select the existing stream and select Add streams.

    If you choose to Register new streams, add a name for the new stream and select Add streams.

REST

To add a stream to an app, send a POST request by using the projects.locations.applications.addStreamInput method.

Before using any of the request data, make the following replacements:

  • PROJECT: Your Google Cloud project ID or project number.
  • LOCATION_ID: The region where you are using Agent Platform Vision. For example: us-central1, europe-west4. See available regions.
  • APPLICATION_ID: The ID of your target application.
  • STREAM_ID: The ID of the target stream.

HTTP method and URL:

POST https://visionai.googleapis.com/v1/projects/PROJECT/locations/LOCATION_ID/applications/APPLICATION_ID:addStreamInput

Request JSON body:

{
  "applicationStreamInputs": [
     {
       "streamWithAnnotation": {
         "stream": "projects/PROJECT/locations/LOCATION_ID/clusters/application-cluster-0/streams/STREAM_ID"
       }
     },
     {
       "streamWithAnnotation": {
         "stream": "projects/PROJECT/locations/LOCATION_ID/clusters/application-cluster-0/streams/STREAM_ID"
       }
     }
   ]
}

To send your request, choose one of these options:

curl

Save the request body in a file named request.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://visionai.googleapis.com/v1/projects/PROJECT/locations/LOCATION_ID/applications/APPLICATION_ID:addStreamInput"

PowerShell

Save the request body in a file named request.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://visionai.googleapis.com/v1/projects/PROJECT/locations/LOCATION_ID/applications/APPLICATION_ID:addStreamInput" | Select-Object -Expand Content

You should receive a successful status code (2xx) and an empty response.

Add stream input with node annotations

When you create an application input stream you can add annotations to the stream using the Gemini Enterprise Agent Platform Vision API. You can also add annotations to a node in the Google Cloud console.

Console

The following sample adds available annotations (STREAM_ANNOTATION_TYPE_ACTIVE_ZONE and STREAM_ANNOTATION_TYPE_CROSSING_LINE) to an occupancy count model.

  1. Open the Applications tab of the Gemini Enterprise Agent Platform Vision dashboard.

    Go to the Applications tab

  2. Select View app next to the name of your application from the list.

  3. On the application builder page select the model with stream input you want to add annotations to.

  4. In the side model setting panel, expand the "Advanced setting" section. After expanding the section, click the Create active zones/lines button.

  5. In the stream gallery view, select an input stream to draw active zones or lines.

  6. In the editor view, choose add multi-point lines or add simple polygon to add annotations. Use the side panel to rename the zone or line name, delete existing zones/lines, or switch line direction.

REST & CMD LINE

The following code adds stream annotations.

Before using any of the request data, make the following replacements:

  • PROJECT: Your Google Cloud project ID or project number.
  • LOCATION_ID: The region where you are using Agent Platform Vision. For example: us-central1, europe-west4. See available regions.
  • APPLICATION_ID: The ID of your target application.
  • STREAM_ID: The ID of the target stream.
  • NODE_NAME: The name of the target node from the app graph. For example, builtin-occupancy-count.
  • ANNOTATION_ID: The ID of your target annotation.
  • ANNOTATION_DISPLAYNAME: The user-specified display name of your target annotation.
  • ANNOTATION_TYPE: One of the available enum values. This type must match the annotation_payload object, either activeZone or crossingLine. Available values are:
    • STREAM_ANNOTATION_TYPE_UNSPECIFIED
    • STREAM_ANNOTATION_TYPE_ACTIVE_ZONE
    • STREAM_ANNOTATION_TYPE_CROSSING_LINE
  • normalizedVertices: Each vertex is specified by x, y coordinate values. Coordinates are normalized float values [0,1] relative to the original image ; 0.0 is X_MIN or Y_MIN, 1.0 is X_MAX or Y_MAX.

HTTP method and URL:

POST https://visionai.googleapis.com/v1/projects/PROJECT/locations/LOCATION_ID/applications/APPLICATION_ID:addStreamInput

Request JSON body:

{
  "applicationStreamInputs": [
    {
      "streamWithAnnotation": {
        "stream": "projects/PROJECT/locations/LOCATION_ID/clusters/application-cluster-0/streams/STREAM_ID",
        "nodeAnnotations": [
          {
            "node": "NODE_NAME",
            "annotations": [
              {
                "id": "ANNOTATION_ID",
                "displayName": "ANNOTATION_DISPLAYNAME",
                "sourceStream": "projects/PROJECT/locations/LOCATION_ID/clusters/application-cluster-0/streams/STREAM_ID",
                "type": ANNOTATION_TYPE,
                "activeZone": {
                  "normalizedVertices": {
                    "x": 0.07434944,
                    "y": 0.18061674
                  },
                  "normalizedVertices": {
                    "x": 0.64684016,
                    "y": 0.16079295
                  },
                  "normalizedVertices": {
                    "x": 0.6047088,
                    "y": 0.92070484
                  },
                  "normalizedVertices": {
                    "x": 0.1251549,
                    "y":