

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 带有标签类别和框架属性参考的标注类别配置文件
<a name="sms-label-cat-config-attributes"></a>

使用 Amazon SageMaker API 操作创建 3D 点云或视频帧标注任务时`CreateLabelingJob`，您可以使用标签类别配置文件来指定标签和工作指令。您也可以选择在标签类别属性文件中提供以下内容：
+ 您可以为视频帧和 3D 点云对象跟踪和对象检测任务类型提供*标签类别属性*。工作人员可以使用一个或多个属性来提供有关对象的更多信息。例如，您可能希望使用 *occluded* 属性，以使工作人员确定对象何时被部分遮挡。您可以使用 `categoryAttributes` 参数为单个标签指定标签类别属性，或者使用 `categoryGlobalAttributes` 参数为所有标签指定标签类别属性。
+ 您可以使用 `frameAttributes` 为视频帧和 3D 点云对象跟踪和对象检测任务类型提供*帧属性*。创建帧属性时，该属性会出现在工作人员任务中的每个帧或点云上。在视频帧标注作业中，这些属性是工作人员分配给整个视频帧的属性。对于 3D 点云标注作业，这些属性应用于单个点云。使用帧属性可让工作人员提供特定帧或点云中场景的更多信息。
+ 对于视频帧标注作业，可以使用标签类别配置文件指定发送给工作人员的任务类型（边界框、折线、多边形或关键点）。

工作人员可以选择性地为标签类别属性和帧属性指定值。

