選取您的 Cookie 偏好設定

我們使用提供自身網站和服務所需的基本 Cookie 和類似工具。我們使用效能 Cookie 收集匿名統計資料,以便了解客戶如何使用我們的網站並進行改進。基本 Cookie 無法停用,但可以按一下「自訂」或「拒絕」以拒絕效能 Cookie。

如果您同意,AWS 與經核准的第三方也會使用 Cookie 提供實用的網站功能、記住您的偏好設定,並顯示相關內容,包括相關廣告。若要接受或拒絕所有非必要 Cookie,請按一下「接受」或「拒絕」。若要進行更詳細的選擇,請按一下「自訂」。

建立映像分類任務 (單一標籤)

焦點模式
建立映像分類任務 (單一標籤) - Amazon SageMaker AI

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

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

需要工作者使用您指定的預先定義標籤來分類影像時,請使用 Amazon SageMaker Ground Truth 影像分類標籤任務。系統會向工作者顯示影像,並要求工作者為各個影像逐一選擇標籤。您可以使用 Amazon SageMaker AI 主控台的 Ground Truth 區段或 CreateLabelingJob操作來建立映像分類標籤工作。

重要

對於此任務類型,如果您建立自己的資訊清單檔案,請使用 "source-ref" 來識別您要在 Amazon S3 中標籤的每個影像檔案位置。如需詳細資訊,請參閱輸入資料

建立影像分類標籤工作 (主控台)

您可以依照指示建立標籤工作 (主控台),了解如何在 SageMaker AI 主控台中建立影像分類標籤工作。在步驟 10 中,從任務類別下拉式清單中選擇影像,然後選擇影像分類 (單一標籤)做為任務類型。

Ground Truth 提供類似下列標籤任務的工作者使用者介面。使用主控台建立標籤工作時,您可以指定指示以協助工作者完成工作,以及工作者可以選擇的標籤。

Ground Truth 提供的標記任務的工作者 UI 範例。

建立影像分類標籤工作 (API)

若要建立影像分類標籤工作,請使用 SageMaker API 作業 CreateLabelingJob。此 API 會定義 AWS SDKs此操作。若要查看這項作業支援的特定語言 SDK 清單,請參閱 CreateLabelingJob另請參閱一節。

設定請求時,請遵循建立標籤工作 (API)上的指示並執行下列動作:

  • 此任務類型的註釋前 Lambda 函式會以 PRE-ImageMultiClass 結尾。若要尋找您區域的註釋前 Lambda ARN,請參閱 PreHumanTaskLambdaArn

  • 此任務類型的註釋合併 Lambda 函式會以 ACS-ImageMultiClass 結尾。若要尋找您區域的註釋合併 Lambda ARN,請參閱 AnnotationConsolidationLambdaArn

下列是用 AWS Python SDK (Boto3) 請求,在美國東部 (維吉尼亞北部) 區域建立標籤工作的範例。所有以紅色標示的參數都應該用您的規格和資源加以取代。

response = client.create_labeling_job( LabelingJobName='example-image-classification-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-ImageMultiClass, 'TaskKeywords': [ Image classification', ], 'TaskTitle': Image classification task', 'TaskDescription': 'Carefully inspect the image and classify it by selecting one label from the categories provided.', 'NumberOfHumanWorkersPerDataObject': 123, 'TaskTimeLimitInSeconds': 123, 'TaskAvailabilityLifetimeInSeconds': 123, 'MaxConcurrentTaskCount': 123, 'AnnotationConsolidationConfig': { 'AnnotationConsolidationLambdaArn': 'arn:aws:lambda:us-east-1:432418664414:function:ACS-ImageMultiClass' }, Tags=[ { 'Key': 'string', 'Value': 'string' }, ] )

提供影像分類標籤工作的範本

如果您使用 API 來建立標籤工作,則必須在 UiTemplateS3Uri 中提供工作者任務範本。複製並修改下列範本。僅修改 short-instructionsfull-instructionsheader

將此範本上傳至 S3,並在 UiTemplateS3Uri 中提供此檔案的 S3 URI。

<script src="https://assets.crowd.aws/crowd-html-elements.js"></script> <crowd-form> <crowd-image-classifier name="crowd-image-classifier" src="{{ task.input.taskObject | grant_read_access }}" header="please classify" categories="{{ task.input.labels | to_json | escape }}" > <full-instructions header="Image classification instructions"> <ol><li><strong>Read</strong> the task carefully and inspect the image.</li> <li><strong>Read</strong> the options and review the examples provided to understand more about the labels.</li> <li><strong>Choose</strong> the appropriate label that best suits the image.</li></ol> </full-instructions> <short-instructions> <h3><span style="color: rgb(0, 138, 0);">Good example</span></h3> <p>Enter description to explain the correct label to the workers</p> <h3><span style="color: rgb(230, 0, 0);">Bad example</span></h3><p>Enter description of an incorrect label</p> </short-instructions> </crowd-image-classifier> </crowd-form>

影像分類輸出資料

建立影像分類標籤工作後,您的輸出資料會位於使用 API 時在 S3OutputPath 參數中指定的 Amazon S3 儲存貯體中,或在主控台工作概觀區段的輸出資料集位置中。

若要進一步了解 Ground Truth 產生的輸出資訊清單檔案,以及 Ground Truth 用來儲存輸出資料的檔案結構,請參閱標記任務輸出資料

若要檢視影像分類標籤工作的輸出資訊清單檔案範例,請參閱分類任務輸出

隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。