Прогнозирование классификации видео в Google AutoML для пользовательской модели с помощью облачной функции - PullRequest
0 голосов
/ 14 марта 2020

Мы обучили модель с использованием классификации видео Google AutoML и сейчас пытаемся сделать пакетные прогнозы с помощью облачной функции. В настоящее время мы используем следующий код, но он возвращает сообщение об ошибке:

Error: function terminated. Recommended action: inspect logs for termination reason. Details:
7 PERMISSION_DENIED: The caller does not have permission

код nodejs:

exports.myFunction = (req, res) => {

  const projectId = 'project-id';
  const location = 'us-central1';
  const modelId = 'model-id';
  const inputUri = 'bucket-uri';
  const outputUri = 'bucket-uri';

  console.log("importing google cloud automl...");

  // Imports the Google Cloud AutoML library
  const {PredictionServiceClient} = require(`@google-cloud/automl`).v1;

  console.log("instantiating PredictionServiceClient...");

  // Instantiates a client
  const client = new PredictionServiceClient();

  console.log("instantiated PredictionServiceClient...");

  async function batchPredict() {
    // Construct request
    const request = {
      name: client.modelPath(projectId, location, modelId),
      inputConfig: {
        gcsSource: {
          inputUris: [inputUri],
        },
      },
      outputConfig: {
        gcsDestination: {
          outputUriPrefix: outputUri,
        },
      },
    };

    console.log("making batch prediction...");
    const [operation] = await client.batchPredict(request);

    console.log("about to run promise...");
    const [response] = await operation.promise();
    console.log(response);

    res.status(200).send("Prediction successfull!");
  }

  // make prediction
  batchPredict();

};

1 Ответ

0 голосов
/ 20 марта 2020

, если вы используете "const client = new PredictionServiceClient ();" тогда для процесса используется учетная запись службы по умолчанию. "service-@gcp-sa-automl.iam.gserviceaccount.com"

Для запуска пакетного прогнозирования требуются следующие разрешения:

  1. AutoML Admin
  2. AutoML Predictor
  3. AutoML Service Agent
  4. Администратор объекта хранения

Если вы хотите использовать другую учетную запись службы, используйте следующий код.

credentials = service_account.Credentials.from_service_account_file("/path/to/service-account-key.json")
const client = new PredictionServiceClient(credentials=credentials)
...