

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在資訊清單檔案中匯入影像層級標籤
<a name="md-create-manifest-file-classification"></a>

若要匯入影像層級標籤 （標記為不需要當地語系化資訊的場景、概念或物件的影像），請將 SageMaker AI Ground Truth [分類任務輸出](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-data-output.html#sms-output-class)格式 JSON 行新增至資訊清單檔案。清單檔案由一個或多個 JSON Lines 組成，每個要匯入的影像都有一個。

**提示**  
為了簡化清單檔案的建立，我們會提供 Python 指令碼，用於從 CSV 檔案建立清單檔案。如需詳細資訊，請參閱[從 CSV 檔案建立清單檔案。](ex-csv-manifest.md)。

**建立影像層級標籤的清單檔案**

1. 建立空白文字檔案。

1. 針對要匯入的每個影像新增 JSON Line。每個 JSON Line 應該看起來類似下列內容。

   ```
   {"source-ref":"s3://custom-labels-console-us-east-1-nnnnnnnnnn/gt-job/manifest/IMG_1133.png","TestCLConsoleBucket":0,"TestCLConsoleBucket-metadata":{"confidence":0.95,"job-name":"labeling-job/testclconsolebucket","class-name":"Echo Dot","human-annotated":"yes","creation-date":"2020-04-15T20:17:23.433061","type":"groundtruth/image-classification"}}
   ```

1. 儲存檔案。您可以使用副檔名 `.manifest`，但這不是必要的。

1. 使用您建立的清單檔案建立資料集。如需詳細資訊，請參閱[使用 SageMaker AI Ground Truth 格式資訊清單檔案 （主控台） 建立資料集](md-create-manifest-file.md#create-dataset-procedure-manifest-file)。

 

## 影像層級 JSON Lines
<a name="md-manifest-classification-json"></a>

在本區段中，我們會說明如何為單一影像建立 JSON Line。考慮下列影像。下列影像的場景可能稱為 *Sunrise*。

![\[日落在湖上，有碼頭和小船，被山環繞。\]](http://docs.aws.amazon.com/zh_tw/rekognition/latest/customlabels-dg/images/sunrise.png)


上一個影像 (具有場景 *Sunrise*) 的 JSON Line 可能如下所示。

```
{
    "source-ref": "s3://bucket/images/sunrise.png",
    "testdataset-classification_Sunrise": 1,
    "testdataset-classification_Sunrise-metadata": {
        "confidence": 1,
        "job-name": "labeling-job/testdataset-classification_Sunrise",
        "class-name": "Sunrise",
        "human-annotated": "yes",
        "creation-date": "2020-03-06T17:46:39.176",
        "type": "groundtruth/image-classification"
    }
}
```

記下以下資訊。

### source-ref
<a name="w2aac20c17c25c27c19c11c13"></a>

(必要) 影像的 Amazon S3 位置。格式是 `"s3://BUCKET/OBJECT_PATH"`。匯入資料集中的影像必須存放在同一個 Amazon S3 儲存貯體中。

### *testdataset-classification\$1Sunrise*
<a name="w2aac20c17c25c27c19c11c15"></a>

(必要) 屬性標籤。您可以選擇欄位名稱。欄位值 (前面範例中為 1) 為標籤屬性識別碼。Amazon Rekognition 自訂標籤不會使用，而且可以是任何整數值。必須有由欄位名稱識別的對應中繼資料，並附加了 *-metadata*。例如 `"testdataset-classification_Sunrise-metadata"`。

### *testdataset-classification\$1Sunrise*-metadata
<a name="w2aac20c17c25c27c19c11c17"></a>

(必要) 有關標籤屬性的中繼資料。欄位名稱必須與附加了 *-metadata* 的標籤屬性相同。

*信賴度*  
(必要) Amazon Rekognition 自訂標籤目前未使用，但必須提供介於 0 到 1 之間的值。

*job-name*  
(選用) 您為處理影像的任務選擇的名稱。

*class-name*  
(必要) 您為套用至影像的場景或概念選擇的類別名稱。例如 `"Sunrise"`。

*human-annotated*  
(必要) 如果註釋由人類完成，則指定 `"yes"`。否則為 `"no"`。

*creation-date*   
(必要) 建立標籤時的國際標準時間 (UTC) 日期和時間。

*type*  
(必要) 應套用至影像的處理類型。若為影像層級標籤，值為 `"groundtruth/image-classification"`。

### 對影像新增多個影像層級標籤
<a name="md-dataset-purpose-classification-multiple-labels"></a>

您可以對影像新增多個標籤。例如，下面的 JSON 對單一影像新增了兩個標籤，即 *football* 和 *ball*。

```
{
    "source-ref": "S3 bucket location", 
    "sport0":0, # FIRST label
    "sport0-metadata": { 
        "class-name": "football", 
        "confidence": 0.8, 
        "type":"groundtruth/image-classification", 
        "job-name": "identify-sport", 
        "human-annotated": "yes", 
        "creation-date": "2018-10-18T22:18:13.527256" 
    },
    "sport1":1, # SECOND label
    "sport1-metadata": { 
        "class-name": "ball", 
        "confidence": 0.8, 
        "type":"groundtruth/image-classification", 
        "job-name": "identify-sport", 
        "human-annotated": "yes", 
        "creation-date": "2018-10-18T22:18:13.527256" 
    }
}  # end of annotations for 1 image
```