tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

43
TensorFlow얼굴을 인식해 보자. 공개 소프트웨어 개발자 센터 (KOSS Lab. 2) Mario Cho (조만석) [email protected]

Upload: mario-cho

Post on 16-Apr-2017

2.893 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

TensorFlow로얼굴을인식해보자.

공개 소프트웨어 개발자 센터

(KOSSLab. 2기)MarioCho(조만석)

[email protected]

Page 2: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Who am I ?Development Experience◆ Image Recognition using Neural Network◆ Bio-Medical Data Processing◆ Human Brain Mapping on High Performance

Computing◆ Medical Image Reconstruction

(Computer Tomography) ◆Enterprise System◆Open Source Software Developer

Open Source Software Developer◆ Linux Kernel & LLVM ◆ OPNFV (NFV&SDN) & OpenStack◆ Machine Learning (TensorFlow)

Book◆ Unix V6 Kernel

Korea Open Source Software Lab.Mario Cho

[email protected]

Page 3: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Contents

• 우리가 본다!

• 기초부터 MNIST

• CIF영상인식

• 학습데이터만들기

• Tensorflow에 적용

• 그리고 전설로.

Page 4: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Human Intelligence

Page 5: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Human Brain

Source: https://www.ll.mit.edu/publications/journal/pdf/vol 04_no2/4.2.5.neuralnetwork.pdf

Page 6: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Neural network vs Learning network

Neural Network Deep Learning Network

Human Neural network vs. Machine Learning network

Page 7: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Traditional learning vs Deep Machine Learning

Eiffel Tower

Eiffel Tower

RAW data

RAW data

Deep Learning Network

FeatureExtraction

Vectored Classification

Traditional Learning

Deep Learning

Page 8: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Caffe

U.C. Berkley 개발C++, Python, MATLAB대표적인기계학습을위한공개소프트웨어

* Source: http://caffe.berkeleyvision.org

Page 9: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

TensorFlow

* Source: https://www.tensorflow.org/

Page 10: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Hierarchical Representation of Deep Learning

* Source: : Honglak Lee and colleagues (2011) as published in “Unsupervised Learning of Hierarchical Representations with Convolutional Deep Belief Networks”.

Page 11: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Hello World on TensorFlow

Page 12: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Image recognition in Google Map

* Source: Oriol Vinyals – Research Scientist at Google Brain

Page 13: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Hello World == MNIST

Data Sets data_sets.train 55000 images & labelsdata_sets.validation 5000 images & labelsdata_sets.test 10000 images & labels

Page 14: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

MNIST (predict number of image)

Page 15: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

MNIST beginner code

Page 16: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Face recognition?

Page 17: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

CIFAR-10

• CIFAR-10� 32x32 크기로 컬러 영상 � 10종류로 구분됨. � TensorFlow 예제: tensorflow/models/image/cifar10/

Page 18: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

CIFAR-10 Model

Data Sets data_sets.train 50000 images & labelsdata_sets.validation 1000 images & labelsdata_sets.test 10000 images & labels

Source: http://www.cs.toronto.edu/~kriz/cifar.html

Page 19: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

CIFAR-10 data• Image Data의 특징

� 10종류로 32x32로된 인식 +이미지로 구성� 학습 데이터(Training data)

� data_batch_1.bin, data_batch_2.bin, … , data_batch_5.bin� 테스트 데이터(Test data)

� test_batch.bin

• 1개의 이미지파일(image file)� 32(가로) x 32(세로) x 3(RGB) = 3072 byte� 3 tensor image (RGB)

• *참조: 텐서 플로우의 이미지 형식

tf.image_summary(tag, tensor, max_images=3, collections = None, Name=None) � [0, 255].unint8 � 1 tensor: Grayscale � 3 tensor: RGB � 4 tensor: RGBA

Page 20: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

CIFAR-10 learning networkLayer Name Descriptionconv1 convolution and rectified linear activation.

pool1 max pooling.

norm1 local response normalization.

conv2 convolution and rectified linear activation.norm2 local response normalization.pool2 max pooling.local3 fully connected layer with rectified linear activation.local4 fully connected layer with rectified linear activation.softmax_linear Linear transformation to produce logits

