问题描述
在此 documentation 之后,当我通过 API 请求 batchPredict 时遇到此错误
{
"error": {
"code": 13
"message": "internal",}
}
此外,这是我尝试使用“测试和使用”选项卡时看到的错误的屏幕截图 screenshot。这两个都不是描述性的,所以我不确定错误在哪里。
在请求中,我在 Google 存储中包含了我的 CSV 文件的路径,该文件链接到同一存储分区中的视频。这是 CSV 的内容:
gs://XXXXXXXXXXXX/movie1.mov,inf
gs://XXXXXXXXXXXX/movie2.mov,inf
我还包括 /Results 文件夹的路径(在同一个存储桶中)以保存预测。
const client = new PredictionServiceClient();
async function batchPredict() {
const request = {
name: client.modelPath('project-id-xxxxxx','us-central1','VOTxxxxxxxxxx'),inputConfig: {
gcsSource: {
inputUris: ['gs://XXXXXXXXXXXX/apitest.csv'],},outputConfig: {
gcsDestination: {
outputUriPrefix: 'gs://XXXXXXXXXXXX/results/',};
如果我需要提供更多细节,请告诉我。
解决方法
可能的根本原因是这两个原因之一:
- 您的代码中存在问题。所以,如果你的代码和下面的不一样,我建议你尝试一下(当然要改变适当的变量)。
- 您的模型有问题,这是最可能的根本原因(根据错误消息本身)。
因此,如果它不是您的代码,您应该在问题跟踪器上创建一个私有的 issue report,解释您的问题并提供尽可能多的详细信息以及您的用例和影响。
由于它是私有的,只有 Google 员工和您可以访问它,因此请随时分享您的项目和模型 ID。
为了重现您的问题,我做了以下工作(请务必遵循 before you begin guide):
- 我在
gs://YOUR_BUCKET/TRAINING.csv
上训练了一个模型
TRAIN,gs://automl-video-demo-data/traffic_videos/traffic_videos_train.csv
TEST,gs://automl-video-demo-data/traffic_videos/traffic_videos_test.csv
- 根据
gs://YOUR_BUCKET/VIDEOS_TO_ANNOTATE.csv
(inputUri) 上的几张图片进行预测:
gs://automl-video-demo-data/traffic_videos/highway_078.mp4,inf
gs://automl-video-demo-data/traffic_videos/highway_079.mp4,10.00000,15.50000
- 使用教程中的 Node.js predict example:
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
const projectId = 'YOUR_PROJECT';
const location = 'us-central1';
const modelId = 'VOTXXXXXXXXXXXXXXXXXX';
const inputUri = 'gs://YOUR_BUCKET/VIDEOS_TO_ANNOTATE.csv';
const outputUri = 'gs://YOUR_BUCKET/outputs/';
// Imports the Google Cloud AutoML library
const {PredictionServiceClient} = require('@google-cloud/automl').v1beta1;
// Instantiates a client
const client = new PredictionServiceClient();
async function batchPredict() {
// Construct request
const request = {
name: client.modelPath(projectId,location,modelId),inputConfig: {
gcsSource: {
inputUris: [inputUri],},outputConfig: {
gcsDestination: {
outputUriPrefix: outputUri,};
const [operation] = await client.batchPredict(request);
console.log('Waiting for operation to complete...');
// Wait for operation to complete.
const [response] = await operation.promise();
console.log(
`Batch Prediction results saved to Cloud Storage bucket. ${response}`
);
}
batchPredict();
请注意,我也尝试过 REST & CMD LINE predict example。
在这两种情况下,它都运行良好,我收到了正确的回复: Nodejs 预测的响应:
Waiting for operation to complete...
Batch Prediction results saved to Cloud Storage bucket. [object Object]
REST & CMD LINE 预测响应:
{
"name": "projects/XXXXXXXXXX/locations/us-central1/operations/VOTXXXXXXXXXXXXXXX","metadata": {
"@type": "type.googleapis.com/google.cloud.automl.v1beta1.OperationMetadata","createTime": "2021-04-16T08:09:52.102270Z","updateTime": "2021-04-16T08:09:52.102270Z","batchPredictDetails": {
"inputConfig": {
"gcsSource": {
"inputUris": [
"gs://MY_BUCKET/VIDEOS_TO_ANNOTATE.csv"
]
}
}
}
}
}