tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho

Post on 16-Apr-2017

2.887 Views

Category:

Software

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

TensorFlow로얼굴을인식해보자.

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

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

hephaex@gmail.com

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

hephaex@gmail.com

Contents

• 우리가 본다!

• 기초부터 MNIST

• CIF영상인식

• 학습데이터만들기

• Tensorflow에 적용

• 그리고 전설로.

Human Intelligence

Human Brain

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

Neural network vs Learning network

Neural Network Deep Learning Network

Human Neural network vs. Machine Learning network

Traditional learning vs Deep Machine Learning

Eiffel Tower

Eiffel Tower

RAW data

RAW data

Deep Learning Network

FeatureExtraction

Vectored Classification

Traditional Learning

Deep Learning

Caffe

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

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

TensorFlow

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

Hierarchical Representation of Deep Learning

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

Hello World on TensorFlow

Image recognition in Google Map

* Source: Oriol Vinyals – Research Scientist at Google Brain

Hello World == MNIST

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

MNIST (predict number of image)

MNIST beginner code

Face recognition?

CIFAR-10

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

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

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

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

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

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

OpenCV

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

Open CV: face dectec code

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.) 큐의이름

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

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

TensorFlow Training

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

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 )

CNN 2x code

소결!

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

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

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

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

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

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

뭐가문제냐?

face extraction

#1. No. of Face data

# 2. Face extraction method

#3. advanced face detect

#4 View side effect

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

#5 Emphasis?

#6. Eigen faces

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

#6. Converging on the same face

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

Make Her Beautiful?

Source: http://www.estherhonig.com

Thanks you!

Q&A

top related