Page 21: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Source data: 얼굴 인식에 사용할 사진을 모으자!

Page 22: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Prepare: 사진에서얼굴만추출하자.

Page 23: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

OpenCV

Page 24: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Face Detection using Haar Cascades

Source: http://opencv-python-tutroals.r eadthedocs.io/en/latest/py_tutorials/py_objdetect/pya_face_detection/py_face_detec tion.html#face-detection

Page 25: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Open CV: face dectec code

Page 26: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

CIFAR-10 data• TFRecode file

� TensorFlow에 TFRcords를이용하여 binary 데이터를연속된 데이터로변형.� 연속된데이터를 Reader, Writer를이용해서 읽고쓸수 있다.� 고정길이가 아닌구조형 데이터도읽고쓰는 처리가능

� 1 image file 은� 32(가로) x 32(세로) x 3(RGB) = 3072 byte

� 1 label + 1 file image file 은� < 1 x label > < 3072 x pixel>

� 1000 label + 1000 image file � 32 * 32 * 3 * 1000 = 3 072 000 (3MB)

� Filenames, shuffling� [“files0”, “file1”], � (“file%d” % i) for I in range(2)

• tf.train.input_producer(input_tensor, element_shape=None, num_epochs=None, shuffle=True, seed=None, capacity=32, shared_name=None, summary_name=None, name=None)� input_tensor: 1차열로구성� element_shape: (Optional.) 입력 텐서의형태� num_epochs: (Optional.) � shuffle: (Optional.):데이터를 임으로섞어 놓을지?� seed: (Optional.):데이터의 씨앗을사용?� capacity: (Optional.):버퍼를사용한 입력.� name: (Optional.) 큐의이름

Page 27: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

CIFAR-10 data sets 형식으로바꾸자.

Page 28: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

CIFAR-10 에서대상을얼굴추출자료로바꾸자.

Page 29: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

TensorFlow Training

� 학습이 잘 된 것처럼 보이나되어서 평가를 해보면

Page 30: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

CNN layer를 바꿔가며 자신만의 방법을…• X2 conv layers

96 x 96 x 3

48 x 48 x 3224 x 24 x 64

12 x 12 x 128

6 x 6 x 256

(6 x 6 x 256) * 1024

1024 x 256

256 x 5

Cf. weight compare- cifar10:

- (5 x 5 x 3 x 64) + (5 x 5 x 64 x 64) + (4096 * 384) + (384 * 192) + (192 * 6)

= 1754944- X2 conv:

- (3 x 3 x 3 x 32) + (3 x 3x 32 x 64) + (3 x 3 x 64 x 128) + (3 x 3 x 128 x 256) + (9216 x 1024) + (1024 x 256) + (256 x 5)

= 10088544 (5.7x cifar10 )

Page 31: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

CNN 2x code

Page 32: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

소결!

• CIFAR-10을 응용하여 얼굴 인식을 해보자.

•이쁜 언니들 얼굴 자료를 모으고

•전체 사진에서 Open CV를 이용해서 CIFAR-10에 맞게 얼굴만을 데이터를 수정해서

• CIFAR-10 형식으로 데이터 변환했다.

•그리고 python cifar-10을 실행하니

•학습까지 잘되었다? 진짜!?!

Page 33: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

뭐가문제냐?

Page 34: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

face extraction

Page 35: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

#1. No. of Face data

Page 36: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

# 2. Face extraction method

Page 37: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

#3. advanced face detect

Page 38: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

#4 View side effect

Source: http://socialsciences.uow.edu.au/psychology/research/pcl/members/UOW040587.html

Page 39: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

#5 Emphasis?

Page 40: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

#6. Eigen faces

Source: http://jbhuang0604.blogspot.kr/2013/04/miss-korea-2013-contestants-face.html

Page 41: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

#6. Converging on the same face

Source: http://jbhuang0604.blogspot.kr/2013/04/miss-korea-2013-contestants-face.html

Page 42: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Make Her Beautiful?

Source: http://www.estherhonig.com

Page 43: Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Thanks you!

Q&A