javascript - 从 Node.js 客户端库返回的 GCP AutoML 数据集 ID 与实际数据集 ID 不匹配
问题描述
以前,我使用 Node.js 客户端库创建数据集并在 GCP automl 上训练模型,一切正常。但是,现在我面临“错误:5 NOT_FOUND:数据集不存在或无法与 AutoMl 一起使用”。
之后,我意识到从创建数据集请求返回的数据集 id 与实际的数据集 id不匹配(与 Web 界面相比)。所以我不能以编程方式与数据集交互。
我的目标是使用该数据集 id 上传图像并训练模型。我缺少任何更新吗?任何建议将不胜感激。
以下是来自https://cloud.google.com/vision/automl/docs/create-datasets的使用 GCP Automl 创建数据集的参考代码。
* 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();
解决方案
现在我使用了来自https://github.com/googleapis/nodejs-automl/blob/master/samples/vision_object_detection_create_dataset.js的示例代码,它运行良好。是的,我应该在一开始就使用它。但我们总能找到行不通的方法,在工作之前,对吗?
快乐编码,创造一个更美好的世界;)。
推荐阅读
- django - 如何将用户 ID 传递给 Django 中的自定义密码哈希?
- r - 如何编写函数将数据转换为更高维度
- firebase - 如何修复 google play 服务版本不兼容的错误
- docker - Docker for Windows 的端口问题
- python - 如何逐步抓取谷歌结果?
- javascript - 我正在尝试主动跟踪用户坐标并在 js 中显示一行
- python - 在 Python 中使用元数据格式化数据库的列
- google-bigquery - 通过服务帐户访问 BigQuery 失败,在美国位置找不到数据集
- node.js - Jenkins 从机与 nodejs 运行 npm publish
- reactjs - 在中间件中获取数据时的无限循环