분류용 이미지 학습 데이터 준비

이 페이지에서는 이미지 분류 모델을 학습시키기 위해 Vertex AI 데이터 세트에서 사용할 이미지 학습 데이터를 준비하는 방법을 설명합니다.

다음 목표 섹션에는 데이터 요구사항, 입력/출력 스키마 파일, 스키마로 정의되는 데이터 가져오기 파일 형식(JSON Lines 및 CSV)이 포함되어 있습니다.

단일 라벨 분류

데이터 요구사항

  • 학습 데이터: 모델을 학습시킬 때 다음과 같은 이미지 형식이 지원됩니다. Vertex AI API는 이렇게 가져온 이미지를 사전 처리한 후 모델을 학습시키는 데 사용되는 데이터로 제공합니다. 최대 파일 크기는 30MB입니다.
    • JPEG
    • GIF
    • PNG
    • BMP
    • ICO
  • 예측 데이터: 모델에서 예측을 요청 (쿼리)할 때 지원되는 이미지 형식은 다음과 같습니다. 최대 파일 크기는 1.5MB입니다.
    • JPEG
    • GIF
    • PNG
    • WEBP
    • BMP
    • TIFF
    • ICO

    AutoML 모델 학습에 사용되는 이미지 데이터를 위한 권장사항

    다음 권장사항은 AutoML을 사용하여 모델을 학습시키는 데이터 세트에 적용됩니다.

  • AutoML 모델은 현실의 물체를 찍은 사진에 최적화되어 있습니다.
  • 학습 데이터는 예측을 수행할 데이터와 최대한 유사해야 합니다. 예를 들어 사용 사례에 보안 카메라 영상처럼 흐릿한 저해상도 이미지가 포함되는 경우 흐릿한 저해상도 이미지로 학습 데이터를 구성해야 합니다. 또한 일반적으로 다양한 각도, 해상도, 배경으로 촬영한 학습 이미지를 제공하는 것이 좋습니다.
  • 인간이 지정할 수 없는 라벨은 Vertex AI 모델도 일반적으로 예측할 수 없습니다. 따라서 이미지를 1~2초 보고 라벨을 지정하도록 사람을 학습시킬 수 없다면 이 모델도 그렇게 하도록 학습시킬 수 없습니다.
  • 권장되는 학습 이미지 개수는 라벨당 1,000개입니다. 라벨당 최소 개수는 10개입니다. 이미지 하나에 라벨이 여러 개인 모델을 학습시키는 경우 일반적으로 라벨당 필요한 예의 수가 늘어나며, 결과 점수를 해석하기도 어려워집니다.
  • 가장 흔한 라벨의 이미지가 가장 흔하지 않은 라벨의 이미지보다 최대 100배 많을 때 모델 효과가 가장 뛰어납니다. 빈도가 극히 낮은 라벨은 삭제하는 것이 좋습니다.
  • 정의된 라벨 중 어느 것과도 일치하지 않는 None_of_the_above 라벨과 이미지를 포함하면 유용합니다. 예를 들어 꽃 데이터 세트의 경우 라벨을 지정한 품종에 속하지 않는 꽃의 이미지를 포함하고 None_of_the_above 라벨을 붙입니다.

YAML 스키마 파일

공개적으로 액세스할 수 있는 다음 스키마 파일을 사용하여 단일 라벨 이미지 분류 주석을 가져옵니다. 이 스키마 파일은 데이터 입력 파일의 형식을 지정합니다. 이 파일의 구조는 OpenAPI 스키마를 따릅니다.

gs://google-cloud-aiplatform/schema/dataset/ioformat/image_classification_single_label_io_format_1.0.0.yaml

전체 스키마 파일

title: ImageClassificationSingleLabel
description: >
 Import and export format for importing/exporting images together with
 single-label classification annotation. Can be used in
 Dataset.import_schema_uri field.
