New user sign up using AWS Builder ID
New user sign up using AWS Builder ID is currently unavailable on re:Post. To sign up, please use the AWS Management Console instead.
Ground Truth에서 AWS 제공 Lambda 함수와 함께 사용자 지정 UI 템플릿을 사용하려면 어떻게 해야 하나요?
레이블 지정 작업 시 Amazon SageMaker Ground Truth 사용자 지정 UI 템플릿과 AWS Lambda 함수를 사용하고 싶습니다.
해결방법
1. 다음 예제와 같이 레이블 지정 작업을 위한 사용자 지정 UI 템플릿을 생성합니다. 의미 체계 세분화 작업의 경우, 다음 예제와 같이 name 변수를 crowd-semantic-segmentation으로 설정합니다. 경계 상자 작업의 경우, name 변수를 boundingBox로 설정합니다. 사용자 지정 템플릿에 대한 향상된 HTML 요소의 전체 목록은 Crowd HTML 요소 참조 자료를 참조하세요.
<script src="https://assets.crowd.aws/crowd-html-elements.js"></script> <crowd-form> <crowd-semantic-segmentation name="crowd-semantic-segmentation" src="{{ task.input.taskObject | grant_read_access }}" header= "{{ task.input.header }}" labels="{{ task.input.labels | to_json | escape }}"> <full-instructions header= "Segmentation Instructions"> <ol> <li>Read the task carefully and inspect the image.</li> <li>Read the options and review the examples provided to understand more about the labels.</li> <li>Choose the appropriate label that best suits the image.</li> </ol> </full-instructions> <short-instructions> <p>Use the tools to label the requested items in the image</p> </short-instructions> </crowd-semantic-segmentation> </crowd-form>
2. 레이블에 대한 JSON 파일을 만듭니다. 예제:
{ "labels": [ { "label": "Chair" }, ... { "label": "Oven" } ] }
3. 이미지에 대한 입력 매니페스트 파일을 만듭니다. 예제:
{"source-ref":"s3://awsdoc-example-bucket/input_manifest/apartment-chair.jpg"} {"source-ref":"s3://awsdoc-example-bucket/input_manifest/apartment-carpet.jpg"}
4. HTML, 매니페스트 및 JSON 파일을 Amazon Simple Storage Service(Amazon S3)에 업로드합니다. 예제:
import boto3 import os bucket = 'awsdoc-example-bucket' prefix = 'GroundTruthCustomUI' boto3.Session().resource('s3').Bucket(bucket).Object(os.path.join(prefix, 'customUI.html')).upload_file('customUI.html') boto3.Session().resource('s3').Bucket(bucket).Object(os.path.join(prefix, 'input.manifest')).upload_file('input.manifest') boto3.Session().resource('s3').Bucket(bucket).Object(os.path.join(prefix, 'testLabels.json')).upload_file('testLabels.json')
5. 사전 처리 및 주석 통합 Lambda 함수에 대한 Amazon 리소스 이름(ARN)을 검색합니다. 예를 들어, 의미 체계 세분화 ARN은 다음과 같습니다.
arn:aws:lambda:eu-west-1:111122223333:function:PRE-SemanticSegmentation
arn:aws:lambda:eu-west-1:111122223333:function:ACS-SemanticSegmentation
6. boto3과 같은 AWS SDK를 사용하여 레이블 지정 작업을 생성합니다. 다음 예제의 이러한 값을 대체합니다.
INPUT_MANIFEST_IN_S3 S3_OUTPUT_PATH IAM_ROLE_ARN LABELS_JSON_FILE_IN_S3 WORKTEAM_ARN HTML_TEMPLATE_IN_S3
import boto3 client = boto3.client('sagemaker') client.create_labeling_job(LabelingJobName='SemanticSeg-CustomUI', LabelAttributeName='output-ref', InputConfig={ 'DataSource': { 'S3DataSource': { 'ManifestS3Uri': 'INPUT_MANIFEST_IN_S3' } }, 'DataAttributes': { 'ContentClassifiers' : [ 'FreeOfPersonallyIdentifiableInformation', ] } }, OutputConfig={ 'S3OutputPath' : 'S3_OUTPUT_PATH' }, RoleArn='IAM_ROLE_ARN', LabelCategoryConfigS3Uri='LABELS_JSON_FILE_IN_S3', StoppingConditions={ 'MaxPercentageOfInputDatasetLabeled': 100 }, HumanTaskConfig={ 'WorkteamArn': 'WORKTEAM_ARN', 'UiConfig': { 'UiTemplateS3Uri' : 'HTML_TEMPLATE_IN_S3' }, 'PreHumanTaskLambdaArn' : 'arn:aws:lambda:eu-west-1:111122223333:function:PRE-SemanticSegmentation', 'TaskKeywords': [ 'SemanticSegmentation', ], 'TaskTitle': 'Semantic Segmentation', 'TaskDescription': 'Draw around the specified labels using the tools', 'NumberOfHumanWorkersPerDataObject': 1, 'TaskTimeLimitInSeconds': 3600, 'TaskAvailabilityLifetimeInSeconds': 1800, 'MaxConcurrentTaskCount': 1, 'AnnotationConsolidationConfig': { 'AnnotationConsolidationLambdaArn': 'arn:aws:lambda:eu-west-1:111122223333:function:ACS-SemanticSegmentation' } }, Tags=[ { 'Key': 'reason', 'Value': 'CustomUI' } ])
관련 정보
관련 콘텐츠
- 질문됨 9달 전lg...
- 질문됨 2년 전lg...
- 질문됨 9달 전lg...
- AWS 공식업데이트됨 일 년 전
- AWS 공식업데이트됨 일 년 전
- AWS 공식업데이트됨 4달 전