How to use the @google-cloud/automl.v1beta1 function in @google-cloud/automl

To help you get started, we’ve selected a few @google-cloud/automl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / nodejs-automl / samples / vision / object-detection / deploy-model.v1beta1.js View on Github external
projectId = 'YOUR_PROJECT_ID',
  computeRegion = 'YOUR_REGION_NAME',
  modelId = 'MODEL_ID'
) {
  // [START automl_vision_object_detection_deploy_model]

  /**
   * Demonstrates using the AutoML client to deploy model.
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const projectId = '[PROJECT_ID]' e.g., "my-gcloud-project";
  // const computeRegion = '[REGION_NAME]' e.g., "us-central1";
  // const modelId = '[MODEL_ID]' e.g., "TEN5200971474357190656";

  //Imports the Google Cloud Automl library
  const {AutoMlClient} = require('@google-cloud/automl').v1beta1;

  // Instantiates a client
  const automlClient = new AutoMlClient();
  async function deployModel() {
    // Get the full path of the model.
    const modelFullId = automlClient.modelPath(
      projectId,
      computeRegion,
      modelId
    );

    // Deploy a model with the deploy model request.
    const [operation] = await automlClient.deployModel({name: modelFullId});

    const [response] = await operation.promise();
    console.log(`Deployment Details:`);
github googleapis / nodejs-automl / samples / vision / object-detection / get-operation-status.v1beta1.js View on Github external
function main(operationFullId = 'OPERATION_FULL_ID') {
  // [START automl_vision_object_detection_get_operation_status]
  /**
   * Demonstrates using the AutoML client to get operation status.
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const operationFullId = '[OPERATION_FULL_ID]'
  // eg., "projects//locations/us-central1/operations/",
  // `Full name of an operation`;

  //Imports the Google Cloud Automl library
  const {AutoMlClient} = require('@google-cloud/automl').v1beta1;

  // Instantiates a client
  const automlClient = new AutoMlClient();
  async function getOperationStatus() {
    // Get the latest state of a long-running operation.
    const [response] = await automlClient.operationsClient.getOperation({
      name: operationFullId,
    });
    console.log(`Operation details:`);
    console.log(`\tName: ${response.name}`);
    console.log(`\tMetadata:`);
    console.log(`\t\tType Url: ${response.metadata.typeUrl}`);
    console.log(`\tDone: ${response.done}`);

    if (response.response) {
      console.log(`\tResponse:`);
github googleapis / nodejs-automl / samples / vision / object-detection / import-data.v1beta1.js View on Github external
computeRegion = 'YOUR_REGION_NAME',
  datasetId = 'YOUR_DATASET_ID',
  gcsPath = 'GCS_PATH'
) {
  // [START automl_vision_object_detection_import_data]
  /**
   * Demonstrates using the AutoML client to import labeled items.
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const projectId = '[PROJECT_ID]' e.g., "my-gcloud-project";
  // const computeRegion = '[REGION_NAME]' e.g., "us-central1";
  // const datasetId = '[DATASET_ID]' e.g.,"IOD34216801856389120";
  // const gcsPath = '[GCS_PATH]' e.g., "gs:///",
  // `.csv paths in AutoML Vision Object Detection CSV format`;
  //Imports the Google Cloud Automl library
  const {AutoMlClient} = require('@google-cloud/automl').v1beta1;

  // Instantiates a client
  const automlClient = new AutoMlClient();
  async function importData() {
    // Get the full path of the dataset.
    const datasetFullId = automlClient.datasetPath(
      projectId,
      computeRegion,
      datasetId
    );

    // Get the multiple Google Cloud Storage URIs.
    const inputUris = gcsPath.split(`,`);
    const inputConfig = {
      gcsSource: {
        inputUris: inputUris,
github googleapis / nodejs-automl / samples / vision / object-detection / get-model-evaluations.v1beta1.js View on Github external
modelId = 'MODEL_ID',
  modelEvaluationId = 'MODEL_EVALUATION_ID'
) {
  // [START automl_vision_object_detection_get_model_evaluation]
  /**
   * Demonstrates using the AutoML client to get model evaluations.
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const projectId = '[PROJECT_ID]' e.g., "my-gcloud-project";
  // const computeRegion = '[REGION_NAME]' e.g., "us-central1";
  // const modelId = '[MODEL_ID]' e.g., "IOD2122286140026257408";
  // const modelEvaluationId = '[MODEL_EVALUATION_ID]'
  // e.g., "3806191078210741236";

  //Imports the Google Cloud Automl library
  const {AutoMlClient} = require('@google-cloud/automl').v1beta1;

  // Instantiates a client
  const automlClient = new AutoMlClient();

  const math = require(`mathjs`);

  async function getModelEvaluations() {
    // Get the full path of the model evaluation.
    const modelEvaluationFullId = automlClient.modelEvaluationPath(
      projectId,
      computeRegion,
      modelId,
      modelEvaluationId
    );

    // Get complete detail of the model evaluation.
github googleapis / nodejs-automl / samples / language / entity-extraction / create-model.v1beta1.js View on Github external
async function main(
  projectId = 'YOUR_PROJECT_ID',
  computeRegion = 'YOUR_REGION_NAME',
  datasetId = 'YOUR_DATASET_NAME',
  modelName = 'YOUR_MODEL_NAME'
) {
  // [START automl_language_entity_create_model]
  const automl = require('@google-cloud/automl');
  const client = new automl.v1beta1.AutoMlClient();

  /**
   * Demonstrates using the AutoML client to create a model.
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const projectId = '[PROJECT_ID]' e.g., "my-gcloud-project";
  // const computeRegion = '[REGION_NAME]' e.g., "us-central1";
  // const datasetId = '[DATASET_ID]' e.g., "TEN8051890775971069952";
  // const modelName = '[MODEL_NAME]' e.g., "myModel";

  // A resource that represents Google Cloud Platform location.
  const projectLocation = client.locationPath(projectId, computeRegion);

  // Set datasetId, model name and model metadata for the dataset.
  const myModel = {
    displayName: modelName,
github googleapis / nodejs-automl / samples / language / entity-extraction / list-datasets.v1beta1.js View on Github external
async function main(
  projectId = 'YOUR_PROJECT_ID',
  computeRegion = 'YOUR_REGION_NAME',
  filter = 'YOUR_FILTER_EXPRESSION'
) {
  // [START automl_language_entity_list_datasets]
  const automl = require('@google-cloud/automl');
  const util = require('util');
  const client = new automl.v1beta1.AutoMlClient();

  /**
   * Demonstrates using the AutoML client to list all datasets.
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const projectId = '[PROJECT_ID]' e.g., "my-gcloud-project";
  // const computeRegion = '[REGION_NAME]' e.g., "us-central1";
  // const filter_ = '[FILTER_EXPRESSIONS]'
  // e.g., "textExtractionDatasetMetadata:*";

  // A resource that represents Google Cloud Platform location.
  const projectLocation = client.locationPath(projectId, computeRegion);

  // List all the datasets available in the region by applying filter.
  client
    .listDatasets({parent: projectLocation, filter: filter})
github googleapis / nodejs-automl / samples / vision / object-detection / display-evaluation.v1beta1.js View on Github external
filter = 'FILTER_EXPRESSION'
) {
  // [START automl_vision_object_detection_display_evaluation]
  /**
   * Demonstrates using the AutoML client to display model evaluation.
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const projectId = '[PROJECT_ID]' e.g., "my-gcloud-project";
  // const computeRegion = '[REGION_NAME]' e.g., "us-central1";
  // const modelId = '[MODEL_ID]' e.g., "IOD2122286140026257408";
  // const filter = '[FILTER_EXPRESSIONS]'
  // e.g., "imageObjectDetectionModelMetadata:*";

  const math = require(`mathjs`);
  //Imports the Google Cloud Automl library
  const {AutoMlClient} = require('@google-cloud/automl').v1beta1;

  // Instantiates a client
  const automlClient = new AutoMlClient();

  // Get the full path of the model.
  const modelFullId = automlClient.modelPath(projectId, computeRegion, modelId);

  // List all the model evaluations in the model by applying filter.
  automlClient
    .listModelEvaluations({parent: modelFullId, filter: filter})
    .then(respond => {
      const response = respond[0];
      // Iterate through the results.
      let modelEvaluationId = ``;
      for (const element of response) {
        // There is evaluation for each class in a model and for overall model.
github googleapis / nodejs-automl / samples / vision / object-detection / get-model.v1beta1.js View on Github external
function main(
  projectId = 'YOUR_PROJECT_ID',
  computeRegion = 'YOUR_REGION_NAME',
  modelId = 'MODEL_ID'
) {
  // [START automl_vision_object_detection_get_model]
  /**
   * Demonstrates using the AutoML client to get model details.
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const projectId = '[PROJECT_ID]' e.g., "my-gcloud-project";
  // const computeRegion = '[REGION_NAME]' e.g., "us-central1";
  // const modelId = '[MODEL_ID]' e.g., "IOD1187015161160925184";

  //Imports the Google Cloud Automl library
  const {AutoMlClient} = require('@google-cloud/automl').v1beta1;

  // Instantiates a client
  const automlClient = new AutoMlClient();

  async function getModel() {
    // Get the full path of the model.
    const modelFullId = automlClient.modelPath(
      projectId,
      computeRegion,
      modelId
    );

    // Get complete detail of the model.
    const [response] = await automlClient.getModel({name: modelFullId});

    // Display the model information.
github googleapis / nodejs-automl / samples / vision / object-detection / create-dataset.v1beta1.js View on Github external
function main(
  projectId = 'YOUR_PROJECT_ID',
  computeRegion = 'YOUR_REGION_NAME',
  datasetName = 'YOUR_DATASET_NAME'
) {
  // [START automl_vision_object_detection_create_dataset]
  /**
   * Demonstrates using the AutoML client to create a dataset.
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const projectId = '[PROJECT_ID]' e.g., "my-gcloud-project";
  // const computeRegion = '[REGION_NAME]' e.g., "us-central1";
  // const datasetName = '[DATASET_NAME]' e.g., "myDataset";

  //Imports the Google Cloud Automl library
  const {AutoMlClient} = require('@google-cloud/automl').v1beta1;

  // Instantiates a client
  const automlClient = new AutoMlClient();
  const util = require(`util`);

  async function createDataset() {
    // A resource that represents Google Cloud Platform location.
    const projectLocation = automlClient.locationPath(projectId, computeRegion);

    // Set dataset name and metadata.
    const myDataset = {
      displayName: datasetName,
      imageObjectDetectionDatasetMetadata: {},
    };

    // Create a dataset with the dataset metadata in the region.
github googleapis / nodejs-automl / samples / language / sentiment-analysis / delete-model.v1beta1.js View on Github external
async function main(
  projectId = 'YOUR_PROJECT_ID',
  computeRegion = 'YOUR_REGION_NAME',
  modelId = 'YOUR_MODEL_ID'
) {
  // [START automl_language_sentiment_delete_model]
  const automl = require('@google-cloud/automl');
  const client = new automl.v1beta1.AutoMlClient();

  /**
   * Demonstrates using the AutoML client to delete a model.
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const projectId = '[PROJECT_ID]' e.g., "my-gcloud-project";
  // const computeRegion = '[REGION_NAME]' e.g., "us-central1";
  // const modelId = '[MODEL_ID]' e.g., "TST5200971474357190656";

  // Get the full path of the model.
  const modelFullId = client.modelPath(projectId, computeRegion, modelId);

  // Delete a model.
  client
    .deleteModel({name: modelFullId})
    .then(responses => {