type: object
required:
- imageGcsUri
properties:
 imageGcsUri:
   type: string
   description: >
     A Cloud Storage URI pointing to an image. Up to 30MB in size.
     Supported file mime types: `image/jpeg`, `image/gif`, `image/png`,
     `image/webp`, `image/bmp`, `image/tiff`, `image/vnd.microsoft.icon`.
 classificationAnnotation:
   type: object
   description: Single classification Annotation on the image.
   properties:
     displayName:
       type: string
       description: >
         It will be imported as/exported from AnnotationSpec's display name,
         i.e. the name of the label/class.
     annotationResourceLabels:
       description: Resource labels on the Annotation.
       type: object
       additionalProperties:
         type: string
 dataItemResourceLabels:
   description: Resource labels on the DataItem.
   type: object
   additionalProperties:
     type: string

입력 파일

JSON Lines

각 행의 JSON:


{
  "imageGcsUri": "gs://bucket/filename.ext",
  "classificationAnnotation": {
    "displayName": "LABEL",
    "annotationResourceLabels": {
        "aiplatform.googleapis.com/annotation_set_name": "displayName",
        "env": "prod"
      }
   },
  "dataItemResourceLabels": {
    "aiplatform.googleapis.com/ml_use": "training/test/validation"
  }
}

필드 참고사항:

  • imageGcsUri - 유일한 필수 필드입니다.
  • annotationResourceLabels - 키-값 문자열 쌍을 포함할 수 있습니다. 시스템에 예약된 유일한 키-값 쌍은 다음과 같습니다.
    • 'aiplatform.googleapis.com/annotation_set_name': 'value'

    여기서 value는 데이터 세트에 있는 기존 주석 집합의 표시 이름 중 하나입니다.

  • dataItemResourceLabels - 키-값 문자열 쌍을 포함할 수 있습니다. 시스템에서 예약할 수 있는 유일한 키-값 쌍은 다음과 같이 데이터 항목의 머신러닝 사용 세트를 지정합니다.
    • 'aiplatform.googleapis.com/ml_use': 'training/test/validation'

JSON Lines 예시 - image_classification_single_label.jsonl:


{"imageGcsUri": "gs://bucket/filename1.jpeg",  "classificationAnnotation": {"displayName": "daisy"}, "dataItemResourceLabels": {"aiplatform.googleapis.com/ml_use": "test"}}
{"imageGcsUri": "gs://bucket/filename2.gif",  "classificationAnnotation": {"displayName": "dandelion"}, "dataItemResourceLabels": {"aiplatform.googleapis.com/ml_use": "training"}}
{"imageGcsUri": "gs://bucket/filename3.png",  "classificationAnnotation": {"displayName": "roses"}, "dataItemResourceLabels": {"aiplatform.googleapis.com/ml_use": "training"}}
{"imageGcsUri": "gs://bucket/filename4.bmp",  "classificationAnnotation": {"displayName": "sunflowers"}, "dataItemResourceLabels": {"aiplatform.googleapis.com/ml_use": "training"}}
{"imageGcsUri": "gs://bucket/filename5.tiff",  "classificationAnnotation": {"displayName": "tulips"}, "dataItemResourceLabels": {"aiplatform.googleapis.com/ml_use": "validation"}}
...

CSV

CSV 형식:

[ML_USE],GCS_FILE_PATH,[LABEL]
열 목록
  • ML_USE(선택사항) - 모델을 학습시킬 때 데이터 분할 목적으로 사용됩니다. TRAINING, TEST, VALIDATION이 사용됩니다. 수동 데이터 분할에 대한 자세한 내용은 AutoML 모델에 대한 데이터 분할 정보를 참조하세요.
  • GCS_FILE_PATH - 이 필드에는 이미지에 대한 Cloud Storage URI가 포함됩니다. Cloud Storage URI는 대소문자를 구분합니다.
  • LABEL(선택사항). 라벨은 문자로 시작해야 하며 문자, 숫자, 밑줄만 포함할 수 있습니다.

CSV 예시 - image_classification_single_label.csv:

test,gs://bucket/filename1.jpeg,daisy
training,gs://bucket/filename2.gif,dandelion
gs://bucket/filename3.png
gs://bucket/filename4.bmp,sunflowers
validation,gs://bucket/filename5.tiff,tulips
...
    

멀티 라벨 분류

