从云函数调用 auto ml api 时资源 ID 无效
Invalid resource ID when calling auto ml api from cloud function
我正在调用 auto ml api 进行预测,但出现以下错误:
AutoML API Error: { Error: 5 NOT_FOUND: Invalid resource ID
at Object.exports.createStatusError (/srv/node_modules/grpc/src/common.js:91:15)
at Object.onReceiveStatus (/srv/node_modules/grpc/src/client_interceptors.js:1209:28)
at InterceptingListener._callNext (/srv/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (/srv/node_modules/grpc/src/client_interceptors.js:618:8)
at callback (/srv/node_modules/grpc/src/client_interceptors.js:847:24)
code: 5,metadata: Metadata {_internal_repr: { 'grpc-server-stats-bin': [Array] },flags: 0 },details: 'Invalid resource ID' }
我的代码如下:
function callAutoMLAPI(b64img) {
return new Promise((resolve, reject) => {
const payload = {
"image": {
"imageBytes": b64img
}
}
const reqBody = {
name: predictionClient.modelPath(project, region, automl_model),
payload: payload
}
console.log('ReqBody: ',reqBody);
predictionClient.predict(reqBody)
.then(responses => {
console.log('Got a prediction from AutoML API!', JSON.stringify(responses));
resolve(responses);
return null;
})
.catch(err => {
console.log('AutoML API Error: ',err);
reject(err);
});
});
}
我认为这是因为我的位置或 modelId 不正确,但我不知道在哪里可以找到我的模型位置和我的 modelId
如前所述here
"The model name has the format projects/{project-id}/locations/us-central1/models/{model-id}; the model ID is the element that appears after models/ in the "响应的名称"值。"
表示是模型页下的ID
我正在调用 auto ml api 进行预测,但出现以下错误:
AutoML API Error: { Error: 5 NOT_FOUND: Invalid resource ID
at Object.exports.createStatusError (/srv/node_modules/grpc/src/common.js:91:15)
at Object.onReceiveStatus (/srv/node_modules/grpc/src/client_interceptors.js:1209:28)
at InterceptingListener._callNext (/srv/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (/srv/node_modules/grpc/src/client_interceptors.js:618:8)
at callback (/srv/node_modules/grpc/src/client_interceptors.js:847:24)
code: 5,metadata: Metadata {_internal_repr: { 'grpc-server-stats-bin': [Array] },flags: 0 },details: 'Invalid resource ID' }
我的代码如下:
function callAutoMLAPI(b64img) {
return new Promise((resolve, reject) => {
const payload = {
"image": {
"imageBytes": b64img
}
}
const reqBody = {
name: predictionClient.modelPath(project, region, automl_model),
payload: payload
}
console.log('ReqBody: ',reqBody);
predictionClient.predict(reqBody)
.then(responses => {
console.log('Got a prediction from AutoML API!', JSON.stringify(responses));
resolve(responses);
return null;
})
.catch(err => {
console.log('AutoML API Error: ',err);
reject(err);
});
});
}
我认为这是因为我的位置或 modelId 不正确,但我不知道在哪里可以找到我的模型位置和我的 modelId
如前所述here "The model name has the format projects/{project-id}/locations/us-central1/models/{model-id}; the model ID is the element that appears after models/ in the "响应的名称"值。"
表示是模型页下的ID