모델 평가

AutoML Vision 객체 감지는 모델을 학습시킨 후 테스트 세트의 이미지를 사용하여 새 모델의 품질과 정확성을 평가합니다.

AutoML Vision 객체 감지는 모델의 전반적인 성능이 어떠한지를 나타내는 종합적인 평가 측정항목(평가 프로세스 출력)과 해당 라벨에 대한 모델의 성능을 나타내는 카테고리 라벨별 평가 측정학목을 제공합니다.

평가 개요

평가 처리 입력

  • IoU 임곗값: Intersection over Union의 약자로, 객체 감지에서 객체에 대해 예측된 경계 상자와 실제 경계 상자가 겹치는 부분을 측정하는 데 사용되는 값입니다. 예측된 경계 상자 값이 실제 경계 상자 값에 가까워질수록 교차 영역과 IoU 값이 커집니다.

  • 점수 임곗값: 모델이 이 값보다 낮은 점수를 가진 예측을 반환하지 않는다는 가정 하에 출력 측정항목(미만)이 계산됩니다.

평가 처리 출력

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

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

  • F1 점수: 정밀도와 재현율의 조화 평균입니다. F1은 정밀도와 재현율 사이의 균형을 찾고 있을 때 유용한 측정항목입니다. F1은 학습 데이터의 클래스 분포가 균등하지 않을 때도 유용합니다.

이 데이터를 사용하여 모델의 준비 상태를 평가합니다. 혼동이 높거나, AUC 점수가 낮거나, 정밀도/재현율 점수가 낮다면 모델에 학습 데이터가 더 많이 필요하거나 라벨이 일관되지 않은 경우일 수 있습니다. AUC 점수가 너무 높고 정밀도/재현율이 완벽하다면 데이터가 너무 '쉬워서' 일반화가 잘 되지 않는 경우일 수 있습니다. AUC가 높은 것은 모델이 미래의 추론을 잘 나타내지 않는 이상적인 데이터로 학습되었음을 나타냅니다.

모델 평가 관리

모델 평가 나열

모델을 학습시키면 해당 모델에 대한 평가 측정항목을 나열할 수 있습니다.

웹 UI

  1. AutoML Vision 객체 감지 UI를 열고 왼쪽 탐색 메뉴에서 모델 탭(전구 아이콘이 있음)을 클릭하여 사용 가능한 모델을 표시합니다.

    다른 프로젝트의 모델을 보려면 제목 표시줄 오른쪽 위에 있는 드롭다운 목록에서 프로젝트를 선택하세요.

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

  3. 필요하면 제목 표시줄 아래에 있는 평가 탭을 클릭합니다.

    모델 학습이 끝나면 AutoML Vision 객체 감지에 평가 측정항목이 표시됩니다.

    모델 평가 페이지

  4. 특정 라벨의 측정항목을 보려면 페이지 하단에 있는 라벨 목록에서 라벨 이름을 선택합니다.

    모델 평가 페이지 특정 라벨

REST

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

  • project-id: GCP 프로젝트 ID입니다.
  • model-id: 모델을 만들 때의 응답에서 모델의 ID입니다. ID는 모델 이름의 마지막 요소입니다. 예를 들면 다음과 같습니다.
    • 모델 이름: projects/project-id/locations/location-id/models/IOD4412217016962778756
    • 모델 ID: IOD4412217016962778756

HTTP 메서드 및 URL:

GET https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/models/MODEL_ID/modelEvaluations

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

curl

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

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: project-id" \
"https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/models/MODEL_ID/modelEvaluations"

PowerShell

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

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

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/models/MODEL_ID/modelEvaluations" | Select-Object -Expand Content

다음 샘플과 유사한 JSON 응답이 표시됩니다. 키 객체 감지 관련 필드는 굵게 표시되며 명확성을 위해 다양한 양의 boundingBoxMetricsEntries 항목이 표시됩니다.



    {
  "modelEvaluation": [
    {
      "name": "projects/project-id/locations/us-central1/models/model-id/modelEvaluations/model-eval-id",
      "annotationSpecId": "6342510834593300480",
      "createTime": "2019-07-26T22:28:56.890727Z",
      "evaluatedExampleCount": 18,
      "imageObjectDetectionEvaluationMetrics": {
        "evaluatedBoundingBoxCount": 96,
        "boundingBoxMetricsEntries": [
          {
            "iouThreshold": 0.15,
            "meanAveragePrecision": 0.6317751,
            "confidenceMetricsEntries": [
              {
                "confidenceThreshold": 0.101631254,
                "recall": 0.84375,
                "precision": 0.2555205,
                "f1Score": 0.3922518
              },
              {
                "confidenceThreshold": 0.10180253,
                "recall": 0.8333333,
                "precision": 0.25316456,
                "f1Score": 0.3883495
              },
              ...
              {
                "confidenceThreshold": 0.8791167,
                "recall": 0.020833334,
                "precision": 1,
                "f1Score": 0.040816326
              },
              {
                "confidenceThreshold": 0.8804436,
                "recall": 0.010416667,
                "precision": 1,
                "f1Score": 0.020618558
              }
            ]
          },
          {
            "iouThreshold": 0.8,
            "meanAveragePrecision": 0.15461995,
            "confidenceMetricsEntries": [
              {
                "confidenceThreshold": 0.101631254,
                "recall": 0.22916667,
                "precision": 0.06940063,
                "f1Score": 0.10653753
              },
              ...
              {
                "confidenceThreshold": 0.8804436,
                "recall": 0.010416667,
                "precision": 1,
                "f1Score": 0.020618558
              }
            ]
          },
          {
            "iouThreshold": 0.4,
            "meanAveragePrecision": 0.56170964,
            "confidenceMetricsEntries": [
              {
                "confidenceThreshold": 0.101631254,
                "recall": 0.7604167,
                "precision": 0.23028392,
                "f1Score": 0.3535109
              },
              ...
              {
                "confidenceThreshold": 0.8804436,
                "recall": 0.010416667,
                "precision": 1,
                "f1Score": 0.020618558
              }
            ]
          },
          ...
        ],
        "boundingBoxMeanAveragePrecision": 0.4306387
      },
      "displayName": "Tomato"
    },
    {
      "name": "projects/project-id/locations/us-central1/models/model-id/modelEvaluations/model-eval-id",
      "annotationSpecId": "1730824816165912576",
      "createTime": "2019-07-26T22:28:56.890727Z",
      "evaluatedExampleCount": 9,
      "imageObjectDetectionEvaluationMetrics": {
        "evaluatedBoundingBoxCount": 51,
        "boundingBoxMetricsEntries": [
          {
            ...
          }
        ],
        "boundingBoxMeanAveragePrecision": 0.29565892
      },
      "displayName": "Cheese"
    },
    {
      "name": "projects/project-id/locations/us-central1/models/model-id/modelEvaluations/model-eval-id",
      "annotationSpecId": "7495432339200147456",
      "createTime": "2019-07-26T22:28:56.890727Z",
      "evaluatedExampleCount": 4,
      "imageObjectDetectionEvaluationMetrics": {
        "evaluatedBoundingBoxCount": 22,
        "boundingBoxMetricsEntries": [
          {
            "iouThreshold": 0.2,
            "meanAveragePrecision": 0.104004614,
            "confidenceMetricsEntries": [
              {
                "confidenceThreshold": 0.1008248,
                "recall": 0.36363637,
                "precision": 0.08888889,
                "f1Score": 0.14285715
              },
              ...
              {
                "confidenceThreshold": 0.47585258,
                "recall": 0.045454547,
                "precision": 1,
                "f1Score": 0.08695653
              }
            ]
          },
          ...
        ],
        "boundingBoxMeanAveragePrecision": 0.057070773
      },
      "displayName": "Seafood"
    }
  ]
}

