Skip to content
Node.js client for Google Cloud AutoML: Train high quality custom machine learning models with minimum effort and machine learning expertise.
JavaScript Shell Other
Branch: master
Clone or download
yoshi-automation and JustinBeckwith chore: release 1.2.4 (#219)
* updated CHANGELOG.md [ci skip]

* updated package.json [ci skip]

* updated samples/package.json [ci skip]
Latest commit c489ec6 Aug 5, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github chore: move CONTRIBUTING.md to root (#126) Feb 7, 2019
.kokoro build: add Node 12 remove Node 11 (#216) Aug 1, 2019
protos fix: allow calls with no request, add JSON proto Aug 2, 2019
samples chore: release 1.2.4 (#219) Aug 5, 2019
src fix: allow calls with no request, add JSON proto Aug 2, 2019
system-test fix: use credential file to get project id (#111) Jan 2, 2019
test fix: default opts to empty object (#191) Jun 6, 2019
.cloud-repo-tools.json doc: generate README.md from nodejs-repo-tools (#5) Jul 17, 2018
.eslintignore chore: update nyc and eslint configs (#103) Dec 11, 2018
.eslintrc.yml Enable prefer-const in the eslint config (#51) Sep 20, 2018
.gitignore feat: support new AutoML problems; add batchPredict, exportModel methods Apr 3, 2019
.jsdoc.js docs: use the jsdoc-fresh theme (#214) Jul 31, 2019
.nycrc build: ignore proto files in test coverage (#188) May 28, 2019
.prettierignore run the generator Jun 15, 2018
.prettierrc run the generator Jun 15, 2018
.repo-metadata.json fix(docs): move to new client docs URL (#201) Jun 13, 2019
CHANGELOG.md chore: release 1.2.4 (#219) Aug 5, 2019
CODE_OF_CONDUCT.md run the generator Jun 15, 2018
CONTRIBUTING.md docs: update links in contrib guide (#132) Feb 14, 2019
LICENSE chore: update license file (#92) Dec 4, 2018
README.md fix(docs): link to reference docs section on googleapis.dev (#205) Jun 25, 2019
codecov.yaml Update kokoro config (#59) Oct 2, 2018
linkinator.config.json build: use config file for linkinator (#208) Jun 28, 2019
package.json chore: release 1.2.4 (#219) Aug 5, 2019
renovate.json chore: ignore package-lock.json (#27) Aug 7, 2018
synth.metadata fix: allow calls with no request, add JSON proto Aug 2, 2019
synth.py feat: support new AutoML problems; add batchPredict, exportModel methods Apr 3, 2019

README.md

Google Cloud Platform logo

Cloud AutoML: Node.js Client

release level npm version codecov

Cloud AutoML API client for Node.js

Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Table of contents:

Quickstart

Before you begin

  1. Select or create a Cloud Platform project.
  2. Enable billing for your project.
  3. Enable the Cloud AutoML API.
  4. Set up authentication with a service account so you can access the API from your local workstation.

Installing the client library

npm install @google-cloud/automl

Using the client library

  const automl = require('@google-cloud/automl');
  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. “ICN723541179344731436”`;
  // const filePath = `local text file path of content to be classified, e.g. "./resources/flower.png"`;
  // 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');

  const params = {};

  if (scoreThreshold) {
    params.score_threshold = scoreThreshold;
  }

  // Set the payload by giving the content and type of the file.
  const payload = {};
  payload.image = {imageBytes: content};

  // params is additional domain-specific parameters.
  // currently there is no additional parameters supported.
  const [response] = await client.predict({
    name: modelFullId,
    payload: payload,
    params: params,
  });
  console.log(`Prediction results:`);
  response.payload.forEach(result => {
    console.log(`Predicted class name: ${result.displayName}`);
    console.log(`Predicted class score: ${result.classification.score}`);
  });

Samples

Samples are in the samples/ directory. The samples' README.md has instructions for running the samples.

Sample Source Code Try it
Quickstart source code Open in Cloud Shell

The Cloud AutoML Node.js Client API Reference documentation also contains samples.

Versioning

This library follows Semantic Versioning.

This library is considered to be in beta. This means it is expected to be mostly stable while we work toward a general availability release; however, complete stability is not guaranteed. We will address issues and requests against beta libraries with a high priority.

More Information: Google Cloud Platform Launch Stages

Contributing

Contributions welcome! See the Contributing Guide.

License

Apache Version 2.0

See LICENSE

You can’t perform that action at this time.