| 69 | } |
| 70 | |
| 71 | async 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 | |
| 92 | async function detectLabelsGCS(bucketName, fileName) { |
| 93 | // [START vision_label_detection_gcs] |