Go

이 샘플을 사용해 보기 전에 클라이언트 라이브러리 페이지에서 언어 설정 안내를 따르세요.

import (
	"context"
	"fmt"
	"io"

	automl "cloud.google.com/go/automl/apiv1"
	"cloud.google.com/go/automl/apiv1/automlpb"
	"google.golang.org/api/iterator"
)

// listModelEvaluation lists existing model evaluations.
func listModelEvaluations(w io.Writer, projectID string, location string, modelID string) error {
	// projectID := "my-project-id"
	// location := "us-central1"
	// modelID := "TRL123456789..."

	ctx := context.Background()
	client, err := automl.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("NewClient: %w", err)
	}
	defer client.Close()

	req := &automlpb.ListModelEvaluationsRequest{
		Parent: fmt.Sprintf("projects/%s/locations/%s/models/%s", projectID, location, modelID),
	}

	it := client.ListModelEvaluations(ctx, req)

	// Iterate over all results
	for {
		evaluation, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("ListModelEvaluations.Next: %w", err)
		}

		fmt.Fprintf(w, "Model evaluation name: %v\n", evaluation.GetName())
		fmt.Fprintf(w, "Model annotation spec id: %v\n", evaluation.GetAnnotationSpecId())
		fmt.Fprintf(w, "Create Time:\n")
		fmt.Fprintf(w, "\tseconds: %v\n", evaluation.GetCreateTime().GetSeconds())
		fmt.Fprintf(w, "\tnanos: %v\n", evaluation.GetCreateTime().GetNanos())
		fmt.Fprintf(w, "Evaluation example count: %v\n", evaluation.GetEvaluatedExampleCount())
		fmt.Fprintf(w, "Object detection model evaluation metrics: %v\n", evaluation.GetImageObjectDetectionEvaluationMetrics())
	}

	return nil
}

Java

이 샘플을 사용해 보기 전에 클라이언트 라이브러리 페이지에서 언어 설정 안내를 따르세요.


import com.google.cloud.automl.v1.AutoMlClient;
import com.google.cloud.automl.v1.ListModelEvaluationsRequest;
import com.google.cloud.automl.v1.ModelEvaluation;
import com.google.cloud.automl.v1.ModelName;
import java.io.IOException;

class ListModelEvaluations {

  public static void main(String[] args) throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "YOUR_PROJECT_ID";
    String modelId = "YOUR_MODEL_ID";
    listModelEvaluations(projectId, modelId);
  }

  // List model evaluations
  static void listModelEvaluations(String projectId, String modelId) 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.
      ModelName modelFullId = ModelName.of(projectId, "us-central1", modelId);
      ListModelEvaluationsRequest modelEvaluationsrequest =
          ListModelEvaluationsRequest.newBuilder().setParent(modelFullId.toString()).build();

      // List all the model evaluations in the model by applying filter.
      System.out.println("List of model evaluations:");
      for (ModelEvaluation modelEvaluation :
          client.listModelEvaluations(modelEvaluationsrequest).iterateAll()) {

        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(
            "Object Detection Model Evaluation Metrics: %s\n",
            modelEvaluation.getImageObjectDetectionEvaluationMetrics());
      }
    }
  }
}

Node.js

이 샘플을 사용해 보기 전에 클라이언트 라이브러리 페이지에서 언어 설정 안내를 따르세요.

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

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

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

async function listModelEvaluations() {
  // Construct request
  const request = {
    parent: client.modelPath(projectId, location, modelId),
    filter: '',
  };

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

  console.log('List of model evaluations:');
  for (const evaluation of response) {
    console.log(`Model evaluation name: ${evaluation.name}`);
    console.log(`Model annotation spec id: ${evaluation.annotationSpecId}`);
    console.log(`Model display name: ${evaluation.displayName}`);
    console.log('Model create time');
    console.log(`\tseconds ${evaluation.createTime.seconds}`);
    console.log(`\tnanos ${evaluation.createTime.nanos / 1e9}`);
    console.log(
      `Evaluation example count: ${evaluation.evaluatedExampleCount}`
    );
    console.log(
      `Object detection model evaluation metrics: ${evaluation.imageObjectDetectionEvaluationMetrics}`
    );
  }
}

