MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / detectLabels

Function detectLabels

vision/detect.js:71–90  ·  view source on GitHub ↗
(fileName)

Source from the content-addressed store, hash-verified

69}
70
71async function detectLabels(fileName) {
72 // [START vision_label_detection]
73 // Imports the Google Cloud client library
74 const vision = require('@google-cloud/vision');
75
76 // Creates a client
77 const client = new vision.ImageAnnotatorClient();
78
79 /**
80 * TODO(developer): Uncomment the following line before running the sample.
81 */
82 // const fileName = 'Local image file, e.g. /path/to/image.png';
83
84 // Performs label detection on the local file
85 const [result] = await client.labelDetection(fileName);
86 const labels = result.labelAnnotations;
87 console.log('Labels:');
88 labels.forEach(label => console.log(label.description));
89 // [END vision_label_detection]
90}
91
92async function detectLabelsGCS(bucketName, fileName) {
93 // [START vision_label_detection_gcs]

Callers 1

detect.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected