图像语义分割 - Amazon SageMaker
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

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

图像语义分割

要在像素级别识别图像内容,请使用 Amazon G SageMaker round Truth 语义分割标签任务。在分配语义分割标注作业时,工作人员会将图像中的像素分类为一组预定义的标签或类。Ground Truth 支持单类和多类语义分割标注作业。

您可以使用亚马逊 SageMaker控制台的 Ground Truth 部分或CreateLabelingJob操作创建语义分段标签作业。

重要

对于此任务类型,如果您创建自己的清单文件,请使用 "source-ref" 识别 Amazon S3 中您要标注的每个图像文件的位置。有关更多信息,请参阅输入数据

创建语义分割标注作业(控制台)

您可以按照说明学习创建标注作业(控制台)如何在 SageMaker 控制台中创建语义分段标注作业。在步骤 10 中,从任务类别下拉菜单中选择图像,然后选择语义分割作为任务类型。

Ground Truth 为标注任务提供类似于以下内容的工作人员 UI。使用控制台创建标注作业时,需要指定说明,以便于工作人员完成工作人员可以从中选择的作业和标签。

创建语义分割标注作业 (API)

要创建语义分割标注作业,请使用 SageMaker API 操作CreateLabelingJob。此 API 为所有 Amazon SDK 定义了此操作。要查看此操作支持的特定于语言的 SDK 列表,请查看 CreateLabelingJob另请参阅部分。

请按照创建标注作业 (API)中的说明进行操作,并在配置请求时执行以下操作:

  • 此任务类型的注释前 Lambda 函数以 PRE-SemanticSegmentation 结尾。要查找您所在地区的预注释 Lambda ARN,请参阅。PreHumanTaskLambdaArn

  • 此任务类型的注释合并 Lambda 函数以 ACS-SemanticSegmentation 结尾。要查找您所在地区的注释合并 Lambda ARN,请参阅。AnnotationConsolidationLambdaArn

以下是一个 Amazon Python SDK (Boto3) 请求示例,该请求在美国东部(弗吉尼亚州北部)区域中创建标注作业。所有红色参数都应替换为您的规范和资源。

response = client.create_labeling_job( LabelingJobName='example-semantic-segmentation-labeling-job, LabelAttributeName='label', InputConfig={ 'DataSource': { 'S3DataSource': { 'ManifestS3Uri': 's3://bucket/path/manifest-with-input-data.json' } }, 'DataAttributes': { 'ContentClassifiers': [ 'FreeOfPersonallyIdentifiableInformation'|'FreeOfAdultContent', ] } }, OutputConfig={ 'S3OutputPath': 's3://bucket/path/file-to-store-output-data', 'KmsKeyId': 'string' }, RoleArn='arn:aws:iam::*:role/*, LabelCategoryConfigS3Uri='s3://bucket/path/label-categories.json', StoppingConditions={ 'MaxHumanLabeledObjectCount': 123, 'MaxPercentageOfInputDatasetLabeled': 123 }, HumanTaskConfig={ 'WorkteamArn': 'arn:aws:sagemaker:region:*:workteam/private-crowd/*', 'UiConfig': { 'UiTemplateS3Uri': 's3://bucket/path/worker-task-template.html' }, 'PreHumanTaskLambdaArn': 'arn:aws:lambda:us-east-1:432418664414:function:PRE-SemanticSegmentation, 'TaskKeywords': [ 'Semantic Segmentation', ], 'TaskTitle': 'Semantic segmentation task', 'TaskDescription': 'For each category provided, segment out each relevant object using the color associated with that category', 'NumberOfHumanWorkersPerDataObject': 123, 'TaskTimeLimitInSeconds': 123, 'TaskAvailabilityLifetimeInSeconds': 123, 'MaxConcurrentTaskCount': 123, 'AnnotationConsolidationConfig': { 'AnnotationConsolidationLambdaArn': 'arn:aws:lambda:us-east-1:432418664414:function:ACS-SemanticSegmentation' }, Tags=[ { 'Key': 'string', 'Value': 'string' }, ] )

为语义分割标注作业提供模板

如果要使用 API 创建标注作业,必须在 UiTemplateS3Uri 中提供工作人员任务模板。复制并修改以下模板。仅修改 short-instructionsfull-instructionsheader

将此模板上传到 S3,并在 UiTemplateS3Uri 中为此文件提供 S3 URI。

语义分割输出数据

创建语义分割标注作业后,输出数据将位于使用 API 时在 S3OutputPath 参数中指定的 Amazon S3 存储桶中,或控制台的作业概览部分的输出数据集位置字段中。

要了解有关 Ground Truth 生成的输出清单文件以及 Ground Truth 用来存储输出数据的文件结构的更多信息,请参阅输出数据

要查看语义分割标注作业的输出清单文件示例,请参阅3D 点云语义分割输出