listModelEvaluations();

Python

이 샘플을 사용해 보기 전에 클라이언트 라이브러리 페이지에서 언어 설정 안내를 따르세요.

from google.cloud import automl

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

client = automl.AutoMlClient()
# Get the full path of the model.
model_full_id = client.model_path(project_id, "us-central1", model_id)

print("List of model evaluations:")
for evaluation in client.list_model_evaluations(parent=model_full_id, filter=""):
    print(f"Model evaluation name: {evaluation.name}")
    print(f"Model annotation spec id: {evaluation.annotation_spec_id}")
    print(f"Create Time: {evaluation.create_time}")
    print(f"Evaluation example count: {evaluation.evaluated_example_count}")
    print(
        "Object detection model evaluation metrics: {}\n\n".format(
            evaluation.image_object_detection_evaluation_metrics
        )
    )

추가 언어

C#: 클라이언트 라이브러리 페이지의 C# 설정 안내를 따른 다음 .NET용 AutoML Vision 객체 감지 참조 문서를 참조하세요.

PHP: 클라이언트 라이브러리 페이지의 PHP 설정 안내를 따른 다음 PHP용 AutoML Vision 객체 감지 참조 문서를 참조하세요.

Ruby: 클라이언트 라이브러리 페이지의 Ruby 설정 안내를 따른 다음 Ruby용 AutoML Vision 객체 감지 참조 문서를 참조하세요.

모델 평가 가져오기

평가 ID를 사용하여 라벨(displayName)의 특정 모델 평가를 가져올 수도 있습니다.

웹 UI

AutoML Vision 객체 감지 UI에서 모델 페이지로 이동한 다음 모델을 선택하면 같은 작업을 사용할 수 있습니다. 모델을 선택한 후 평가 탭으로 이동하고 라벨을 선택하여 라벨별 평가를 봅니다.

모델 평가 페이지 특정 라벨

REST

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

  • project-id: GCP 프로젝트 ID입니다.
  • model-id: 모델을 만들 때의 응답에서 모델의 ID입니다. ID는 모델 이름의 마지막 요소입니다. 예를 들면 다음과 같습니다.
    • 모델 이름: projects/project-id/locations/location-id/models/IOD4412217016962778756
    • 모델 ID: IOD4412217016962778756
  • model-evaluation-id: 모델 평가의 ID 값입니다. list 모델 평가 작업에서 모델 평가 ID를 가져올 수 있습니다.

HTTP 메서드 및 URL:

GET https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/models/MODEL_ID/modelEvaluations/MODEL_EVALUATION_ID

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

curl

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

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: project-id" \
"https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/models/MODEL_ID/modelEvaluations/MODEL_EVALUATION_ID"

PowerShell

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

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

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/models/MODEL_ID/modelEvaluations/MODEL_EVALUATION_ID" | Select-Object -Expand Content

