【发布时间】:2020-06-30 02:29:05
【问题描述】:
现在我可以使用 autoML node.js 客户端库在 google-cloud-automl 上训练模型。
问:如何在完成模型训练后以编程方式获取模型 ID?
目标:我将使用该 id 来部署没有 Web 界面的模型。
试过:起初,我以为是在训练模型时的响应(operation.name)。但是 operation.name 显示 projects/${projectId}/locations/${location}/operations/${operationId},不包括模型 ID。所以我不知道如何以编程方式获取模型 ID。
任何建议将不胜感激。
训练代码来自:https://cloud.google.com/vision/automl/docs/train-edge
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
// const projectId = 'YOUR_PROJECT_ID';
// const location = 'us-central1';
// const dataset_id = 'YOUR_DATASET_ID';
// const displayName = 'YOUR_DISPLAY_NAME';
// Imports the Google Cloud AutoML library
const {AutoMlClient} = require(`@google-cloud/automl`).v1;
// Instantiates a client
const client = new AutoMlClient();
async function createModel() {
// Construct request
const request = {
parent: client.locationPath(projectId, location),
model: {
displayName: displayName,
datasetId: datasetId,
imageClassificationModelMetadata: {
trainBudgetMilliNodeHours: 24000,
},
},
};
// Don't wait for the LRO
const [operation] = await client.createModel(request);
console.log(`Training started... ${operation}`);
console.log(`Training operation name: ${operation.name}`);
}
createModel();
部署代码来自:https://cloud.google.com/vision/automl/docs/deploy (需要型号ID)
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
// const projectId = 'YOUR_PROJECT_ID';
// const location = 'us-central1';
// const modelId = 'YOUR_MODEL_ID';
// Imports the Google Cloud AutoML library
const {AutoMlClient} = require(`@google-cloud/automl`).v1;
// Instantiates a client
const client = new AutoMlClient();
async function deployModel() {
// Construct request
const request = {
name: client.modelPath(projectId, location, modelId),
};
const [operation] = await client.deployModel(request);
// Wait for operation to complete.
const [response] = await operation.promise();
console.log(`Model deployment finished. ${response}`);
}
deployModel();
【问题讨论】:
标签: javascript node.js google-cloud-platform google-cloud-automl