kookmin-sw / 2019-cap1-2019_4

Flex Ads to implement advertising system in offline market
MIT License
10 stars 7 forks source link

Add faces to collection with S3 Access Error #41

Closed james-sungjae-lee closed 5 years ago

james-sungjae-lee commented 5 years ago

얼굴 이미지를 Rekognition 에 학습시키는 과정에서 Collection Upload 가 정상적으로 처리되지 않음

첫 번째 에러는 S3 의 데이터를 Rekognition 으로 전송하는 과정에서 Filename 이 적절하지 못하여 발생함

Screen Shot 2019-04-19 at 7 30 33 PM

botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the IndexFaces operation: 1 validation error detected: Value 'train/jisoo/20190417-01200156.PNG' at 'externalImageId' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z0-9_.-:]+ ( 오류 내용 )

이로 미루어 보았을 때, filename 으로는 directory 를 표현하기 위한 '/' 표시가 들어가면 안 되며,

S3 의 가장 상위 폴더 위치에 저장 후 file 을 이동시켜 폴더별 관리가 필요한 것으로 보인다.

해당 오류는 filename 을 수정함으로써 해결되었다. 하지만 Access 문제는 여전히 남아있다.

james-sungjae-lee commented 5 years ago

botocore.errorfactory.InvalidS3ObjectException: An error occurred (InvalidS3ObjectException) when calling the IndexFaces operation: Unable to get object metadata from S3. Check object key, region and/or access permissions. ( 두 번째 오류 내용 )

두 번째로 발생한 오류는 입력한 S3 Object 정보에 접근할 수 없다는 것이며, object key, region, access permission 을 확인하라는 메시지가 나타난다.

이에 해당 내용을 순차적으로 확인하였다.

  1. object key

    • S3 의 object key 를 정확하게 확인하기 위해, s3 의 bucket.objects.all( ) 을 이용하여 object key 를 출력하여 보았다. 하지만 해당 키값을 정확하게 입력했음에도 오류는 해결되지 않았다.
  2. region

    • S3 는 us-east-1 region 에 존재하는 것으로, rekognition 또한 동일한 region 옵션을 할당하여 테스트 해 보았지만 오류는 해결되지 않았다.
  3. access permission

    • rekognition 과 s3 모두에 full access 가능한 IAM 을 생성하고, rekognition 과 s3 각각에 접근이 가능하다는 것은 테스트 했지만, 상호 접근이 불가능 한 것으로 보인다.

관련 자료를 찾아본 결과, 약간의 의심이 가는 부분은 다음 두 가지이다.

james-sungjae-lee commented 5 years ago

region 문제로 밝혀짐

https://stackoverflow.com/questions/44532633/aws-rekognition-gives-an-invalids3exeption-error

james-sungjae-lee commented 5 years ago
Screen Shot 2019-04-30 at 4 56 36 PM

문제를 해결하기 위해서는 위와 같이 rekognition 의 client 생성 시에 s3 의 region 과 동일한 region 을

region_name 파라미터에 입력해주면 된다.