다음 샘플과 유사한 JSON 응답이 표시됩니다. 키 객체 감지 관련 필드는 굵게 표시되며 명확성을 위해 짧은 버전의 boundingBoxMetricsEntries 항목이 표시됩니다.



    {
  "name": "projects/project-id/locations/us-central1/models/model-id/modelEvaluations/model-evaluation-id",
  "annotationSpecId": "6342510834593300480",
  "createTime": "2019-07-26T22:28:56.890727Z",
  "evaluatedExampleCount": 18,
  "imageObjectDetectionEvaluationMetrics": {
    "evaluatedBoundingBoxCount": 96,
    "boundingBoxMetricsEntries": [
      {
        "iouThreshold": 0.15,
        "meanAveragePrecision": 0.6317751,
        "confidenceMetricsEntries": [
          {
            "confidenceThreshold": 0.101631254,
            "recall": 0.84375,
            "precision": 0.2555205,
            "f1Score": 0.3922518
          },
          ...
          {
            "confidenceThreshold": 0.8804436,
            "recall": 0.010416667,
            "precision": 1,
            "f1Score": 0.020618558
          }
        ]
      },
      {
        "iouThreshold": 0.8,
        "meanAveragePrecision": 0.15461995,
        "confidenceMetricsEntries": [
          {
            "confidenceThreshold": 0.101631254,
            "recall": 0.22916667,
            "precision": 0.06940063,
            "f1Score": 0.10653753
          },
          ...
          {
            "confidenceThreshold": 0.8804436,
            "recall": 0.010416667,
            "precision": 1,
            "f1Score": 0.020618558
          }
        ]
      },
      {
        "iouThreshold": 0.4,
        "meanAveragePrecision": 0.56170964,
        "confidenceMetricsEntries": [
          {
            "confidenceThreshold": 0.101631254,
            "recall": 0.7604167,
            "precision": 0.23028392,
            "f1Score": 0.3535109
          },
          ...
          {
            "confidenceThreshold": 0.8804436,
            "recall": 0.010416667,
            "precision": 1,
            "f1Score": 0.020618558
          }
        ]
      },
      ...
    ],
    "boundingBoxMeanAveragePrecision": 0.4306387
  },
  "displayName": "Tomato"
}

Go

이 샘플을 사용해 보기 전에 클라이언트 라이브러리 페이지에서 언어 설정 안내를 따르세요.

import (
	"context"
	"fmt"
	"io"

	automl "cloud.google.com/go/automl/apiv1"
	"cloud.google.com/go/automl/apiv1/automlpb"
)

// getModelEvaluation gets a model evaluation.
func getModelEvaluation(w io.Writer, projectID string, location string, modelID string, modelEvaluationID string) error {
	// projectID := "my-project-id"
	// location := "us-central1"
	// modelID := "TRL123456789..."
	// modelEvaluationID := "123456789..."

	ctx := context.Background()
	client, err := automl.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("NewClient: %w", err)
	}
	defer client.Close()

	req := &automlpb.GetModelEvaluationRequest{
		Name: fmt.Sprintf("projects/%s/locations/%s/models/%s/modelEvaluations/%s", projectID, location, modelID, modelEvaluationID),
	}

	evaluation, err := client.GetModelEvaluation(ctx, req)
	if err != nil {
		return fmt.Errorf("GetModelEvaluation: %w", err)
	}

	fmt.Fprintf(w, "Model evaluation name: %v\n", evaluation.GetName())
	fmt.Fprintf(w, "Model annotation spec id: %v\n", evaluation.GetAnnotationSpecId())
	fmt.Fprintf(w, "Create Time:\n")
	fmt.Fprintf(w, "\tseconds: %v\n", evaluation.GetCreateTime().GetSeconds())
	fmt.Fprintf(w, "\tnanos: %v\n", evaluation.GetCreateTime().GetNanos())
	fmt.Fprintf(w, "Evaluation example count: %v\n", evaluation.GetEvaluatedExampleCount())
	fmt.Fprintf(w, "Object detection model evaluation metrics: %v\n", evaluation.GetImageObjectDetectionEvaluationMetrics())

	return nil
}

Java

이 샘플을 사용해 보기 전에 클라이언트 라이브러리 페이지에서 언어 설정 안내를 따르세요.


import com.google.cloud.automl.v1.AutoMlClient;
import com.google.cloud.automl.v1.ModelEvaluation;
import com.google.cloud.automl.v1.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(
          "Object Detection Model Evaluation Metrics: %s\n",
          modelEvaluation.getImageObjectDetectionEvaluationMetrics());
    }
  }
}

