| 40 | const content = fs.readFileSync(filePath); |
| 41 | |
| 42 | async function predict() { |
| 43 | // Construct request |
| 44 | // params is additional domain-specific parameters. |
| 45 | // score_threshold is used to filter the result |
| 46 | const request = { |
| 47 | name: client.modelPath(projectId, location, modelId), |
| 48 | payload: { |
| 49 | image: { |
| 50 | imageBytes: content, |
| 51 | }, |
| 52 | }, |
| 53 | }; |
| 54 | |
| 55 | const [response] = await client.predict(request); |
| 56 | |
| 57 | for (const annotationPayload of response.payload) { |
| 58 | console.log(`Predicted class name: ${annotationPayload.displayName}`); |
| 59 | console.log( |
| 60 | `Predicted class score: ${annotationPayload.classification.score}` |
| 61 | ); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | predict(); |
| 66 | // [END automl_vision_classification_predict] |