

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

# 컬렉션에서 얼굴 삭제
<a name="delete-faces-procedure"></a>

[DeleteFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DeleteFaces.html) 작업을 사용하여 컬렉션에서 얼굴을 삭제할 수 있습니다. 자세한 내용은 [컬렉션에서 얼굴 관리](managing-face-collections.md#collections-index-faces) 단원을 참조하십시오.



**컬렉션에서 얼굴 삭제**

1. 아직 설정하지 않았다면 다음과 같이 하세요.

   1. `AmazonRekognitionFullAccess` 권한이 있는 사용자를 생성하거나 업데이트합니다. 자세한 내용은 [1단계: AWS 계정 설정 및 사용자 생성](setting-up.md#setting-up-iam) 단원을 참조하십시오.

   1.  AWS CLI 및 AWS SDKs를 설치하고 구성합니다. 자세한 내용은 [2단계: AWS CLI 및 AWS SDKs 설정](setup-awscli-sdk.md) 단원을 참조하십시오.

1. 다음 예제를 사용하여 `DeleteFaces` 작업을 호출합니다.

------
#### [ Java ]

   이 예제는 모음에서 한 개의 얼굴을 삭제합니다.

   `collectionId`의 값을, 삭제하려는 얼굴을 포함하는 모음으로 변경합니다. `faces`의 값을, 삭제하려는 얼굴 ID로 변경합니다. 여러 얼굴을 삭제하려면 `faces` 배열에 얼굴 ID를 추가합니다.

   ```
   //Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   //PDX-License-Identifier: MIT-0 (For details, see https://github.com/awsdocs/amazon-rekognition-developer-guide/blob/master/LICENSE-SAMPLECODE.)
   
   package aws.example.rekognition.image;
   import com.amazonaws.services.rekognition.AmazonRekognition;
   import com.amazonaws.services.rekognition.AmazonRekognitionClientBuilder;
   import com.amazonaws.services.rekognition.model.DeleteFacesRequest;
   import com.amazonaws.services.rekognition.model.DeleteFacesResult;
   
   import java.util.List;
   
   
   public class DeleteFacesFromCollection {
      public static final String collectionId = "MyCollection";
      public static final String faces[] = {"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"};
   
      public static void main(String[] args) throws Exception {
         
         AmazonRekognition rekognitionClient = AmazonRekognitionClientBuilder.defaultClient();
        
         
         DeleteFacesRequest deleteFacesRequest = new DeleteFacesRequest()
                 .withCollectionId(collectionId)
                 .withFaceIds(faces);
        
         DeleteFacesResult deleteFacesResult=rekognitionClient.deleteFaces(deleteFacesRequest);
         
        
         List < String > faceRecords = deleteFacesResult.getDeletedFaces();
         System.out.println(Integer.toString(faceRecords.size()) + " face(s) deleted:");
         for (String face: faceRecords) {
            System.out.println("FaceID: " + face);
         }
      }
   }
   ```

------
#### [ Java V2 ]

   이 코드는 AWS 설명서 SDK 예제 GitHub 리포지토리에서 가져온 것입니다. 전체 예제는 [여기](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javav2/example_code/rekognition/src/main/java/com/example/rekognition/DeleteFacesFromCollection.java)에서 확인하세요.

   ```
   import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
   import software.amazon.awssdk.regions.Region;
   import software.amazon.awssdk.services.rekognition.RekognitionClient;
   import software.amazon.awssdk.services.rekognition.model.DeleteFacesRequest;
   import software.amazon.awssdk.services.rekognition.model.RekognitionException;
   // snippet-end:[rekognition.java2.delete_faces_collection.import]
   
   /**
    * Before running this Java V2 code example, set up your development environment, including your credentials.
    *
    * For more information, see the following documentation topic:
    *
    * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
    */
   public class DeleteFacesFromCollection {
       public static void main(String[] args) {
   
           final String usage = "\n" +
               "Usage: " +
               "   <collectionId> <faceId> \n\n" +
               "Where:\n" +
               "   collectionId - The id of the collection from which faces are deleted. \n\n" +
               "   faceId - The id of the face to delete. \n\n";
   
           if (args.length != 1) {
               System.out.println(usage);
               System.exit(1);
           }
   
           String collectionId = args[0];
           String faceId = args[1];
           Region region = Region.US_EAST_1;
           RekognitionClient rekClient = RekognitionClient.builder()
               .region(region)
               .credentialsProvider(ProfileCredentialsProvider.create("profile-name"))
               .build();
   
           System.out.println("Deleting collection: " + collectionId);
           deleteFacesCollection(rekClient, collectionId, faceId);
           rekClient.close();
       }
   
       // snippet-start:[rekognition.java2.delete_faces_collection.main]
       public static void deleteFacesCollection(RekognitionClient rekClient,
                                                String collectionId,
                                                String faceId) {
   
           try {
               DeleteFacesRequest deleteFacesRequest = DeleteFacesRequest.builder()
                   .collectionId(collectionId)
                   .faceIds(faceId)
                   .build();
   
               rekClient.deleteFaces(deleteFacesRequest);
               System.out.println("The face was deleted from the collection.");
   
           } catch(RekognitionException e) {
               System.out.println(e.getMessage());
               System.exit(1);
           }
       }
       // snippet-end:[rekognition.java2.delete_faces_collection.main]
   }
   ```

------
#### [ AWS CLI ]

   이 AWS CLI 명령은 `delete-faces` CLI 작업에 대한 JSON 출력을 표시합니다. `collection-id`의 값을, 삭제하려는 얼굴을 포함하는 모음의 이름으로 바꿉니다. `face-ids`의 값을, 삭제하려는 얼굴 ID 배열로 바꿉니다. Rekognition 세션을 생성하는 라인에서 `profile_name`의 값을 개발자 프로필의 이름으로 대체합니다.

   ```
   aws rekognition delete-faces --collection-id "collection-id" --face-ids "faceid" --profile profile-name
   ```

------
#### [ Python ]

   이 예제는 모음에서 한 개의 얼굴을 삭제합니다.

   `collectionId`의 값을, 삭제하려는 얼굴을 포함하는 모음으로 변경합니다. `faces`의 값을, 삭제하려는 얼굴 ID로 변경합니다. 여러 얼굴을 삭제하려면 `faces` 배열에 얼굴 ID를 추가합니다. Rekognition 세션을 생성하는 라인에서 `profile_name`의 값을 개발자 프로필의 이름으로 대체합니다.

   ```
   # Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   # PDX-License-Identifier: MIT-0 (For details, see https://github.com/awsdocs/amazon-rekognition-developer-guide/blob/master/LICENSE-SAMPLECODE.)
   
   import boto3
   
   def delete_faces_from_collection(collection_id, faces):
   
       session = boto3.Session(profile_name='profile-name')
       client = session.client('rekognition')
       response = client.delete_faces(CollectionId=collection_id,
                                      FaceIds=faces)
   
       print(str(len(response['DeletedFaces'])) + ' faces deleted:')
       for faceId in response['DeletedFaces']:
           print(faceId)
       return len(response['DeletedFaces'])
   
   
   def main():
       collection_id = 'collection-id'
       faces = []
       faces.append("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
   
       faces_count = delete_faces_from_collection(collection_id, faces)
       print("deleted faces count: " + str(faces_count))
   
   if __name__ == "__main__":
       main()
   ```

------
#### [ .NET ]

   이 예제는 모음에서 한 개의 얼굴을 삭제합니다.

   `collectionId`의 값을, 삭제하려는 얼굴을 포함하는 모음으로 변경합니다. `faces`의 값을, 삭제하려는 얼굴 ID로 변경합니다. 여러 얼굴을 삭제하려면 `faces` 목록에 얼굴 ID를 추가합니다.

   ```
   //Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   //PDX-License-Identifier: MIT-0 (For details, see https://github.com/awsdocs/amazon-rekognition-developer-guide/blob/master/LICENSE-SAMPLECODE.)
   
   using System;
   using System.Collections.Generic;
   using Amazon.Rekognition;
   using Amazon.Rekognition.Model;
   
   public class DeleteFaces
   {
       public static void Example()
       {
           String collectionId = "MyCollection";
           List<String> faces = new List<String>() { "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" };
   
           AmazonRekognitionClient rekognitionClient = new AmazonRekognitionClient();
   
           DeleteFacesRequest deleteFacesRequest = new DeleteFacesRequest()
           {
               CollectionId = collectionId,
               FaceIds = faces
           };
   
           DeleteFacesResponse deleteFacesResponse = rekognitionClient.DeleteFaces(deleteFacesRequest);
           foreach (String face in deleteFacesResponse.DeletedFaces)
               Console.WriteLine("FaceID: " + face);
       }
   }
   ```

------

## DeleteFaces 작업 요청
<a name="deletefaces-request"></a>

`DeleteFaces`에 대한 입력은 얼굴을 포함하는 모음의 ID와, 삭제할 얼굴의 얼굴 ID 배열입니다.

```
{
    "CollectionId": "MyCollection",
    "FaceIds": [
        "daf29cac-f910-41e9-851f-6eeb0e08f973"
    ]
}
```

## DeleteFaces 작업 응답
<a name="deletefaces-operation-response"></a>

`DeleteFaces` 응답에는 삭제된 얼굴의 얼굴 ID 배열이 들어 있습니다.

```
{
    "DeletedFaces": [
        "daf29cac-f910-41e9-851f-6eeb0e08f973"
    ]
}
```

 입력에 제공된 얼굴 ID가 현재 사용자와 연결되어 있는 경우 타당한 이유가 있는 UnsuccessfulFaceDeletions의 일부로 반환됩니다.

```
{
   "DeletedFaces": [
        "daf29cac-f910-41e9-851f-6eeb0e08f973"
    ],
     "UnsuccessfulFaceDeletions" : [
        {
           "FaceId" : "0b683aed-a0f1-48b2-9b5e-139e9cc2a757",
           "UserId" : "demoUser1",
           "Reason" : ["ASSOCIATED_TO_AN_EXISTING_USER"]
        }
     ]
}
```