SlideShare a Scribd company logo
Confidential + ProprietaryConfidential + Proprietary
얼굴 인식 모델 개발 삽질기.
조대협
Confidential + Proprietary
배경
딥러닝에서 배운 것을 써먹어 보자
일본에 인디 개발자가 혼자 개발한 사례
“만만할거 같다.”
연예인 얼굴 45명에 대해서 CNN 기반으
로 분류하는 로직을 개발
http://memo.sugyan.com/entry/20160328/1459094743
Confidential + Proprietary
알고리즘이나 모델이 아닌
데이타 자체와
데이타 수집 및 정재 파이프라인
결론 부터
...
Confidential + ProprietaryConfidential + Proprietary
데이타 정재 과정
Confidential + Proprietary
퍼블릭 데이타 PubFig에서 데이타 수집
얼굴 데이타가 많은데? 데이타는 다 됐
어 → 비극의 시작
얼굴 분리
얼굴만 VISION API로 따내기 시작함
두명 이상일때 엉뚱한 사람이 들어옴
404 Not Found
노가다
일일이 눈으로 판별하기 시작함
연예인의 평생 얼굴(화장 전후, 살찐 얼
http://www.cs.columbia.edu/CAVE/databases/pubfig/
Confidential + Proprietary
학습 시작
그리고 시작되는 삽질의 연속
Confidential + Proprietary
라벨 변환이 안된다.
가독성을 좋게하기 위해서 라벨을 문자열로 했음. ‘배열에 넣고 나중에 바꿀 생각을 했
는데..’
텐서플로우에서는 잘 안됨
/Users/terrycho/training_data_class5_40/training/jesi-jessica371.jpeg,Alba
/Users/terrycho/training_data_class5_40/training/jesi-jessica376.jpeg,Alba
/Users/terrycho/training_data_class5_40/training/jesi-jessica379.jpeg,Alba
/Users/terrycho/training_data_class5_40/training/an-2384379443_77fdb5566a.jpg,Jolie
/Users/terrycho/training_data_class5_40/training/an-244912461_63f694f004_o.jpg,Jolie
/Users/terrycho/training_data_class5_40/training/jesi-jessica371.jpeg,Alba,0
/Users/terrycho/training_data_class5_40/training/jesi-jessica376.jpeg,Alba,0
/Users/terrycho/training_data_class5_40/training/jesi-jessica379.jpeg,Alba,0
/Users/terrycho/training_data_class5_40/training/an-2384379443_77fdb5566a.jpg,Jolie,1
/Users/terrycho/training_data_class5_40/training/an-244912461_63f694f004_o.jpg,Jolie,1
결국은 숫자 라벨을 사용함
Confidential + Proprietary
드디어 돌아간다
그리고 다시 삽질
Confidential + Proprietary
예측 결과가 쏠리기 시작함
“내 컴퓨터의 성별은 여자 였다.”
90%를 브래드피드로만 인식함
Confidential + Proprietary
쏠림의 원인은 학습 순서
학습 데이타 파일
/Users/terrycho/training_data_class5_40/training/jesi-jessica371.jpeg,Alba,0
/Users/terrycho/training_data_class5_40/training/jesi-jessica376.jpeg,Alba,0
/Users/terrycho/training_data_class5_40/training/jesi-jessica379.jpeg,Alba,0
/Users/terrycho/training_data_class5_40/training/an-2384379443_77fdb5566a.jpg,Jolie,1
/Users/terrycho/training_data_class5_40/training/an-244912461_63f694f004_o.jpg,Jolie,1
def get_input_queue(csv_file_name,num_epochs = None):
train_images = []
train_labels = []
for line in open(csv_file_name,'r'):
cols = re.split(',|n',line)
train_images.append(cols[0])
# 3rd column is label and needs to be converted to int type
train_labels.append(int(cols[2]) )
input_queue = tf.train.slice_input_producer([train_images,train_labels],
num_epochs = num_epochs,shuffle = True)
return input_queue
셔플링
Confidential + Proprietary
그래도 쏠린다.
브래드 피트로만 예측
내 컴퓨터가 여자가 아니라, 안젤리나
졸리였던거야..
Confidential + Proprietary
문제는 데이타 분포
불규칙적인 데이타 분포
클래스 데이타 수
브래드 피트 400
안젤리나 졸리 100
제시카 알바 50
“ 일일이 수동으로 데이타를 골라내다 보
니, 나중에는 지겨워서 대충…. ”
클래스 데이타 수
브래드 피트 50
안젤리나 졸리 50
제시카 알바 50
“ 작은 수의 데이타로 다 맞춤.. ”
Confidential + Proprietary
정확도가 안올라감
“학습 데이타가 부족한가??”
구글링에서 데이타를 채워놓음 (클래스당 120개까
지)
Confidential + Proprietary
필터링 1. 독사진만 걸러냄
눈으로 일일이 골라내는게 힘들어서 필터링 자동화 → 구글 VISION API
if 'faceAnnotations' not in response['responses'][0]:
print('[Error] %s: Cannot find face ' % image_file)
return None
face = response['responses'][0]['faceAnnotations']
label = response['responses'][0]['labelAnnotations']
if len(face) > 1 :
print('[Error] %s: It has more than 2 faces in a file' % image_file)
return None
Confidential + Proprietary
일일이 수집하고 필터링하기 너무 어려움
데이타 뻥튀기
# random image
image = tf.image.random_flip_left_right(image)
image = tf.image.random_brightness(image,max_delta=0.5)
image = tf.image.random_contrast(image,lower=0.2,upper=2.0)
image = tf.image.random_hue(image,max_delta=0.08)
image = tf.image.random_saturation(image,lower=0.2,upper=2.0)
Confidential + Proprietary
Confidential + Proprietary
연예인 사진을 해보자
“빅뱅,EXO. 레드벨벳"
정확도가 안나옴
Confidential + Proprietary
원인 분석
모두 정면을 보고 있다.
각도, 메이크업..
육안으로도 구별 불가….
(40대 아저씨인가… 좌절)
Confidential + Proprietary
필터링 2. 얼굴 각도 필터링
얼굴 각도 필터링 (구글 VISION API)
roll_angle = face[0]['rollAngle']
pan_angle = face[0]['panAngle']
tilt_angle = face[0]['tiltAngle']
angle = [roll_angle,pan_angle,tilt_angle]
# check angle
# if face skew angle is greater than > 20, it will skip the data
if abs(roll_angle) > MAX_ROLL or abs(pan_angle) > MAX_PAN or abs(tilt_angle) > MAX_TILT:
print('[Error] %s: face skew angle is big' % image_file)
return None
Confidential + Proprietary
목돌아간 설현
필터링 되는 데이타가 너무 많음
Confidential + Proprietary
자동화
Confidential + Proprietary
결국은 다시 수동 작업
“쓰레기 데이타가 너무 많음"
Confidential + Proprietary
빅토리아 누님...
구글 VISION API Label Detection
# check sunglasses
for l in label:
if 'sunglasses' in l['description']:
print('[Error] %s: sunglass is detected' % image_file)
return None
Confidential + Proprietary
표정
안해봤는데, 가능할듯..
Confidential + Proprietary
학습에 좋은 데이타
해보니...
화장 안하고 얼굴 다 들어나고 되도록이면 정면을 보는 사진 → 프로필 사진류
시상식, 펜싸인회, CF 사진 → 스포츠 신문 사이트에 많음
동영상이나 움짤에서 프레임을 잘라내는 것도 좋을듯 (안해봤음. 구찮아서..)
Confidential + Proprietary
그외에도...
한글 파일명으로 인해서 윈도우에서 Charset 문제 → 학습 파일은 영어로..
학습 파일에 Full Path를 썼음
“/Users/terrycho/training_data_class5_40/training/jesi-1zdcfbt.jpg”
→ 학습 파일명만 쓰는게 좋음
(CloudML → gs:// , 다른 컴퓨터로 옮길때..)
Confidential + Proprietary
Lesson learned
꽃같이 단순한 데이타를 하지 않기 잘했
음. 얼굴 인식이 어렵고 많은 삽질이
있었음 → 약간의 깨달음 (ML은 삽질
과 노가다)
좋은 양질의 데이타 확보가 중요하다.
ML 모델도 중요하지만, 데이타 수집 및 필
터링 파이프라인도 중요
Confidential + Proprietary
아직도 삽질중
Confidential + Proprietary
질문
구글은 여러 표정에 안경을 써도 어떻게 잘 잡아 낼까?
아마도 “더 큰 네트워크" + “더 많은 데이타"
Confidential + Proprietary
앞으로 과제
CloudML 적용
Prediction 엔진을 이용하여 REST API 개발
CIFAR-10, VGG 등 검증된 모델 포팅
트랜스퍼 러닝 시도
Image Segmentation
GAN → 메이크업 해주기

More Related Content

PPTX
Terraform
PDF
서버 개발자가 되기 위한 첫 걸음
PPTX
DevOps: A Value Proposition
PPTX
Kubernetes Selenium Grid
PPTX
Introduction to Selenium Web Driver
PPTX
BDD testing with cucumber
PDF
PKI in DevOps: How to Deploy Certificate Automation within CI/CD
PPTX
04 생활 속 문제 해결을 위한 엔트리 프로그래밍
Terraform
서버 개발자가 되기 위한 첫 걸음
DevOps: A Value Proposition
Kubernetes Selenium Grid
Introduction to Selenium Web Driver
BDD testing with cucumber
PKI in DevOps: How to Deploy Certificate Automation within CI/CD
04 생활 속 문제 해결을 위한 엔트리 프로그래밍

What's hot (20)

PPTX
DevOps - Overview - One of the Top Trends in IT Industry
PDF
Introduction to DevOps Tools | DevOps Training | DevOps Tutorial for Beginner...
PDF
Phoenix Framework
PDF
DevOps - A Gentle Introduction
PPTX
Serverless integration with Knative and Apache Camel on Kubernetes
PDF
Profiling - 실시간 대화식 프로파일러
PPTX
Getting Started with BigQuery ML
PPTX
Oracle Cloud With Azure DevOps Pipelines
PPTX
Devops Mindset Essentials
PDF
.NET Core 3.0 + Windows 10 で WPF 開発
PDF
Open shift 4-update
PPT
Automated Web Testing Using Selenium
PDF
Understanding DevOps
PDF
Jenkins
PDF
Knative, Serverless on Kubernetes, and Openshift
PPTX
Introduction to DevOps
PDF
SRE 101
PDF
DevOps for beginners
PDF
김민욱, (달빛조각사) 엘릭서를 이용한 mmorpg 서버 개발, NDC2019
PDF
Introduction of cloud native CI/CD on kubernetes
DevOps - Overview - One of the Top Trends in IT Industry
Introduction to DevOps Tools | DevOps Training | DevOps Tutorial for Beginner...
Phoenix Framework
DevOps - A Gentle Introduction
Serverless integration with Knative and Apache Camel on Kubernetes
Profiling - 실시간 대화식 프로파일러
Getting Started with BigQuery ML
Oracle Cloud With Azure DevOps Pipelines
Devops Mindset Essentials
.NET Core 3.0 + Windows 10 で WPF 開発
Open shift 4-update
Automated Web Testing Using Selenium
Understanding DevOps
Jenkins
Knative, Serverless on Kubernetes, and Openshift
Introduction to DevOps
SRE 101
DevOps for beginners
김민욱, (달빛조각사) 엘릭서를 이용한 mmorpg 서버 개발, NDC2019
Introduction of cloud native CI/CD on kubernetes
Ad

More from Terry Cho (20)

PPTX
Kubernetes #6 advanced scheduling
PPTX
Kubernetes #4 volume & stateful set
PPTX
Kubernetes #3 security
PPTX
Kubernetes #2 monitoring
PPTX
Kubernetes #1 intro
PPTX
5. 솔루션 카달로그
PPTX
4. 대용량 아키텍쳐 설계 패턴
PPTX
3. 마이크로 서비스 아키텍쳐
PPTX
서비스 지향 아키텍쳐 (SOA)
PPTX
1. 아키텍쳐 설계 프로세스
PPTX
애자일 스크럼과 JIRA
PPTX
REST API 설계
PPTX
모바일 개발 트랜드
PPTX
소프트웨어 개발 트랜드 및 MSA (마이크로 서비스 아키텍쳐)의 이해
PPTX
Micro Service Architecture의 이해
PPTX
머신 러닝 입문 #1-머신러닝 소개와 kNN 소개
PPTX
R 프로그래밍-향상된 데이타 조작
PPTX
R 프로그래밍 기본 문법
PPTX
R 기본-데이타형 소개
PPTX
2014 공개소프트웨어 대회 소프트웨어 개발 트렌드의 변화
Kubernetes #6 advanced scheduling
Kubernetes #4 volume & stateful set
Kubernetes #3 security
Kubernetes #2 monitoring
Kubernetes #1 intro
5. 솔루션 카달로그
4. 대용량 아키텍쳐 설계 패턴
3. 마이크로 서비스 아키텍쳐
서비스 지향 아키텍쳐 (SOA)
1. 아키텍쳐 설계 프로세스
애자일 스크럼과 JIRA
REST API 설계
모바일 개발 트랜드
소프트웨어 개발 트랜드 및 MSA (마이크로 서비스 아키텍쳐)의 이해
Micro Service Architecture의 이해
머신 러닝 입문 #1-머신러닝 소개와 kNN 소개
R 프로그래밍-향상된 데이타 조작
R 프로그래밍 기본 문법
R 기본-데이타형 소개
2014 공개소프트웨어 대회 소프트웨어 개발 트렌드의 변화
Ad

머신러닝으로 얼굴 인식 모델 개발 삽질기

  • 1. Confidential + ProprietaryConfidential + Proprietary 얼굴 인식 모델 개발 삽질기. 조대협
  • 2. Confidential + Proprietary 배경 딥러닝에서 배운 것을 써먹어 보자 일본에 인디 개발자가 혼자 개발한 사례 “만만할거 같다.” 연예인 얼굴 45명에 대해서 CNN 기반으 로 분류하는 로직을 개발 http://memo.sugyan.com/entry/20160328/1459094743
  • 3. Confidential + Proprietary 알고리즘이나 모델이 아닌 데이타 자체와 데이타 수집 및 정재 파이프라인 결론 부터 ...
  • 4. Confidential + ProprietaryConfidential + Proprietary 데이타 정재 과정
  • 5. Confidential + Proprietary 퍼블릭 데이타 PubFig에서 데이타 수집 얼굴 데이타가 많은데? 데이타는 다 됐 어 → 비극의 시작 얼굴 분리 얼굴만 VISION API로 따내기 시작함 두명 이상일때 엉뚱한 사람이 들어옴 404 Not Found 노가다 일일이 눈으로 판별하기 시작함 연예인의 평생 얼굴(화장 전후, 살찐 얼 http://www.cs.columbia.edu/CAVE/databases/pubfig/
  • 6. Confidential + Proprietary 학습 시작 그리고 시작되는 삽질의 연속
  • 7. Confidential + Proprietary 라벨 변환이 안된다. 가독성을 좋게하기 위해서 라벨을 문자열로 했음. ‘배열에 넣고 나중에 바꿀 생각을 했 는데..’ 텐서플로우에서는 잘 안됨 /Users/terrycho/training_data_class5_40/training/jesi-jessica371.jpeg,Alba /Users/terrycho/training_data_class5_40/training/jesi-jessica376.jpeg,Alba /Users/terrycho/training_data_class5_40/training/jesi-jessica379.jpeg,Alba /Users/terrycho/training_data_class5_40/training/an-2384379443_77fdb5566a.jpg,Jolie /Users/terrycho/training_data_class5_40/training/an-244912461_63f694f004_o.jpg,Jolie /Users/terrycho/training_data_class5_40/training/jesi-jessica371.jpeg,Alba,0 /Users/terrycho/training_data_class5_40/training/jesi-jessica376.jpeg,Alba,0 /Users/terrycho/training_data_class5_40/training/jesi-jessica379.jpeg,Alba,0 /Users/terrycho/training_data_class5_40/training/an-2384379443_77fdb5566a.jpg,Jolie,1 /Users/terrycho/training_data_class5_40/training/an-244912461_63f694f004_o.jpg,Jolie,1 결국은 숫자 라벨을 사용함
  • 8. Confidential + Proprietary 드디어 돌아간다 그리고 다시 삽질
  • 9. Confidential + Proprietary 예측 결과가 쏠리기 시작함 “내 컴퓨터의 성별은 여자 였다.” 90%를 브래드피드로만 인식함
  • 10. Confidential + Proprietary 쏠림의 원인은 학습 순서 학습 데이타 파일 /Users/terrycho/training_data_class5_40/training/jesi-jessica371.jpeg,Alba,0 /Users/terrycho/training_data_class5_40/training/jesi-jessica376.jpeg,Alba,0 /Users/terrycho/training_data_class5_40/training/jesi-jessica379.jpeg,Alba,0 /Users/terrycho/training_data_class5_40/training/an-2384379443_77fdb5566a.jpg,Jolie,1 /Users/terrycho/training_data_class5_40/training/an-244912461_63f694f004_o.jpg,Jolie,1 def get_input_queue(csv_file_name,num_epochs = None): train_images = [] train_labels = [] for line in open(csv_file_name,'r'): cols = re.split(',|n',line) train_images.append(cols[0]) # 3rd column is label and needs to be converted to int type train_labels.append(int(cols[2]) ) input_queue = tf.train.slice_input_producer([train_images,train_labels], num_epochs = num_epochs,shuffle = True) return input_queue 셔플링
  • 11. Confidential + Proprietary 그래도 쏠린다. 브래드 피트로만 예측 내 컴퓨터가 여자가 아니라, 안젤리나 졸리였던거야..
  • 12. Confidential + Proprietary 문제는 데이타 분포 불규칙적인 데이타 분포 클래스 데이타 수 브래드 피트 400 안젤리나 졸리 100 제시카 알바 50 “ 일일이 수동으로 데이타를 골라내다 보 니, 나중에는 지겨워서 대충…. ” 클래스 데이타 수 브래드 피트 50 안젤리나 졸리 50 제시카 알바 50 “ 작은 수의 데이타로 다 맞춤.. ”
  • 13. Confidential + Proprietary 정확도가 안올라감 “학습 데이타가 부족한가??” 구글링에서 데이타를 채워놓음 (클래스당 120개까 지)
  • 14. Confidential + Proprietary 필터링 1. 독사진만 걸러냄 눈으로 일일이 골라내는게 힘들어서 필터링 자동화 → 구글 VISION API if 'faceAnnotations' not in response['responses'][0]: print('[Error] %s: Cannot find face ' % image_file) return None face = response['responses'][0]['faceAnnotations'] label = response['responses'][0]['labelAnnotations'] if len(face) > 1 : print('[Error] %s: It has more than 2 faces in a file' % image_file) return None
  • 15. Confidential + Proprietary 일일이 수집하고 필터링하기 너무 어려움 데이타 뻥튀기 # random image image = tf.image.random_flip_left_right(image) image = tf.image.random_brightness(image,max_delta=0.5) image = tf.image.random_contrast(image,lower=0.2,upper=2.0) image = tf.image.random_hue(image,max_delta=0.08) image = tf.image.random_saturation(image,lower=0.2,upper=2.0)
  • 17. Confidential + Proprietary 연예인 사진을 해보자 “빅뱅,EXO. 레드벨벳" 정확도가 안나옴
  • 18. Confidential + Proprietary 원인 분석 모두 정면을 보고 있다. 각도, 메이크업.. 육안으로도 구별 불가…. (40대 아저씨인가… 좌절)
  • 19. Confidential + Proprietary 필터링 2. 얼굴 각도 필터링 얼굴 각도 필터링 (구글 VISION API) roll_angle = face[0]['rollAngle'] pan_angle = face[0]['panAngle'] tilt_angle = face[0]['tiltAngle'] angle = [roll_angle,pan_angle,tilt_angle] # check angle # if face skew angle is greater than > 20, it will skip the data if abs(roll_angle) > MAX_ROLL or abs(pan_angle) > MAX_PAN or abs(tilt_angle) > MAX_TILT: print('[Error] %s: face skew angle is big' % image_file) return None
  • 20. Confidential + Proprietary 목돌아간 설현 필터링 되는 데이타가 너무 많음
  • 22. Confidential + Proprietary 결국은 다시 수동 작업 “쓰레기 데이타가 너무 많음"
  • 23. Confidential + Proprietary 빅토리아 누님... 구글 VISION API Label Detection # check sunglasses for l in label: if 'sunglasses' in l['description']: print('[Error] %s: sunglass is detected' % image_file) return None
  • 25. Confidential + Proprietary 학습에 좋은 데이타 해보니... 화장 안하고 얼굴 다 들어나고 되도록이면 정면을 보는 사진 → 프로필 사진류 시상식, 펜싸인회, CF 사진 → 스포츠 신문 사이트에 많음 동영상이나 움짤에서 프레임을 잘라내는 것도 좋을듯 (안해봤음. 구찮아서..)
  • 26. Confidential + Proprietary 그외에도... 한글 파일명으로 인해서 윈도우에서 Charset 문제 → 학습 파일은 영어로.. 학습 파일에 Full Path를 썼음 “/Users/terrycho/training_data_class5_40/training/jesi-1zdcfbt.jpg” → 학습 파일명만 쓰는게 좋음 (CloudML → gs:// , 다른 컴퓨터로 옮길때..)
  • 27. Confidential + Proprietary Lesson learned 꽃같이 단순한 데이타를 하지 않기 잘했 음. 얼굴 인식이 어렵고 많은 삽질이 있었음 → 약간의 깨달음 (ML은 삽질 과 노가다) 좋은 양질의 데이타 확보가 중요하다. ML 모델도 중요하지만, 데이타 수집 및 필 터링 파이프라인도 중요
  • 29. Confidential + Proprietary 질문 구글은 여러 표정에 안경을 써도 어떻게 잘 잡아 낼까? 아마도 “더 큰 네트워크" + “더 많은 데이타"
  • 30. Confidential + Proprietary 앞으로 과제 CloudML 적용 Prediction 엔진을 이용하여 REST API 개발 CIFAR-10, VGG 등 검증된 모델 포팅 트랜스퍼 러닝 시도 Image Segmentation GAN → 메이크업 해주기