Set up a project and a development environment

This guide describes how to set up a Google Cloud project to start using Vertex AI Vision.

Set up your project

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. Install the Google Cloud CLI.
  3. To initialize the gcloud CLI, run the following command:

    gcloud init
  4. Create or select a Google Cloud project.

    • Create a Google Cloud project:

      gcloud projects create PROJECT_ID

      Replace PROJECT_ID with a name for the Google Cloud project you are creating.

    • Select the Google Cloud project that you created:

      gcloud config set project PROJECT_ID

      Replace PROJECT_ID with your Google Cloud project name.

  5. Make sure that billing is enabled for your Google Cloud project.

  6. Enable the Vertex AI Vision API:

    gcloud services enable visionai.googleapis.com
  7. Set up authentication:

    1. Create the service account:

      gcloud iam service-accounts create SERVICE_ACCOUNT_NAME

      Replace SERVICE_ACCOUNT_NAME with a name for the service account.

    2. Grant the roles/visionai.editor IAM role to the service account:

      gcloud projects add-iam-policy-binding PROJECT_ID --member="serviceAccount:SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com" --role=roles/visionai.editor

      Replace the following:

      • SERVICE_ACCOUNT_NAME: the name of the service account
      • PROJECT_ID: the project ID where you created the service account
    3. Generate the key file:

      gcloud iam service-accounts keys create FILE_NAME.json --iam-account=SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com

      Replace the following:

      • FILE_NAME: a name for the key file
      • SERVICE_ACCOUNT_NAME: the name of the service account
      • PROJECT_ID: the project ID where you created the service account
  8. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the path of the JSON file that contains your credentials. This variable applies only to your current shell session, so if you open a new session, set the variable again.

  9. Install the Google Cloud CLI.
  10. To initialize the gcloud CLI, run the following command:

    gcloud init
  11. Create or select a Google Cloud project.

    • Create a Google Cloud project:

      gcloud projects create PROJECT_ID

      Replace PROJECT_ID with a name for the Google Cloud project you are creating.

    • Select the Google Cloud project that you created:

      gcloud config set project PROJECT_ID

      Replace PROJECT_ID with your Google Cloud project name.

  12. Make sure that billing is enabled for your Google Cloud project.

  13. Enable the Vertex AI Vision API:

    gcloud services enable visionai.googleapis.com
  14. Set up authentication:

    1. Create the service account:

      gcloud iam service-accounts create SERVICE_ACCOUNT_NAME

      Replace SERVICE_ACCOUNT_NAME with a name for the service account.

    2. Grant the roles/visionai.editor IAM role to the service account:

      gcloud projects add-iam-policy-binding PROJECT_ID --member="serviceAccount:SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com" --role=roles/visionai.editor

      Replace the following:

      • SERVICE_ACCOUNT_NAME: the name of the service account
      • PROJECT_ID: the project ID where you created the service account
    3. Generate the key file:

      gcloud iam service-accounts keys create FILE_NAME.json --iam-account=SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com

      Replace the following:

      • FILE_NAME: a name for the key file
      • SERVICE_ACCOUNT_NAME: the name of the service account
      • PROJECT_ID: the project ID where you created the service account
  15. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the path of the JSON file that contains your credentials. This variable applies only to your current shell session, so if you open a new session, set the variable again.


Certain tasks require you to use additional Google Cloud products in addition to Vertex AI Vision. You might need to perform additional setup tasks to use other Google Cloud products.

Vertex AI Vision SDK

The Vertex AI Vision Software Development Kit (SDK) contains tools and libraries for you to develop programs and custom workflows with Vertex AI Vision.

These tools refer to a set of binary source files that help your productivity when you use or develop solutions using Vertex AI Vision. You can also add these binary source files into your scripting to help manage larger scale deployments. The command line interface (CLI) vaictl is an example in this category.

Libraries refers to a set of programming APIs that you can use to programmatically manage, control, and perform I/O of different forms with Vertex AI Vision. The C++ programming API is an example in this category.

The code for both tools and libraries are open source and we welcome developers to build them directly. For tools, we also offer pre-built binary files on specific platforms that you can download for direct use. We also offer Docker images for cases when your platform is not directly supported.

Prerequisites

Consider these prerequisites before you use the Vertex AI Vision SDK.

