Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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');
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');