데이터 요구사항

  • 학습 데이터: 모델을 학습시킬 때 다음과 같은 이미지 형식이 지원됩니다. Vertex AI API는 이렇게 가져온 이미지를 사전 처리한 후 모델을 학습시키는 데 사용되는 데이터로 제공합니다. 최대 파일 크기는 30MB입니다.
    • JPEG
    • GIF
    • PNG
    • BMP
    • ICO
  • 예측 데이터: 모델에서 예측을 요청 (쿼리)할 때 지원되는 이미지 형식은 다음과 같습니다. 최대 파일 크기는 1.5MB입니다.
    • JPEG
    • GIF
    • PNG
    • WEBP
    • BMP
    • TIFF
    • ICO

    AutoML 모델 학습에 사용되는 이미지 데이터를 위한 권장사항

    다음 권장사항은 AutoML을 사용하여 모델을 학습시키는 데이터 세트에 적용됩니다.

  • AutoML 모델은 현실의 물체를 찍은 사진에 최적화되어 있습니다.
  • 학습 데이터는 예측을 수행할 데이터와 최대한 유사해야 합니다. 예를 들어 사용 사례에 보안 카메라 영상처럼 흐릿한 저해상도 이미지가 포함되는 경우 흐릿한 저해상도 이미지로 학습 데이터를 구성해야 합니다. 또한 일반적으로 다양한 각도, 해상도, 배경으로 촬영한 학습 이미지를 제공하는 것이 좋습니다.
  • 인간이 지정할 수 없는 라벨은 Vertex AI 모델도 일반적으로 예측할 수 없습니다. 따라서 이미지를 1~2초 보고 라벨을 지정하도록 사람을 학습시킬 수 없다면 이 모델도 그렇게 하도록 학습시킬 수 없습니다.
  • 권장되는 학습 이미지 개수는 라벨당 1,000개입니다. 라벨당 최소 개수는 10개입니다. 이미지 하나에 라벨이 여러 개인 모델을 학습시키는 경우 일반적으로 라벨당 필요한 예의 수가 늘어나며, 결과 점수를 해석하기도 어려워집니다.
  • 가장 흔한 라벨의 이미지가 가장 흔하지 않은 라벨의 이미지보다 최대 100배 많을 때 모델 효과가 가장 뛰어납니다. 빈도가 극히 낮은 라벨은 삭제하는 것이 좋습니다.
  • 정의된 라벨 중 어느 것과도 일치하지 않는 None_of_the_above 라벨과 이미지를 포함하면 유용합니다. 예를 들어 꽃 데이터 세트의 경우 라벨을 지정한 품종에 속하지 않는 꽃의 이미지를 포함하고 None_of_the_above 라벨을 붙입니다.

YAML 스키마 파일

공개적으로 액세스할 수 있는 다음 스키마 파일을 사용하여 멀티 라벨 이미지 분류 주석을 가져옵니다. 이 스키마 파일은 데이터 입력 파일의 형식을 지정합니다. 이 파일의 구조는 OpenAPI 스키마를 따릅니다.

gs://google-cloud-aiplatform/schema/dataset/ioformat/image_classification_multi_label_io_format_1.0.0.yaml

전체 스키마 파일

title: ImageClassificationMultiLabel
description: >
 Import and export format for importing/exporting images together with
 multi-label classification annotations. Can be used in
 Dataset.import_schema_uri field.
type: object
required:
- imageGcsUri
properties:
 imageGcsUri:
   type: string
   description: >
     A Cloud Storage URI pointing to an image. Up to 30MB in size.
     Supported file mime types: `image/jpeg`, `image/gif`, `image/png`,
     `image/webp`, `image/bmp`, `image/tiff`, `image/vnd.microsoft.icon`.
 classificationAnnotations:
   type: array
   description: Multiple classification Annotations on the image.
   items:
     type: object
     description: Classification annotation.
     properties:
       displayName:
         type: string
         description: >
           It will be imported as/exported from AnnotationSpec's display name,
           i.e. the name of the label/class.
       annotationResourceLabels:
         description: Resource labels on the Annotation.
         type: object
         additionalProperties:
           type: string
 dataItemResourceLabels:
   description: Resource labels on the DataItem.
   type: object
   additionalProperties:
     type: string

