以下操作需要几秒钟。我知道这不是概念性的问题,但我还是从GCP的问题中交叉发布,以防有人遇到相同的情况。
const { PredictionServiceClient } = require('@google-cloud/automl');const predictionServiceClient = new PredictionServiceClient({ apiEndpoint });const prediction = await predictionServiceClient.predict({ name: modelFullId, params, payload,});
这个API在冷启动时需要接近10秒,热启动时需要5秒。除了导出模型并自己运行外,有没有其他方法可以加快速度?
回答:
是的,你可以导出模型并使用tensorFlowJS。
https://cloud.google.com/vision/automl/docs/edge-quickstart
https://github.com/tensorflow/tfjs/tree/master/tfjs-automl
-
导出模型并下载
model.json, dict.txt, *.bin
文件到本地。 -
将模型加载到tensorFlowJS中并使用它。