모델 평가

AutoML Video Intelligence Classification은 모델을 학습한 후 테스트 세트의 항목을 사용하여 새 모델의 품질과 정확성을 평가합니다.

AutoML Video Intelligence Classification은 모델의 전반적인 성능을 나타내는 종합적인 평가 측정항목과 모델의 해당 라벨에 대한 성능을 나타내는 카테고리 라벨별 평가 측정항목을 제공합니다.

  • AuPRC: 정밀도/재현율 곡선 아래 영역으로, '평균 정밀도'라고도 합니다. 일반적으로 0.5에서 1.0 사이이며 값이 클수록 모델이 정확한 것입니다.

  • 신뢰도 기준 곡선은 신뢰도 기준의 변화가 정밀도, 재현율, 참양성률, 거짓양성률에 미치는 영향을 보여줍니다. 정밀도와 재현율의 관계에 대해 알아보세요.

이 데이터를 사용하여 모델의 준비 상태를 평가합니다. AUC 점수가 낮거나, 정밀도/재현율 점수가 낮다면 모델에 학습 데이터가 더 많이 필요한 경우일 수 있습니다. AUC 점수가 너무 높고 정밀도 및 재현율이 완벽하다면 데이터가 너무 쉬워서 일반화가 잘 되지 않는 경우일 수 있습니다.

모델 평가값 가져오기

웹 UI

  1. AutoML Video UI에서 모델 페이지를 엽니다.

  2. 평가하려는 모델의 행을 클릭합니다.

  3. 평가 탭을 클릭합니다.

    모델의 학습이 완료되면 AutoML Video에서 평가 측정항목을 보여줍니다.

    모델 정보를 제공하는 평가 탭
  4. 특정 라벨의 측정항목을 보려면 페이지 하단에 있는 라벨 목록에서 라벨 이름을 선택합니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • model-name: 모델을 만들 때 받은 응답의 모델 전체 이름입니다. 전체 이름의 형식은 다음과 같습니다. projects/project-number/locations/location-id/models/model-id.
  • project-number: 프로젝트 수입니다.

HTTP 메서드 및 URL:

GET  https://automl.googleapis.com/v1beta1/model-name:modelEvaluations

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

다음 명령어를 실행합니다.

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: project-number" \
" https://automl.googleapis.com/v1beta1/model-name:modelEvaluations"

PowerShell

다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "project-number" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri " https://automl.googleapis.com/v1beta1/model-name:modelEvaluations" | Select-Object -Expand Content
응답에는 전체 모델의 ModelEvaluation 리소스가 포함됩니다. 예를 들면 2308399322008336298입니다.

Java

AutoML Video에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import com.google.cloud.automl.v1beta1.AutoMlClient;
import com.google.cloud.automl.v1beta1.ModelEvaluation;
import com.google.cloud.automl.v1beta1.ModelEvaluationName;
import java.io.IOException;

class GetModelEvaluation {

  static void getModelEvaluation() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "YOUR_PROJECT_ID";
    String modelId = "YOUR_MODEL_ID";
    String modelEvaluationId = "YOUR_MODEL_EVALUATION_ID";
    getModelEvaluation(projectId, modelId, modelEvaluationId);
  }

  // Get a model evaluation
  static void getModelEvaluation(String projectId, String modelId, String modelEvaluationId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (AutoMlClient client = AutoMlClient.create()) {
      // Get the full path of the model evaluation.
      ModelEvaluationName modelEvaluationFullId =
          ModelEvaluationName.of(projectId, "us-central1", modelId, modelEvaluationId);

      // Get complete detail of the model evaluation.
      ModelEvaluation modelEvaluation = client.getModelEvaluation(modelEvaluationFullId);

      System.out.format("Model Evaluation Name: %s%n", modelEvaluation.getName());
      System.out.format("Model Annotation Spec Id: %s", modelEvaluation.getAnnotationSpecId());
      System.out.println("Create Time:");
      System.out.format("\tseconds: %s%n", modelEvaluation.getCreateTime().getSeconds());
      System.out.format("\tnanos: %s", modelEvaluation.getCreateTime().getNanos() / 1e9);
      System.out.format(
          "Evalution Example Count: %d%n", modelEvaluation.getEvaluatedExampleCount());

      System.out.format(
          "Classification Model Evaluation Metrics: %s%n",
          modelEvaluation.getClassificationEvaluationMetrics());
    }
  }
}

Node.js

AutoML Video에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// const projectId = 'YOUR_PROJECT_ID';
// const location = 'us-central1';
// const modelId = 'YOUR_MODEL_ID';
// const modelEvaluationId = 'YOUR_MODEL_EVALUATION_ID';

// Imports the Google Cloud AutoML library
const {AutoMlClient} = require('@google-cloud/automl').v1beta1;

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

async function getModelEvaluation() {
  // Construct request
  const request = {
    name: client.modelEvaluationPath(
      projectId,
      location,
      modelId,
      modelEvaluationId
    ),
  };

  const [response] = await client.getModelEvaluation(request);

  console.log(`Model evaluation name: ${response.name}`);
  console.log(`Model annotation spec id: ${response.annotationSpecId}`);
  console.log(`Model display name: ${response.displayName}`);
  console.log('Model create time');
  console.log(`\tseconds ${response.createTime.seconds}`);
  console.log(`\tnanos ${response.createTime.nanos / 1e9}`);
  console.log(`Evaluation example count: ${response.evaluatedExampleCount}`);
  console.log(
    `Video classification model evaluation metrics: ${response.videoClassificationEvaluationMetrics}`
  );
}

getModelEvaluation();

Python

AutoML Video에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

from google.cloud import automl_v1beta1 as automl

# TODO(developer): Uncomment and set the following variables
# project_id = "YOUR_PROJECT_ID"
# model_id = "YOUR_MODEL_ID"
# model_evaluation_id = "YOUR_MODEL_EVALUATION_ID"

client = automl.AutoMlClient()
# Get the full path of the model evaluation.
model_path = client.model_path(project_id, "us-central1", model_id)
model_evaluation_full_id = f"{model_path}/modelEvaluations/{model_evaluation_id}"

# Get complete detail of the model evaluation.
response = client.get_model_evaluation(name=model_evaluation_full_id)

print(f"Model evaluation name: {response.name}")
print(f"Model annotation spec id: {response.annotation_spec_id}")
print(f"Create Time: {response.create_time}")
print(f"Evaluation example count: {response.evaluated_example_count}")

print(
    "Classification model evaluation metrics: {}".format(
        response.classification_evaluation_metrics
    )
)

모델 반복 학습

품질 수준이 만족스럽지 않은 경우 이전 단계로 돌아가서 다음과 같이 품질을 높일 수 있습니다.

  • 여러 가지 유형의 동영상(예: 더 넓은 시각, 고해상도 또는 저해상도, 다른 시점)을 추가해야 할 수 있습니다.
  • 학습 동영상이 부족한 라벨을 모두 삭제해 봅니다.
  • 컴퓨터는 라벨 이름을 이해하지 못하며, 무작위로 나열된 글자로 인식할 뿐입니다. 'door' 라벨과 'door_with_knob' 라벨이 있는 경우 컴퓨터는 그 의미의 차이를 알지 못하며 오로지 제공되는 동영상만 구분합니다.
  • 참양성, 참음성의 예를 추가하여 데이터를 보강합니다. 결정 경계에 가까운 예가 특히 중요합니다.

변경을 마친 후 품질 수준이 충분히 향상될 때까지 모델을 학습하고 평가합니다.