

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 인적 검토 워크플로(API) 생성
<a name="a2i-textract-create-flow-definition-api"></a>

인적 검토 워크플로를 생성하거나*흐름 정의*Amazon A2I를 사용하여[https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateFlowDefinition.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateFlowDefinition.html)작업.

이 예에서는 Amazon S3 자체 문서를 사용하거나 다운로드할 수 있습니다.[이 샘플 문서](https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2020/04/17/sample-document-final.png)S3 버킷에 저장합니다.

Amazon S3 버킷이 동일한지 확인합니다.AWS통화에 사용할 리전`AnalyzeDocument`. 버킷을 생성하려면 의 지침을 따르십시오.[버킷 만들기](https://docs.aws.amazon.com/AmazonS3/latest/user-guide/create-bucket.html)의*Amazon Simple Storage Service 콘솔*.

**사전 요구사항**

Amazon A2I API를 사용하여 사람 검토 워크플로를 생성하려면 다음 사전 요구 사항을 완료해야 합니다.
+ Amazon A2I 및 Amazon Textract API 작업을 모두 호출할 수 있는 권한이 있는 IAM 역할을 구성합니다. 시작하려면 AWS 정책, AmazonAugmentedAIFullAccess 및 AmazonTextractFullAccess IAM 역할에 연결할 수 있습니다. 나중에 필요하므로 IAM 역할 Amazon 리소스 이름 (ARN) 을 기록해 두십시오.

  Amazon Textract Textract를 사용할 때 보다 세부적인 권한은 단원을 참조하십시오[Amazon Textract Textract자격 증명 기반 정책 예제](security_iam_id-based-policy-examples.md). Amazon A2I의 경우 단원을 참조하십시오.[Amazon Augmented AI AI의 권한 및 보안](https://docs.aws.amazon.com/sagemaker/latest/dg/a2i-permissions-security.html)의*Amazon SageMaker 개발자 안내서*.
+ 비공개 작업 팀을 만들고 작업팀 ARN을 기록합니다. Amazon A2I의 새 사용자인 경우 의 지침을 따르십시오.[1단계: 작업 팀 생성 (콘솔)](a2i-textract-create-flow-definition-console.md#a2i-textract-create-flow-definition-workteam).
+ 작업자 작업 템플릿을 생성합니다. 의 지침을 따르십시오.[작업자 작업 템플릿 생성](https://docs.aws.amazon.com/sagemaker/latest/dg/a2i-worker-template-console.html#a2i-create-worker-template-console)을 눌러 Amazon A2I 콘솔을 사용하여 템플릿을 생성합니다. 템플릿을 만들 때 다음을 선택합니다.**텍스트 형식 추출**...에 대한**템플릿 유형**. 템플릿에서 바꾸기`s3_arn`문서의 Amazon S3 ARN을 사용합니다. 추가 작업자 지침 추가`<full-instructions header="Instructions"></full-instructions>`.

  템플릿을 미리 보려면 IAM 역할에 에서 설명하는 권한이 있는지 확인합니다.[작업자 작업 템플릿 미리 보기 사용](https://docs.aws.amazon.com/sagemaker/latest/dg/a2i-permissions-security.html#permissions-for-worker-task-templates-augmented-ai).

  템플릿을 생성한 후 작업자 작업 템플릿 ARN을 기록합니다.

에서 생성한 리소스를 사용합니다.**사전 요구사항**를 구성합니다.`CreateFlowDefinition`요청. 이 요청에서 활성화 조건을 JSON 형식으로 지정할 수도 있습니다. 활성화 조건을 구성하는 방법에 대한 자세한 내용은 단원을 참조하십시오.[Amazon Textract Textract와 함께 인적 루프 활성화 조건 JSON 스키마 사용](https://docs.aws.amazon.com/sagemaker/latest/dg/a2i-json-humantaskactivationconditions-textract-example.html).

## 인적 검토 워크플로 생성 (Python용 AWS SDK (Boto3)
<a name="a2i-textract-create-flow-definition-api-example"></a>

이 예제를 사용하려면{{red}}사양과 리소스가 포함된 텍스트.

먼저 다음 코드를 사용하여 활성화 조건을 JSON 객체로 인코딩합니다. 그러면 Amazon Textract Textract가 99보다 작은 신뢰 점수를 반환하는 경우 사람의 검토가 트리거됩니다.*메일 주소*및 해당 값 또는 문서에서 감지된 키-값 쌍에 대해 90보다 작은 신뢰 점수를 반환하는 경우 이 예에 제공된 샘플 문서를 사용하는 경우 이러한 활성화 조건은 사람의 검토 작업을 만듭니다.

```
import json

humanLoopActivationConditions = json.dumps({{"{
                "Conditions": [
                    {
                        "ConditionType": "ImportantFormKeyConfidenceCheck",
                        "ConditionParameters": {
                            "ImportantFormKey": "Mail Address",
                            "KeyValueBlockConfidenceLessThan": 99,
                            "WordBlockConfidenceLessThan": 99
                        }
                    },
                    {
                        "ConditionType": "ImportantFormKeyConfidenceCheck",
                        "ConditionParameters": {
                            "ImportantFormKey": "*",
                            "KeyValueBlockConfidenceLessThan": 90,
                            "WordBlockConfidenceLessThan": 90
                        }
                    }
                ]
            }"}}
)
```

사용`humanLoopActivationConditions`를 구성하려면`create_flow_definition`요청. 다음 예제에서는 SDK for Python (Boto3) 를 사용하여[https://docs.aws.amazon.com/goto/boto3/sagemaker-2017-07-24/CreateFlowDefinition](https://docs.aws.amazon.com/goto/boto3/sagemaker-2017-07-24/CreateFlowDefinition)us-west-2 AWS 리전에서. 개인 작업 팀을 사용하여 지정합니다.

```
response = client.create_flow_definition(
    FlowDefinitionName='string',
    HumanLoopRequestSource={
         'AwsManagedHumanLoopRequestSource': {{"AWS/Textract/AnalyzeDocument/Forms/V1"}}
    }, 
    HumanLoopActivationConfig={
        'HumanLoopActivationConditionsConfig': {
            'HumanLoopActivationConditions': humanLoopActivationConditions
        }
    },
    HumanLoopConfig={
        'WorkteamArn': "arn:aws:sagemaker:{{us-west-2}}:{{111122223333}}:workteam/{{private-crowd}}/{{work-team-name}}",
        'HumanTaskUiArn': "arn:aws:sagemaker:{{us-west-2}}:{{111122223333}}:human-task-ui/{{worker-task-template-name}}",
        'TaskTitle': {{"Add a task title"}},
        'TaskDescription': {{"Describe your task"}},
        'TaskCount': {{1}},
        'TaskAvailabilityLifetimeInSeconds': {{3600}},
        'TaskTimeLimitInSeconds': {{86400}},
        'TaskKeywords': [{{"Document Review"}}, {{"Content Review"}}]
        }
    },
    OutputConfig={
        'S3OutputPath': "s3://{{DOC-EXAMPLE-BUCKET/prefix/}}",
    },
    RoleArn="arn:aws:iam::{{111122223333}}:role/{{role-name}}"
)
```