The ML.ANNOTATE_IMAGE function

This document describes the ML.ANNOTATE_IMAGE function, which lets you annotate images that are stored in BigQuery object tables by using the Cloud Vision API.

Syntax

ML.ANNOTATE_IMAGE(
  MODEL `project_id.dataset.model_name`,
  TABLE `project_id.dataset.object_table,
  STRUCT( ['feature_name_1', 'feature_name_2', ...] AS vision_features )
)

Arguments

ML.ANNOTATE_IMAGE takes the following arguments:

Output

ML.ANNOTATE_IMAGE returns the input table plus the following columns:

  • ml_annotate_image_result: a JSON value that contains the image annotation result from the Vision API.
  • ml_annotate_image_status: a STRING value that contains the API response status for the corresponding row. This value is empty if the operation was successful.

Quotas

See Cloud AI service functions quotas and limits.

Examples

Example 1

The following example performs label detection on the object table mytable in mydataset:

# Create model
CREATE OR REPLACE MODEL
`myproject.mydataset.myvisionmodel`
REMOTE WITH CONNECTION `myproject.myregion.myconnection`
OPTIONS (remote_service_type = 'cloud_ai_vision_v1');
# Annotate image
SELECT *
FROM ML.ANNOTATE_IMAGE(
  MODEL `mydataset.myvisionmodel`,
  TABLE `mydataset.mytable`,
  STRUCT(['label_detection'] AS vision_features)
);

The result is similar to the following:

ml_annotate_image_result ml_