Now i can use autoML node.js client library to train the model on google-cloud-automl.
Q: How can i programmatically get the model id when finished training the model?.
Goal: I will use that id to deploy the model without web interface.
Tried: At first, i thought it is in the response when training the model (operation.name). But the operation.name showed projects/${projectId}/locations/${location}/operations/${operationId}, which is not include model id. So i have no idea how to programmatically get the model id.
Any suggestion will be grateful.
code for training from : 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();
code for deploy from: https://cloud.google.com/vision/automl/docs/deploy (model id is required)
/**
* 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();