입력 파일

JSON Lines

각 행의 JSON:


{
  "imageGcsUri": "gs://bucket/filename.ext",
  "classificationAnnotations": [
    {
      "displayName": "LABEL1",
      "annotationResourceLabels": {
        "aiplatform.googleapis.com/annotation_set_name":"displayName",
        "label_type": "flower_type"
      }
    },
    {
      "displayName": "LABEL2",
      "annotationResourceLabels": {
        "aiplatform.googleapis.com/annotation_set_name":"displayName",
        "label_type": "image_shot_type"
      }
    }
  ],
  "dataItemResourceLabels": {
    "aiplatform.googleapis.com/ml_use": "training/test/validation"
  }
}

필드 참고사항:

  • imageGcsUri - 유일한 필수 필드입니다.
  • annotationResourceLabels - 키-값 문자열 쌍을 포함할 수 있습니다. 시스템에 예약된 유일한 키-값 쌍은 다음과 같습니다.
    • 'aiplatform.googleapis.com/annotation_set_name': 'value'

    여기서 value는 데이터 세트에 있는 기존 주석 집합의 표시 이름 중 하나입니다.

  • dataItemResourceLabels - 키-값 문자열 쌍을 포함할 수 있습니다. 시스템에서 예약할 수 있는 유일한 키-값 쌍은 다음과 같이 데이터 항목의 머신러닝 사용 세트를 지정합니다.
    • 'aiplatform.googleapis.com/ml_use': 'training/test/validation'

JSON Lines 예시 - image_classification_multi_label.jsonl:


{"imageGcsUri": "gs://bucket/filename1.jpeg",  "classificationAnnotations": [{"displayName": "daisy"}, {"displayName": "full_shot"}], "dataItemResourceLabels": {"aiplatform.googleapis.com/ml_use": "test"}}
{"imageGcsUri": "gs://bucket/filename2.gif",  "classificationAnnotations": [{"displayName": "dandelion"}, {"displayName": "medium_shot"}], "dataItemResourceLabels": {"aiplatform.googleapis.com/ml_use": "training"}}
{"imageGcsUri": "gs://bucket/filename3.png",  "classificationAnnotations": [{"displayName": "roses"}, {"displayName": "extreme_closeup"}], "dataItemResourceLabels": {"aiplatform.googleapis.com/ml_use": "training"}}
{"imageGcsUri": "gs://bucket/filename4.bmp",  "classificationAnnotations": [{"displayName": "sunflowers"}, {"displayName": "closeup"}], "dataItemResourceLabels": {"aiplatform.googleapis.com/ml_use": "training"}}
{"imageGcsUri": "gs://bucket/filename5.tiff",  "classificationAnnotations": [{"displayName": "tulips"}, {"displayName": "extreme_closeup"}], "dataItemResourceLabels": {"aiplatform.googleapis.com/ml_use": "validation"}}
...

CSV

CSV 형식:

[ML_USE],GCS_FILE_PATH,[LABEL1,LABEL2,...LABELn]
열 목록
  • ML_USE(선택사항) - 모델을 학습시킬 때 데이터 분할 목적으로 사용됩니다. TRAINING, TEST, VALIDATION이 사용됩니다. 수동 데이터 분할에 대한 자세한 내용은 AutoML 모델에 대한 데이터 분할 정보를 참조하세요.
  • GCS_FILE_PATH - 이 필드에는 이미지에 대한 Cloud Storage URI가 포함됩니다. Cloud Storage URI는 대소문자를 구분합니다.
  • LABEL(선택사항). 라벨은 문자로 시작해야 하며 문자, 숫자, 밑줄만 포함할 수 있습니다.

CSV 예시 - image_classification_multi_label.csv:

test,gs://bucket/filename1.jpeg,daisy,full_shot
training,gs://bucket/filename2.gif,dandelion,medium_shot
gs://bucket/filename3.png
gs://bucket/filename4.bmp,sunflowers,closeup
validation,gs://bucket/filename5.tiff,tulips,extreme_closeup
...