11[ // ] : # " This README.md file is auto-generated, all changes to this file will be lost. "
2- [ // ] : # " To regenerate it, use `npm run generate-scaffolding `. "
2+ [ // ] : # " To regenerate it, use `python -m synthtool `. "
33<img src =" https://avatars2.githubusercontent.com/u/2810941?v=3&s=96 " alt =" Google Cloud Platform logo " title =" Google Cloud Platform " align =" right " height =" 96 " width =" 96 " />
44
55# [ Cloud AutoML: Node.js Client] ( https://github.com/googleapis/nodejs-automl )
66
7- [ ![ release level] ( https://img.shields.io/badge/release%20level-alpha-orange .svg?style&#x 3D ; flat )] ( https://cloud.google.com/terms/launch-stages )
7+ [ ![ release level] ( https://img.shields.io/badge/release%20level-beta-yellow .svg?style= flat )] ( https://cloud.google.com/terms/launch-stages )
88[ ![ npm version] ( https://img.shields.io/npm/v/@google-cloud/automl.svg )] ( https://www.npmjs.org/package/@google-cloud/automl )
99[ ![ codecov] ( https://img.shields.io/codecov/c/github/googleapis/nodejs-automl/master.svg?style=flat )] ( https://codecov.io/gh/googleapis/nodejs-automl )
1010
11- Train high quality custom machine learning models with minimum effort and machine learning expertise
1211
1312
14- * [ Using the client library] ( #using-the-client-library )
13+
14+ Cloud AutoML API client for Node.js
15+
16+
17+ * [ Cloud AutoML Node.js Client API Reference] [ client-docs ]
18+ * [ Cloud AutoML Documentation] [ product-docs ]
19+ * [ github.com/googleapis/nodejs-automl] ( https://github.com/googleapis/nodejs-automl )
20+
21+ Read more about the client libraries for Cloud APIs, including the older
22+ Google APIs Client Libraries, in [ Client Libraries Explained] [ explained ] .
23+
24+ [ explained ] : https://cloud.google.com/apis/docs/client-libraries-explained
25+
26+ ** Table of contents:**
27+
28+
29+ * [ Quickstart] ( #quickstart )
30+ * [ Before you begin] ( #before-you-begin )
31+ * [ Installing the client library] ( #installing-the-client-library )
32+ * [ Using the client library] ( #using-the-client-library )
33+ * [ Samples] ( #samples )
1534* [ Versioning] ( #versioning )
1635* [ Contributing] ( #contributing )
1736* [ License] ( #license )
1837
19- ## Using the client library
38+ ## Quickstart
2039
21- 1 . [ Select or create a Cloud Platform project ] [ projects ] .
40+ ### Before you begin
2241
42+ 1 . [ Select or create a Cloud Platform project] [ projects ] .
23431 . [ Enable billing for your project] [ billing ] .
24-
25441 . [ Enable the Cloud AutoML API] [ enable_api ] .
26-
27451 . [ Set up authentication with a service account] [ auth ] so you can access the
2846 API from your local workstation.
2947
30- 1 . Install the client library:
48+ ### Installing the client library
49+
50+ ``` bash
51+ npm install @google-cloud/automl
52+ ```
3153
32- npm install --save @google-cloud/automl
3354
34- 1 . Try an example:
55+ ### Using the client library
3556
3657``` javascript
37- // TBD
58+ const automl = require (' @google-cloud/automl' );
59+ const fs = require (' fs' );
60+
61+ // Create client for prediction service.
62+ const client = new automl.PredictionServiceClient ();
63+
64+ /**
65+ * TODO(developer): Uncomment the following line before running the sample.
66+ */
67+ // const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`;
68+ // const computeRegion = `region-name, e.g. "us-central1"`;
69+ // const modelId = `id of the model, e.g. “ICN723541179344731436”`;
70+ // const filePath = `local text file path of content to be classified, e.g. "./resources/flower.png"`;
71+ // const scoreThreshold = `value between 0.0 and 1.0, e.g. "0.5"`;
72+
73+ // Get the full path of the model.
74+ const modelFullId = client .modelPath (projectId, computeRegion, modelId);
75+
76+ // Read the file content for prediction.
77+ const content = fs .readFileSync (filePath, ' base64' );
78+
79+ const params = {};
80+
81+ if (scoreThreshold) {
82+ params .score_threshold = scoreThreshold;
83+ }
84+
85+ // Set the payload by giving the content and type of the file.
86+ const payload = {};
87+ payload .image = {imageBytes: content};
88+
89+ // params is additional domain-specific parameters.
90+ // currently there is no additional parameters supported.
91+ const [response ] = await client .predict ({
92+ name: modelFullId,
93+ payload: payload,
94+ params: params,
95+ });
96+ console .log (` Prediction results:` );
97+ response .payload .forEach (result => {
98+ console .log (` Predicted class name: ${ result .displayName } ` );
99+ console .log (` Predicted class score: ${ result .classification .score } ` );
100+ });
101+
38102```
39103
40104
41- The [ AutoML Node.js Client API Reference] [ client-docs ] documentation
105+
106+ ## Samples
107+
108+ Samples are in the [ ` samples/ ` ] ( https://github.com/googleapis/nodejs-automl/tree/master/samples ) directory. The samples' ` README.md `
109+ has instructions for running the samples.
110+
111+ | Sample | Source Code | Try it |
112+ | --------------------------- | --------------------------------- | ------ |
113+ | Quickstart | [ source code] ( https://github.com/googleapis/nodejs-automl/blob/master/samples/quickstart.js ) | [ ![ Open in Cloud Shell] [ shell_img ]] ( https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-automl&page=editor&open_in_editor=samples/quickstart.js,samples/README.md ) |
114+
115+
116+
117+ The [ Cloud AutoML Node.js Client API Reference] [ client-docs ] documentation
42118also contains samples.
43119
44120## Versioning
45121
46122This library follows [ Semantic Versioning] ( http://semver.org/ ) .
47123
48- This library is considered to be in ** alpha** . This means it is still a
49- work-in-progress and under active development. Any release is subject to
50- backwards-incompatible changes at any time.
124+
125+
126+ This library is considered to be in ** beta** . This means it is expected to be
127+ mostly stable while we work toward a general availability release; however,
128+ complete stability is not guaranteed. We will address issues and requests
129+ against beta libraries with a high priority.
130+
131+
132+
51133
52134More Information: [ Google Cloud Platform Launch Stages] [ launch_stages ]
53135
@@ -63,21 +145,10 @@ Apache Version 2.0
63145
64146See [ LICENSE] ( https://github.com/googleapis/nodejs-automl/blob/master/LICENSE )
65147
66- ## What's Next
67-
68- * [ AutoML Documentation] [ product-docs ]
69- * [ AutoML Node.js Client API Reference] [ client-docs ]
70- * [ github.com/googleapis/nodejs-automl] ( https://github.com/googleapis/nodejs-automl )
71-
72- Read more about the client libraries for Cloud APIs, including the older
73- Google APIs Client Libraries, in [ Client Libraries Explained] [ explained ] .
74-
75- [ explained ] : https://cloud.google.com/apis/docs/client-libraries-explained
76-
77148[ client-docs ] : https://cloud.google.com/nodejs/docs/reference/automl/latest/
78149[ product-docs ] : https://cloud.google.com/automl/docs/
79150[ shell_img ] : https://gstatic.com/cloudssh/images/open-btn.png
80151[ projects ] : https://console.cloud.google.com/project
81152[ billing ] : https://support.google.com/cloud/answer/6293499#enable-billing
82- [ enable_api ] : https://console.cloud.google.com/flows/enableapi?apiid=automl
83- [ auth ] : https://cloud.google.com/docs/authentication/getting-started
153+ [ enable_api ] : https://console.cloud.google.com/flows/enableapi?apiid=automl.googleapis.com
154+ [ auth ] : https://cloud.google.com/docs/authentication/getting-started
0 commit comments