How to use the @google-cloud/automl.v1beta1.PredictionServiceClient 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 / automlVisionPredict.js View on Github external
async function automlVisionPredict() {
    const automl = require('@google-cloud/automl').v1beta1;
    const fs = require('fs');

    // Create client for prediction service.
    const client = new automl.PredictionServiceClient();

    /**
     * TODO(developer): Uncomment the following line before running the sample.
     */
    // const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`;
    // const computeRegion = `region-name, e.g. "us-central1"`;
    // const modelId = `id of the model, e.g. “ICN12345”`;
    // const filePath = `local text file path of content to be classified, e.g. "./resources/test.txt"`;
    // const scoreThreshold = `value between 0.0 and 1.0, e.g. "0.5"`;

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

    // Read the file content for prediction.
    const content = fs.readFileSync(filePath, 'base64');
github googleapis / nodejs-vision / samples / automl / automlVisionPredict.js View on Github external
async function predict(
  projectId,
  computeRegion,
  modelId,
  filePath,
  scoreThreshold
) {
  // [START automl_vision_predict]
  const automl = require('@google-cloud/automl').v1beta1;
  const fs = require('fs');

  // Create client for prediction service.
  const client = new automl.PredictionServiceClient();

  /**
   * TODO(developer): Uncomment the following line before running the sample.
   */
  // const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`;
  // const computeRegion = `region-name, e.g. "us-central1"`;
  // const modelId = `id of the model, e.g. “ICN12345”`;
  // const filePath = `local text file path of content to be classified, e.g. "./resources/test.txt"`;
  // const scoreThreshold = `value between 0.0 and 1.0, e.g. "0.5"';

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

  // Read the file content for prediction.
  const content = fs.readFileSync(filePath, 'base64');