Node.js

이 샘플을 사용해 보기 전에 클라이언트 라이브러리 페이지에서 언어 설정 안내를 따르세요.

/**
 * 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').v1;

// 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(
    `Object detection model evaluation metrics: ${response.imageObjectDetectionEvaluationMetrics}`
  );
}

getModelEvaluation();

Python

이 샘플을 사용해 보기 전에 클라이언트 라이브러리 페이지에서 언어 설정 안내를 따르세요.

from google.cloud import 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(
    "Object detection model evaluation metrics: {}".format(
        response.image_object_detection_evaluation_metrics
    )
)

추가 언어

C#: 클라이언트 라이브러리 페이지의 C# 설정 안내를 따른 다음 .NET용 AutoML Vision 객체 감지 참조 문서를 참조하세요.

PHP: 클라이언트 라이브러리 페이지의 PHP 설정 안내를 따른 다음 PHP용 AutoML Vision 객체 감지 참조 문서를 참조하세요.

Ruby: 클라이언트 라이브러리 페이지의 Ruby 설정 안내를 따른 다음 Ruby용 AutoML Vision 객체 감지 참조 문서를 참조하세요.

참양성, 거짓음성, 거짓양성(UI 전용)

사용자 인터페이스에서 TRAINING 및 VALIDATION 세트의 특정 모델 성능 예시, 즉 참양성(TP), 거짓 음성(FN), 거짓 양성(FP) 인스턴스를 확인할 수 있습니다.

웹 UI

평가 탭을 선택한 다음 특정 라벨을 선택하여 UI에서 TP, FN, FP 보기에 액세스할 수 있습니다.

이러한 예측의 추세를 보면서 학습 세트를 수정하여 모델의 성능을 개선할 수 있습니다.

참양성 이미지는 모델에서 올바르게 주석 처리된 학습된 모델에 제공되는 검증 상자입니다.

참양성

거짓음성 이미지는 학습된 모델에 유사하게 제공되지만 모델에서 객체 인스턴스에 올바르게 주석 처리할 수 없는 경우입니다.

거짓 음성

마지막으로 거짓 양성 이미지는 학습된 모델에 제공되는 이미지로, 객체의 주석 처리된 인스턴스가 지정된 영역에서 주석 처리되지 않은 경우입니다.

거짓 양성

이 모델은 흥미로운 특수 상황을 선택하여 모델이 라벨 해석을 이해할 수 있도록 정의와 라벨을 세분화할 수 있는 기회를 제공합니다. 예를 들어 더 엄격한 정의를 사용하면 모델이 속을 채운 피망을 '샐러드'로 간주할 것인지 아닌지를 판단하는 데 도움이 됩니다. 라벨, 학습, 평가 루프를 반복하면 모델에서 데이터의 다른 모호성이 드러납니다.

이 보기의 점수 임계값을 사용자 인터페이스에서 조정할 수도 있으며 표시되는 TP, FN, FP 이미지는 기준 변경사항을 반영합니다.

임곗값이 업데이트된 참양성

평가 측정항목 해석

객체 감지 모델은 입력 이미지에 대한 많은 경계 상자를 출력합니다. 각 상자에는 1) 라벨 및 2) 점수 또는 신뢰도가 제공됩니다. 평가 측정항목을 사용하면 모델에 대한 몇 가지 주요 성능 질문에 답할 수 있습니다.

  • 올바른 개수의 상자를 받고 있는가?
  • 모델이 중요하지 않은 케이스에 낮은 점수를 주는 경향이 있는가?
  • 예측된 상자가 정답 상자와 얼마나 정확하게 일치하는가?

다중 라벨 분류와 마찬가지로 이러한 측정항목은 일반적으로 낮은 점수 이외의 클래스 혼동을 지적하지 않습니다.

이미지당 모델 출력을 검사할 때 한 쌍의 상자(정답 상자와 예측된 상자)를 검사하고 일치하는 정도를 결정할 방법이 필요합니다. 다음과 같은 사항을 고려해야 합니다.

  • 두 상자의 라벨이 동일한가?
  • 두 상자가 얼마나 겹치는가?
  • 모델이 어느 정도의 신뢰도로 상자를 예측했는가?

두 번째 요구사항을 해결하기 위해 intersection-over-union 또는 IoU라고 하는 새 측정값을 도입합니다.

IoU 및 IoU 임곗값

상자 IoU

IoU는 두 상자가 얼마나 일치하는지를 결정합니다. IoU 값의 범위는 0(겹침 없음)~1(상자가 동일함)이며, 두 상자의 공통 영역을 하나 이상의 상자에 포함된 영역으로 나누어 계산합니다. AutoML 서비스를 사용하면 여러 IoU 임곗값에서 모델의 성능을 검사할 수 있습니다.

IoU 임곗값을 변경하는 경우

주차장에서 자동차를 세는 사용 사례를 생각해보세요. 상자 좌표가 정확한지는 중요하지 않으며 상자의 개수가 올바른지만 고려하면 됩니다. 이 경우 낮은 IoU 임곗값이 적절합니다.

자동차 주변의 낮은 임곗값 상자
이미지 출처: Nacho, 'Smart' (CC BY 2.0, 경계 상자 및 텍스트 추가)

직물 얼룩의 크기를 측정하는 경우도 생각해보세요. 이 경우에는 매우 정확한 좌표가 필요하므로 더 높은 IoU 임곗값이 적절합니다.

직물 얼룩 주위의 높은 임곗값
이미지 출처: Housing Works Thrift Shops, 'Modern Sofa' (CC BY-SA 2.0, 경계 상자 및 텍스트 추가)

사용 사례의 올바른 임곗값을 변경하고 싶은 경우 이미 다양한 IoU 임곗값에서 평가 측정항목에 액세스할 수 있기 때문에 모델을 다시 학습시킬 필요가 없습니다.

점수 및 점수 임곗값

분류 모델과 유사하게 객체 감지 모델 출력(지금 상자)에 점수가 제공됩니다. 또한 이미지 분류와 마찬가지로 학습 후 '잘' 일치하는지 여부를 판단하기 위해 지정할 수 있는 점수 임곗값이 있습니다. 점수 임곗값을 변경하면 특정 모델의 필요에 맞춰 거짓 양성참양성 비율을 조정할 수 있습니다. 매우 높은 재현율을 원하는 사용자는 일반적으로 모델 출력을 처리할 때 낮은 점수 임곗값을 적용합니다.

모델 반복 학습

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

  • 품질이 낮은 경계 상자 라벨에 이미지를 더 추가해 봅니다.
  • 여러 가지 유형의 이미지(예: 더 넓은 시각, 고해상도 또는 저해상도, 다른 시점)를 추가해야 할 수 있습니다.
  • 학습 이미지가 충분하지 않은 경우에는 경계 상자 라벨을 모두 삭제해 봅니다.
  • Google의 학습 알고리즘은 라벨 이름을 사용하지 않습니다. 하나의 라벨을 'door'라고 하고 다른 라벨을 'door_with_knob'이라고 했을 때 알고리즘은 제공한 이미지를 고려할 뿐 미묘한 차이를 알지 못합니다.
  • 참양성, 참음성의 예시를 추가하여 데이터를 보강합니다. 결정 경계에 가까운 예시, 즉 혼동이 발생하기 쉽지만 라벨이 정확히 지정된 예시가 특히 중요합니다.
  • 학습, 테스트, 검증 분할을 직접 지정합니다. 이미지가 무작위로 배정되는 과정에서 학습과 검증에 거의 비슷한 이미지가 포함되면 과적합이 발생하여 테스트 세트에 대한 성능이 저하될 수 있습니다.

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