Supported platforms

We currently only directly support x86 machines running a Debian-based Linux distribution. We also offer a Docker image with tools already built and installed if you use a different platform.

Additional software requirements

Most of the third party software dependencies the Vertex AI Vision SDK requires are automatically managed when you install the pre-built binaries. However, to use certain aspects of the SDK features and workflows you must install additional dependencies. This section lists these exceptions and how to download and install them.

Python SDK

The Python pip package installs all of its dependencies automatically. However, your basic underlying Python installation must meet the following conditions:

  • Python >= 3.8.

Build from source dependencies

Most users can use the pre-built SDK binaries for their workflow. If you want to develop and build the SDK from source, you must also make sure your system meets the following requirements.

  • Install Bazel. For installation instructions, see the Bazel documentation.
  • On Ubuntu 20.04, you also need several system dependencies. You can install them with the following command:

    apt-get install -y --no-install-recommends \
        autoconf \
        automake \
        build-essential \
        ca-certificates \
        flex \
        bison \
        python3 \
        nasm \
        libjpeg-dev
    

Get pre-built binaries

The vaictl tool is the ready-made binary tool that can be used to control Vertex AI Vision, as well as to send and receive data that it processes.

This section shows ways for you to download and install this tool.

Install the Debian package

You have two options for using the vaictl command-line tool, which you need to work with I/O (stream data):

  • Install the command-line tool locally (OS: Debian GNU/Linux, CPU architecture: x86_64) or
  • Run the commands in a Docker image that has all dependencies installed.

Use the following steps to get the vaictl command-line tool:

Download package

For direct installations, we currently only support Debian/Ubuntu distributions.

You can also download this Debian package from the Vertex AI Vision SDK GitHub releases page.

  1. (Optional) Remove prior versions of vaictl.

    Before you can install the vaictl command-line tool, you must delete any prior versions of the tool on your machine:

    sudo apt-get remove visionai
  2. Download the required package. You can download the package from the GitHub releases page, or use the following command:
    wget https://github.com/google/visionai/releases/download/v0.0.5/visionai_0.0-5_amd64.deb
  3. After downloading the package, run the following command in the directory you downloaded the file:
    sudo apt install ./visionai_0.0-5_amd64.deb
  4. Verify installation:
    vaictl --help

Get Docker

You can get a Docker image that has the Vertex AI Vision SDK and all its dependencies already pre-installed. This Docker image is available at gcr.io/visionai-public-images/vaictl.

  1. Download the image from Container Registry:
    docker pull gcr.io/visionai-public-images/vaictl
  2. Run an interactive container terminal.
    docker run -it --rm gcr.io/visionai-public-images/vaictl /bin/bash
  3. Verify functionality:
    vaictl --help

Get the source code

The Vertex AI Vision SDK is open-source and publicly available on GitHub.

While the SDK depends on the service API definitions, this dependency is already automatically managed by Bazel and you don't need to explicitly acquire it. However, if you need direct access to the service APIs, you can get them on the googleapis GitHub repository.

The Python programming SDK

Vertex AI Vision also supports a Python SDK. To program with this SDK, just make sure that you have met the basic Python SDK dependencies before you install the Python SDK.

For SDK reference information, see the Python SDK reference.

For example codes that use the Python SDK, see the Face blur with the Python SDK tutorial, or see some examples in the source distribution in the visionai/python/examples/ directory.

Get the Python SDK package

The Vertex AI Vision SDK also contains a Python library. Download and install the pre-built version of the Python SDK with the following instructions.

  1. Download the package.

    You can download the Python SDK package from the Vertex AI Vision SDK GitHub releases page, or you can run the command:

    wget https://github.com/google/visionai/releases/download/v0.0.5/visionai-0.0.5-py3-none-any.whl
    
  2. Optional. Create and activate a new virtual environment:

    python3 -m venv vaivenv
    source vaivenv/bin/activate
    
  3. Install the package:

    pip3 install visionai-0.0.5-py3-none-any.whl
    
  4. Optional. Confirm that installation worked:

    python3
    
    import visionai
    
  5. Optional. Deactivate your virtual environment:

    deactivate
    

The C++ programming SDK

C++ is the first programming SDK we support. The C++ public SDK is located in visionai/public/streams.h. For reference information, see the reference documentation.

What's next