Search code examples
javascriptnode.jsgoogle-cloud-platformgoogle-cloud-automl

GCP AutoML dataset id return from Node.js client library is mismatched the actual dataset id


Previously, i have used Node.js client library to create dataset and train the model on GCP automl, and everything works fine. But, now i faced "Error: 5 NOT_FOUND: The Dataset doesn't exist or is inaccessible for use with AutoMl".

After that, i realized that the dataset id return from create dataset request is mismatched the actual dataset id (compared with web interface). So i can not interact with the dataset programmatically.

My goal is to use that dataset id to upload image and train the model. Any update am i missing? Any suggestion will be grateful.

The following is ref code for create dataset with GCP Automl from https://cloud.google.com/vision/automl/docs/create-datasets.

 * TODO(developer): Uncomment these variables before running the sample.
 */
// const projectId = 'YOUR_PROJECT_ID';
// const location = 'us-central1';
// 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 createDataset() {
  // Construct request
  // Specify the classification type
  // Types:
  // MultiLabel: Multiple labels are allowed for one example.
  // MultiClass: At most one label is allowed per example.
  const request = {
    parent: client.locationPath(projectId, location),
    dataset: {
      displayName: displayName,
      imageClassificationDatasetMetadata: {
        classificationType: 'MULTILABEL',
      },
    },
  };

  // Create dataset
  const [operation] = await client.createDataset(request);

  // Wait for operation to complete.
  const [response] = await operation.promise();

  console.log(`Dataset name: ${response.name}`);
  console.log(`
    Dataset id: ${
      response.name
        .split('/')
        [response.name.split('/').length - 1].split('\n')[0]
    }`);
}

createDataset();

Solution

  • Now i used the sample code from https://github.com/googleapis/nodejs-automl/blob/master/samples/vision_object_detection_create_dataset.js, and it works robustly. Yes, i should used it at the beginning. But we all always found the way that won't work, before the work one right?

    Happy coding and create a better world ;).