**重要**  
只有在运行审核作业以验证或调整标签时，您才应在 `auditLabelAttributeName` 中提供标签属性名称。使用此参数输入标注作业中[LabelAttributeName](https://docs.amazonaws.cn/sagemaker/latest/APIReference/API_CreateLabelingJob.html#sagemaker-CreateLabelingJob-request-LabelAttributeName)使用的，该作业生成了您希望工作人员调整的注释。在控制台中创建标签任务时，如果您未指定标签属性名称，则您的任务**名称**将用作 LabelAttributeName。

以下主题显示了不同类型标注作业的标签类别配置文件示例。它们还解释了类别配置文件的架构和配额。

**Topics**
+ [示例：3D 点云标注作业的标签类别配置文件](#sms-label-cat-config-attributes-3d-pc)
+ [示例：视频帧标注作业的标签类别配置文件](#sms-label-cat-config-attributes-vid-frame)
+ [标签类别配置文件架构](#sms-label-cat-config-attributes-schema)
+ [标签和标签类别属性限额](#sms-point-cloud-label-cat-limits)

## 示例：3D 点云标注作业的标签类别配置文件
<a name="sms-label-cat-config-attributes-3d-pc"></a>

以下主题显示了对象检测、对象跟踪、语义分割、调整和验证标注作业的 3D 点云标签类别配置文件的示例。

**Topics**
+ [示例：3D 点云对象跟踪和对象检测](#example-3d-point-cloud-object)
+ [示例：3D 点云语义分割](#example-3d-point-cloud-semantic)
+ [示例：3D 点云调整](#example-3d-point-cloud-adjustment)
+ [示例：3D 点云验证](#example-3d-point-cloud-verification)

### 示例：3D 点云对象跟踪和对象检测
<a name="example-3d-point-cloud-object"></a>

下面是一个标签类别配置文件示例，其中包含 3D 点云对象检测或对象跟踪标注作业的标签类别属性。此示例包括两个帧属性，这些属性将添加到提交给标注作业的所有点云中。`Car` 标签将包括四个标签类别属性 – `X`、`Y`、`Z` 和全局属性 `W`。

```
{
    "documentVersion": "2020-03-01",
    "frameAttributes": [
        {
            "name":"count players",
            "description":"How many players to you see in the scene?",
            "type":"number"
        },
        {
            "name":"select one",
            "description":"describe the scene",
            "type":"string",
            "enum":["clear","blurry"],
            "isRequired":true 
        },   
    ],
    "categoryGlobalAttributes": [
        {
            "name":"W",
            "description":"label-attributes-for-all-labels",
            "type":"string",
            "enum": ["foo", "buzz", "biz"]
        }
    ],
    "labels": [
        {
            "label": "Car",
            "categoryAttributes": [
                {
                    "name":"X",
                    "description":"enter a number",
                    "type":"number",
                },
                {
                    "name":"Y",
                    "description":"select an option",
                    "type":"string",
                    "enum":["y1", "y2"]
                },
                {
                    "name":"Z",
                    "description":"submit a free-form response",
                    "type":"string",
                }
            ]
        },
        {
            "label": "Pedestrian",
            "categoryAttributes": [...]
        }
    ],
    "instructions": {"shortInstruction":"Draw a tight Cuboid", "fullInstruction":"<html markup>"}
}
```

### 示例：3D 点云语义分割
<a name="example-3d-point-cloud-semantic"></a>

下面是 3D 点云语义分割标注作业的标签类别配置文件示例。

3D 点云语义分割任务类型不支持标签类别属性。支持帧属性。如果您为语义分割标注作业提供标签类别属性，将忽略这些属性。

```
{
    "documentVersion": "2020-03-01",
    "frameAttributes": [
        {
            "name":"count players",
            "description":"How many players to you see in the scene?",
            "type":"number"
        },
        {
            "name":"select one",
            "description":"describe the scene",
            "type":"string",
            "enum":["clear","blurry"]
        },   
    ],
    "labels": [
        {
            "label": "Car",
        },
        {
            "label": "Pedestrian",
        },
        {
            "label": "Cyclist",
        }
    ],
    "instructions": {"shortInstruction":"Select the appropriate label and paint all objects in the point cloud that it applies to the same color", "fullInstruction":"<html markup>"}
}
```

### 示例：3D 点云调整
<a name="example-3d-point-cloud-adjustment"></a>

以下是用于 3D 点云对象检测或对象跟踪调整标注作业的标签类别配置文件示例。对于 3D 点云语义分割调整标注作业，不支持 `categoryGlobalAttributes` 和 `categoryAttributes`。

必须包括 `auditLabelAttributeName` 以指定用于创建调整标注作业的前一个标注作业的标签属性名称。也可以选择使用 `editsAllowed` 参数来指定是否可以编辑标签或帧属性。

```
{
    "documentVersion": "2020-03-01",
    "frameAttributes": [
        {
            "name":"count players",
            "description":"How many players to you see in the scene?",
            "type":"number"
        },
        {
            "name":"select one",
            "editsAllowed":"none",
            "description":"describe the scene",
            "type":"string",
            "enum":["clear","blurry"]
        },   
    ],
    "categoryGlobalAttributes": [
        {
            "name":"W",
            "editsAllowed":"any",
            "description":"label-attributes-for-all-labels",
            "type":"string",
            "enum": ["foo", "buzz", "biz"]
        }
    ],
    "labels": [
        {
            "label": "Car",
            "editsAllowed":"any",
            "categoryAttributes": [
                {
                    "name":"X",
                    "description":"enter a number",
                    "type":"number"
                },
                {
                    "name":"Y",
                    "description":"select an option",
                    "type":"string",
                    "enum":["y1", "y2"],
                    "editsAllowed":"any"
                },
                {
                    "name":"Z",
                    "description":"submit a free-form response",
                    "type":"string",
                    "editsAllowed":"none"
                }
            ]
        },
        {
            "label": "Pedestrian",
            "categoryAttributes": [...]
        }
    ],
    "instructions": {"shortInstruction":"Draw a tight Cuboid", "fullInstruction":"<html markup>"},
    // include auditLabelAttributeName for label adjustment jobs
    "auditLabelAttributeName": "myPrevJobLabelAttributeName"
}
```

### 示例：3D 点云验证
<a name="example-3d-point-cloud-verification"></a>

以下是可用于 3D 点云对象检测或对象跟踪验证标注作业的标签类别配置文件示例。对于 3D 点云语义分割验证标注作业，不支持 `categoryGlobalAttributes` 和 `categoryAttributes`。

必须包括 `auditLabelAttributeName` 以指定用于创建验证标注作业的前一个标注作业的标签属性名称。此外，必须使用 `editsAllowed` 参数以指定不能编辑任何标签。

```
{
    "documentVersion": "2020-03-01",
    "frameAttributes": [
        {
            "name":"count players",
            "editsAllowed":"any", 
            "description":"How many players to you see in the scene?",
            "type":"number"
        },
        {
            "name":"select one",
            "editsAllowed":"any", 
            "description":"describe the scene",
            "type":"string",
            "enum":["clear","blurry"]
        },   
    ],
    "categoryGlobalAttributes": [
        {
            "name":"W",
            "editsAllowed":"none", 
            "description":"label-attributes-for-all-labels",
            "type":"string",
            "enum": ["foo", "buzz", "biz"]
        }
    ],
    "labels": [
        {
            "label": "Car",
            "editsAllowed":"none", 
            "categoryAttributes": [
                {
                    "name":"X",
                    "description":"enter a number",
                    "type":"number",
                    "editsAllowed":"none"
                },
                {
                    "name":"Y",
                    "description":"select an option",
                    "type":"string",
                    "enum":["y1", "y2"],
                    "editsAllowed":"any"
                },
                {
                    "name":"Z",
                    "description":"submit a free-form response",
                    "type":"string",
                    "editsAllowed":"none"
                }
            ]
        },
        {
            "label": "Pedestrian",
            "editsAllowed":"none", 
            "categoryAttributes": [...]
        }
    ],
    "instructions": {"shortInstruction":"Draw a tight Cuboid", "fullInstruction":"<html markup>"},
    // include auditLabelAttributeName for label verification jobs
    "auditLabelAttributeName": "myPrevJobLabelAttributeName"
}
```

## 示例：视频帧标注作业的标签类别配置文件
<a name="sms-label-cat-config-attributes-vid-frame"></a>

工作人员可用的注释工具和使用的任务类型取决于您为 `annotationType` 指定的值。例如，如果希望工作人员使用关键点来跟踪多个帧中特定对象姿势的变化，则应该为 `annotationType` 指定 `Keypoint`。如果未指定注释类型，则默认情况下将使用 `BoundingBox`。

以下主题显示了视频帧类别配置文件的示例。

**Topics**
+ [示例：视频帧关键点](#example-video-frame-keypoint)
+ [示例：视频帧调整](#example-video-frame-adjustment)
+ [示例：视频帧验证](#example-video-frame-verification)

### 示例：视频帧关键点
<a name="example-video-frame-keypoint"></a>

下面是一个带有标签类别属性的视频帧关键点标签类别配置文件示例。此示例包括两个帧属性，这两个属性将添加到提交给标注作业的所有帧中。`Car` 标签将包括四个标签类别属性 – `X`、`Y`、`Z` 和全局属性 `W`。

```
{
    "documentVersion": "2020-03-01",
    "frameAttributes": [
        {
            "name":"count players",
            "description":"How many players to you see in the scene?",
            "type":"number"
        },
        {
            "name":"select one",
            "description":"describe the scene",
            "type":"string",
            "enum":["clear","blurry"]
        },   
    ],
    "categoryGlobalAttributes": [
        {
            "name":"W",
            "description":"label-attributes-for-all-labels",
            "type":"string",
            "enum": ["foo", "buz", "buz2"]
        }
    ],
    "labels": [
        {
            "label": "Car",
            "categoryAttributes": [
                {
                    "name":"X",
                    "description":"enter a number",
                    "type":"number",
                },
                {
                    "name":"Y",
                    "description":"select an option",
                    "type":"string",
                    "enum": ["y1", "y2"]
                },
                {
                    "name":"Z",
                    "description":"submit a free-form response",
                    "type":"string",
                }
            ]
        },
        {
            "label": "Pedestrian",
            "categoryAttributes": [...]
        }
    ],
    "annotationType":"Keypoint",
    "instructions": {"shortInstruction":"add example short instructions here", "fullInstruction":"<html markup>"}
}
```

### 示例：视频帧调整
<a name="example-video-frame-adjustment"></a>

以下是可用于视频帧调整标注作业的标签类别配置文件示例。

必须包括 `auditLabelAttributeName` 以指定用于创建验证标注作业的前一个标注作业的标签属性名称。也可以选择使用 `editsAllowed` 参数来指定是否可以编辑标签、标签类别属性或帧属性。

```
{
    "documentVersion": "2020-03-01",
    "frameAttributes": [
        {
            "name":"count players",
            "editsAllowed":"none", 
            "description":"How many players to you see in the scene?",
            "type":"number"
        },
        {
            "name":"select one",
            "description":"describe the scene",
            "type":"string",
            "enum":["clear","blurry"]
        },   
    ],
    "categoryGlobalAttributes": [
        {
            "name":"W",
            "editsAllowed":"any", 
            "description":"label-attributes-for-all-labels",
            "type":"string",
            "enum": ["foo", "buz", "buz2"]
        }
    ],
    "labels": [
        {
            "label": "Car",
            "editsAllowed":"any", 
            "categoryAttributes": [
                {
                    "name":"X",
                    "description":"enter a number",
                    "type":"number",
                    "editsAllowed":"any"
                },
                {
                    "name":"Y",
                    "description":"select an option",
                    "type":"string",
                    "enum": ["y1", "y2"],
                    "editsAllowed":"any"
                },
                {
                    "name":"Z",
                    "description":"submit a free-form response",
                    "type":"string",
                    "editsAllowed":"none"
                }
            ]
        },
        {
            "label": "Pedestrian",
            "editsAllowed":"none", 
            "categoryAttributes": [...]
        }
    ],
    "annotationType":"Keypoint",
    "instructions": {"shortInstruction":"add example short instructions here", "fullInstruction":"<html markup>"},
    // include auditLabelAttributeName for label adjustment jobs
    "auditLabelAttributeName": "myPrevJobLabelAttributeName"
}
```

### 示例：视频帧验证
<a name="example-video-frame-verification"></a>

以下是视频帧标注作业的标签类别配置文件示例。

必须包括 `auditLabelAttributeName` 以指定用于创建验证标注作业的前一个标注作业的标签属性名称。此外，必须使用 `editsAllowed` 参数以指定不能编辑任何标签。

```
{
    "documentVersion": "2020-03-01",
    "frameAttributes": [
        {
            "name":"count players",
            "editsAllowed":"none", 
            "description":"How many players to you see in the scene?",
            "type":"number"
        },
        {
            "name":"select one",
            "editsAllowed":"any", 
            "description":"describe the scene",
            "type":"string",
            "enum":["clear","blurry"]
        },   
    ],
    "categoryGlobalAttributes": [
        {
            "name":"W",
            "editsAllowed":"none", 
            "description":"label-attributes-for-all-labels",
            "type":"string",
            "enum": ["foo", "buz", "buz2"]
        }
    ],
    "labels": [
        {
            "label": "Car",
            "editsAllowed":"none", 
            "categoryAttributes": [
                {
                    "name":"X",
                    "description":"enter a number",
                    "type":"number",
                    "editsAllowed":"any"
                },
                {
                    "name":"Y",
                    "description":"select an option",
                    "type":"string",
                    "enum": ["y1", "y2"],
                    "editsAllowed":"any"
                },
                {
                    "name":"Z",
                    "description":"submit a free-form response",
                    "type":"string",
                    "editsAllowed":"none"
                }
            ]
        },
        {
            "label": "Pedestrian",
            "editsAllowed":"none", 
            "categoryAttributes": [...]
        }
    ],
    "annotationType":"Keypoint",
    "instructions": {"shortInstruction":"add example short instructions here", "fullInstruction":"<html markup>"},
    // include auditLabelAttributeName for label adjustment jobs
    "auditLabelAttributeName": "myPrevJobLabelAttributeName"
}
```

## 标签类别配置文件架构
<a name="sms-label-cat-config-attributes-schema"></a>

下表列出了您可以或必须在标签类别配置文件中包含的元素。

**注意**  
仅视频帧标注作业支持 `annotationType` 参数。


****  

|  参数  |  必需  |  接受的值  |  说明  | 
| --- | --- | --- | --- | 
| frameAttributes |  否  |  JSON 对象列表。 **每个 JSON 对象中的必需参数：** `name`, `type`, `description` 如果 `type` 是 `"number"`，则 `minimum` 和 `maximum` 是必需的 **每个 JSON 对象中的可选参数：** `enum`, `editsAllowed`, `isRequired`  | 使用此参数可创建一个帧属性，该属性应用于标注作业中的所有帧或 3D 点云。有关更多信息，请参阅本节中的第三个表。 | 
| categoryGlobalAttributes |  否  |  JSON 对象列表。 **每个 JSON 对象中的必需参数：** `name`, `type` 如果 `type` 是 `"number"`，则 `minimum` 和 `maximum` 是必需的 **每个 JSON 对象中的可选参数：** `description`, `enum`, `editsAllowed`, `isRequired`   | 使用此参数可以创建应用于在 `labels` 中指定的所有标签的标签类别属性。有关更多信息，请参阅本节中的第三个表。 | 
| labels |  是  |  最多包含 30 个 JSON 对象的列表 **每个 JSON 对象中的必需参数：** `label` **每个 JSON 对象中的可选参数：** `categoryAttributes`, `editsAllowed`  |  使用此参数可以指定标签或类。为每个类添加一个 `label`。 要将标签类别属性添加到一个标签中，请将 `categoryAttributes` 添加到该标签中。 使用 `editsAllowed` 可指定是否可以在调整标注作业中编辑标签。对于验证标注作业，将 `editsAllowed` 设置为 `"none"`。 有关更多信息，请参阅下表。  | 
| annotationType（仅视频帧标注作业支持）  |  否   |  字符串 **接受的参数**： `BoundingBox`, `Polyline`, `Polygon`, `Keypoint` **默认值**： `BoundingBox`  |  使用此项可以指定视频帧标注作业的任务类型。例如，对于多边形视频帧对象检测任务，请选择 `Polygon`。 如果在创建视频帧标注作业时未指定 `annotationType`，Ground Truth 将默认使用 `BoundingBox`。  | 
| instructions |  否  | JSON 对象每个 JSON 对象中的必需参数：`"shortInstruction"`, `"fullInstruction"` |  使用此参数可以添加有助于工作人员完成任务的工作人员说明。有关工作人员说明的更多信息，请参阅[工作人员说明](sms-point-cloud-general-information.md#sms-point-cloud-worker-instructions-general)。 短说明必须少于 255 个字符，长说明必须少于 2048 个字符。 有关更多信息，请参阅 [创建说明页](sms-creating-instruction-pages.md)。  | 
| auditLabelAttributeName |  调整和验证任务类型所必需的  |  字符串  |  输入要调整标注的标注作业中[LabelAttributeName](https://docs.amazonaws.cn/sagemaker/latest/APIReference/API_CreateLabelingJob.html#sagemaker-CreateLabelingJob-request-LabelAttributeName)使用的。 仅当您正在为视频帧和 3D 点云对象检测、对象跟踪或 3D 点云语义分割创建调整作业时，才使用此参数。  | 

### 标签对象架构
<a name="sms-labels-schema"></a>

下表描述了创建 `Labels` 列表时可以使用和必须使用的参数。每个参数都应包含在 JSON 对象中。


****  

| 参数 | 必需 | 接受的值 | Description | 
| --- | --- | --- | --- | 
| label |  是  |  字符串  |  向工作人员显示的标签类别的名称。每个标签类别名称必须唯一。  | 
| categoryAttributes |  否  |  JSON 对象列表。 **每个 JSON 对象中的必需参数：** `name`, `type` 如果 `type` 是 `"number"`，则 `minimum` 和 `maximum` 是必需的 **每个 JSON 对象中的可选参数：** `description`, `enum`, `editsAllowed`, `isRequired`  | 使用此参数可以将标签类别属性添加到在 `labels` 中指定的特定标签。要向标签添加一个或多个标签类别属性，请将 `categoryAttributes` JSON 对象包含在与 `label` 相同的 `labels` JSON 对象中。有关更多信息，请参阅下表。 | 
| editsAllowed |  否  |  字符串 **支持的值**： `"none"`：不允许进行任何修改。 或者 `"any"`（默认）：允许所有修改。  |  指定工作人员是否可以编辑标签。 对于视频帧或 3D 点云*调整*标注作业，请将此参数添加到 `labels` 列表中的一个或多个 JSON 对象，以指定工作人员是否可以编辑标签。 对于 3D 点云和视频帧*验证*标注作业，请将此参数与值 `"none"` 一起添加到 `labels` 列表中的每个 JSON 对象。这将使所有标签都不可编辑。  | 

### 框架属性和 categoryGlobalAttributes 架构
<a name="sms-category-attributes-schema"></a>

下表描述了使用 `frameAttributes` 创建帧属性时以及使用 `categoryGlobalAttributes` 和 `categoryAttributes` 参数创建标签类别属性时可以使用和必须使用的参数。


****  

|  参数  |  必需  |  接受的值  |  Description  | 
| --- | --- | --- | --- | 
| name |  是  |  字符串  |  使用此参数可以为标签类别或帧属性分配名称。这是工作人员看到的属性名称。 标签类别配置文件中的每个标签类别属性名称必须是唯一的。全局标签类别属性和特定于标签的标签类别属性不能具有相同的名称。  | 
| type |  是  |  字符串 **必需的值**： `"string"` 或 `"number"`  |  使用此参数可以定义标签类别或帧属性类型。 如果为 `type` 指定 `"string"` 并为此属性提供 `enum` 值，则工作人员将能够从您提供的选项中进行选择。 如果为 `type` 指定 `"string"` 但不提供 `enum` 值，则工作人员可以输入自由格式文本。 如果为 `type` 指定 `number`，则工作人员可以输入介于您指定的 `minimum` 和 `maximum` 之间的数字。  | 
| enum |  否  |  字符串列表  |  使用此参数可以定义工作人员可为此标签类别或帧属性选择的选项。工作人员可以选择在 `enum` 中指定的一个值。例如，如果为 `enum` 指定 `["foo", "buzz", "bar"`]，则工作人员可以选择 `foo`、`buzz` 或 `bar` 中的一个。 必须为 `type` 指定 `"string"` 才能使用 `enum` 列表。  | 
| description |  `frameAttributes`：是 `categoryAttributes` 或 `categoryGlobalAttributes`：否  |  字符串  |  使用此参数可以添加标签类别或帧属性的描述。您可以使用此字段向工作人员提供有关属性的更多信息。 只有帧属性才需要此字段。  | 
| minimum 和 maximum | 如果属性 type 为 "number"，则是必需的 | 整数 |  使用这些参数可以指定工作人员可为数值标签类别或帧属性输入的最小值和最大值（包括）。 必须为 `type` 指定 `"number"` 才能使用 `minimum` 和 `maximum`。  | 
| editsAllowed |  否  |  字符串 **必需的值**： `"none"`：不允许进行任何修改。 或者 `"any"`（默认）：允许所有修改。  |  指定工作人员是否可以编辑标签类别或帧属性。 对于视频帧或 3D 点云*调整*和*验证*标注作业，请将此参数添加到标签类别和帧属性 JSON 对象中，以指定工作人员是否可以编辑属性。  | 
| isRequired |  否  |  布尔值  |  指定是否需要工作人员对属性进行注释。在对所有必需的属性进行注释之前，工作人员无法提交作业。  | 

## 标签和标签类别属性限额
<a name="sms-point-cloud-label-cat-limits"></a>

您最多可以为每个类指定 10 个标签类别属性。这 10 个属性限额包括全局标签类别属性。例如，如果您创建 4 个全局标签类别属性，然后将三个标签类别属性分配给标签 `X`，则该标签总共具有 4\$13=7 个标签类别属性。有关所有标签类别和标签类别属性限制，请参阅下表。


****  

|  Type  |  最小值  |  最大值  | 
| --- | --- | --- | 
|  标签 (`Labels`)  |  1  |  30  | 
|  标签名称字符限额  |  1  |  16  | 
|  每个标签的标签类别属性（`categoryAttributes` 和 `categoryGlobalAttributes` 总和）  |  0  |  10  | 
|  每个标签的自由格式文本条目标签类别属性（`categoryAttributes` 和 `categoryGlobalAttributes` 总和）。  | 0 | 5 | 
|  帧属性  |  0  |  10  | 
|  `frameAttributes` 中的自由格式文本条目属性。  | 0 | 5 | 
|  属性名称字符限额 (`name`)  |  1  |  16  | 
|  属性描述字符限额 (`description`)  |  0  |  128  | 
|  属性类型字符限额 (`type`)  |  1  |  16  | 
|  `string` 属性的 `enum` 列表中允许的值  | 1 | 10 | 
|  `enum` 列表中某个值的字符限额  | 1 | 16 | 
| 自由格式文本 frameAttributes 的自由格式文本响应中的最大字符数 | 0 | 1000 | 
| 自由格式文本 categoryAttributes 和 categoryGlobalAttributes 的自由格式文本响应中的最大字符数 | 0 | 80 | 