Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face...

88
Lecture 2 - Fei-Fei Li Lecture 2: A Case Study of Computer Vision – Face Recogni<on Professor FeiFei Li Stanford Vision Lab 24Sep12 1

Transcript of Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face...

Page 1: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Lecture  2:    A  Case  Study  of  Computer  Vision  –  

Face  Recogni<on  

Professor  Fei-­‐Fei  Li  Stanford  Vision  Lab  

24-­‐Sep-­‐12  1  

Page 2: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

What  we  will  learn  today  

•  Recogni<on  problems  •  Face  discrimina<on  

–  Principal  Component  Analysis  (PCA)  and  Eigenfaces  (Problem  Set  1  (Q1))  

–  Linear  Discriminant  Analysis  (LDA)  and  Fisherfaces  (supplementary  materials)  

•  Face  detec<on  –  SVM  (Problem  Set  0  (Q2))  –  Boos<ng  

24-­‐Sep-­‐12  2  

Page 3: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Courtesy  of  Johannes  M.  Zanker  

24-­‐Sep-­‐12  

“Faces”  in  the  brain  

3  

Page 4: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

“Faces”  in  the  brain  

24-­‐Sep-­‐12  

Kanwisher,  et  al.  1997  

4  

Page 5: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

•  Digital  photography  

Face  Recogni<on  

24-­‐Sep-­‐12  5  

Page 6: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Face  Recogni<on  •  Digital  photography  •  Surveillance  

24-­‐Sep-­‐12  6  

Page 7: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

•  Digital  photography  •  Surveillance  •  Album  organiza<on  

Face  Recogni<on  

24-­‐Sep-­‐12  7  

Page 8: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Face  Recogni<on  •  Digital  photography  •  Surveillance  •  Album  organiza<on  •  Person  tracking/id.  

24-­‐Sep-­‐12  8  

Page 9: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

•  Digital  photography  •  Surveillance  •  Album  organiza<on  •  Person  tracking/id.  •  Emo<ons  and  expressions  

Face  Recogni<on  

24-­‐Sep-­‐12  9  

Page 10: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

•  Digital  photography  •  Surveillance  •  Album  organiza<on  •  Person  tracking/id.  •  Emo<ons  and  expressions  

•  Security/warfare  •  Tele-­‐conferencing  •  Etc.  

Face  Recogni<on  

24-­‐Sep-­‐12  10  

Page 11: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

vs.  

Iden%fica%on  

What’s  ‘recogni<on’?  

24-­‐Sep-­‐12  11  

Page 12: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

What’s  ‘recogni<on’?  

vs.  

Categoriza%on  Iden<fica<on  

24-­‐Sep-­‐12  12  

Page 13: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Categoriza<on  Iden<fica<on  

No    

localiza%

on  

Yes,  there  are  faces  

24-­‐Sep-­‐12  13  

Page 14: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Categoriza<on  Iden<fica<on  

No    

localiza%

on  Yes,  there  is  John  Lennon  

24-­‐Sep-­‐12  14  

Page 15: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Categoriza<on  Iden<fica<on  

No    

localiza<

on  

Detec%on

 or  

Localizatoin  

John  Lennon  

24-­‐Sep-­‐12  15  

Page 16: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Categoriza<on  Iden<fica<on  

No    

localiza<

on  

Detec%on

 or  

Localizatoin  

24-­‐Sep-­‐12  16  

Page 17: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Pose  recogni<on  

Categoriza<on  Iden<fica<on  

No    

localiza<

on  

Detec%on

 or  

Localizatoin  

24-­‐Sep-­‐12  17  

Page 18: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Categoriza<on  Iden<fica<on  

No    

localiza<

on  

1.   PCA  &  Eigenfaces  (Turk  &  Pentland,  1991)  2.   LDA  &  Fisherfaces  (Bellumeur  et  al.  1997)  

3.   AdaBoost  (Viola  &  Jones,  2001)  

Detec<on

 or  

Localizatoin  

Milestone  Face  Recogni<on  methods  

24-­‐Sep-­‐12  18  

Page 19: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Eigenfaces  and  Fishfaces  –  Principle  Component  Analysis  (PCA)  –  Linear  Discriminant  Analysis  (LDA)  

1.  Turk  and  Pentland,  Eigenfaces  for  Recogni<on,  Journal  of  Cogni6ve  Neuroscience  3  (1):  71–86.  2.  P.  Belhumeur,  J.  Hespanha,  and  D.  Kriegman.  "Eigenfaces  vs.  Fisherfaces:  Recogni<on    Using  Class  Specific  Linear  Projec<on".  IEEE  Transac6ons  on  pa>ern  analysis  and  machine    intelligence  19  (7):  711.  1997.  

24-­‐Sep-­‐12  19  

Page 20: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

The  Space  of  Faces  

•  An  image  is  a  point  in  a  high  dimensional  space  –  If  represented  in  grayscale  intensity,  an  N  x  M  image  is  a  point  in  RNM   [T

hanks  to  Ch

uck  Dy

er,  Steve  Seitz,  N

ishino]  

24-­‐Sep-­‐12  20  

Page 21: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

•   Images  in  the  possible  set                                      are  highly  correlated.    

•   So,  compress  them  to  a  low-­‐dimensional  subspace  that      captures  key  appearance  characteris<cs  of  the  visual  DOFs.        

Key  Idea  

}x̂{=χ

•   USE  PCA  for  es<ma<ng  the  sub-­‐space          (dimensionality  reduc<on)  

• Compare  two  faces  by  projec<ng  the  images  into  the  subspace  and  measuring  the  EUCLIDEAN  distance  between  them.  

 EIGENFACES:  [Turk  and  Pentland  91]  

24-­‐Sep-­‐12  21  

Page 22: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

     

x1

x2

1 2

3

4

5

6

x1

x2

1 2

3

4

5

6

X1’

PCA  projec<on  

USE  PCA  for  es<ma<ng  the  sub-­‐space  

•   Computes  n-­‐dim  subspace  such  that  the  projec<on  of  the  data  points  onto  the  subspace  has  the  largest  variance  among  all  n-­‐dim  subspaces.          

24-­‐Sep-­‐12  22  

Page 23: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

x1

x2

1st principal component

2rd principal component

USE  PCA  for  es<ma<ng  the  sub-­‐space  

24-­‐Sep-­‐12  23  

Page 24: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Orthonormal                          

PCA  Mathema<cal  Formula<on  

Define  a  transforma<on,  W,        

m-­‐dimensional   n-­‐dimensional  

=  Data  Scarer  matrix  Tj

N

1jjT )xx)(xx(S −−∑=

=

N...2,1jxWy jT

j ==

PCA  =  eigenvalue  decomposi<on  of  a  data  covariance  matrix  

=  Transf.  data  scarer  matrix  WSW)yy)(yy(S~ TTT

j

N

1jjT =−−∑=

=

24-­‐Sep-­‐12  24  

𝑊↓𝑜𝑝𝑡 =𝑎𝑟𝑔𝑚𝑎𝑥↓𝑊 |𝑊↑𝑇 𝑆↓𝑇 𝑊|   =[𝑣↓1        𝑣↓2   ⋅⋅⋅     𝑣↓𝑚 ]  Eigenvectors  of  ST  

Page 25: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Image    space  

Face  space  

•   Maximize  the  scarer  of  the  training  images  in  face  space  

•   Computes  n-­‐dim  subspace  such  that  the  projec<on  of  the  data  points  onto  the  subspace  has  the  largest  variance  among  all  n-­‐dim  subspaces.          

24-­‐Sep-­‐12  25  

Page 26: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Eigenfaces  

•  PCA  extracts  the  eigenvectors  of  ST  –  Gives  a  set  of  vectors  v1,  v2,  v3,  ...  

– Each  one  of  these  vectors  is  a  direc<on  in  face  space:    

24-­‐Sep-­‐12  26  

Slide not used

Page 27: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Projec<ng  onto  the  Eigenfaces  •  The  eigenfaces  v1,  ...,  vK  span  the  space  of  faces    

–  A  face  is  converted  to  eigenface  coordinates  by  

24-­‐Sep-­‐12  27  

Page 28: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Algorithm  

1.  Align  training  images  x1,  x2,  …,  xN  

2.  Compute  average  face      u  =  1/N  Σ  xi    3.  Compute  the  difference  image  

 φi = xi – u

Training

Note  that  each  image  is  formulated  into  a  long  vector!  

24-­‐Sep-­‐12  28  

Page 29: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Tes%ng    1.  Take  query  image  X  2.  Project  X  into  Eigenface  space  (W  =  {eigenfaces})              and  compute  projec<on  ωi  =  W  (X  –  u),    3.      Compare  projec<on  ωi  with  all  training  N  projec<ons  ai      

ST  =  (1/N)  Σ  φi  φiT  =  BBT,        B=[φ1,  φ2  …  φN]  

4.  Compute  the  covariance  matrix  (total  scarer  matrix)    

5.  Compute  the  eigenvectors  of  the  covariance  matrix  ST    6.  Compute  training  projec<ons  a1,  a2...  aN  

Algorithm  

24-­‐Sep-­‐12  29  

Page 30: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Illustra<on  of  Eigenfaces  

These  are  the  first  4  eigenvectors  from  a  training  set  of  400  images  (ORL  Face  Database).    

•  The  visualiza<on  of  eigenvectors:  

24-­‐Sep-­‐12  30  

Page 31: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Eigenfaces  look  somewhat  like  generic  faces.  

24-­‐Sep-­‐12  31  

Page 32: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

•  Only  selec<ng  the  top  P  eigenfaces  à  reduces  the  dimensionality.    

•  Fewer  eigenfaces  result  in  more  informa<on  loss,  and  hence  less  discrimina<on  between  faces.  

Reconstruc<on  and  Errors  

P  =  4  

P  =  200  

P  =  400  

24-­‐Sep-­‐12  32  

Page 33: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Summary  for  Eigenface  

Pros  •  Non-­‐itera<ve,  globally  op<mal  solu<on  

Limita<ons  

• PCA  projec<on  is  op%mal  for  reconstruc%on  from  a  low  dimensional  basis,  but  may  NOT  be  op%mal  for  discrimina%on…    

• See  supplementary  materials  for  “Linear  Discrimina<ve  Analysis”,  aka  “Fisherfaces”  

24-­‐Sep-­‐12  33  

Page 34: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

•  Global  appearance  method:  not  robust  to  misalignment,  or  background  varia<on  

Limita<ons  

24-­‐Sep-­‐12  34  

Slide not used

Page 35: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Limita<ons  •  PCA  assumes  that  the  data  has  a  Gaussian  distribu<on  (mean  

µ,  covariance  matrix  Σ)  

The  shape  of  this  dataset  is  not  well  described  by  its  principal  components   Cred

it  slide

:  S.  Lazeb

nik  

24-­‐Sep-­‐12  35  

Slide not used

Page 36: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

PCA-­‐SIFT:  A  More  Dis<nc<ve  Representa<on  for  Local  Image  Descriptors  -­‐    Y  Ke,  R  Sukthankar  -­‐  IEEE  CVPR  04  

Extensions  

• PCA-­‐SIFT  

   

• Generalized  PCA:    R.  Vidal,  Y.  Ma,  and  S.  Sastry.    Generalized  Principal  Component  Analysis  (GPCA).    IEEE  Transac<ons  on  Parern  Analysis  and  Machine  Intelligence,  volume  27,  number  12,  pages  1  -­‐  15,  2005.      

• Tensor  Faces:  "Mul<linear  Analysis  of  Image  Ensembles:  TensorFaces,"  M.A.O.  Vasilescu,  D.  Terzopoulos,  Proc.  7th  European  Conference  on  Computer  Vision  (ECCV'02),  Copenhagen,  Denmark,  May,  2002  

24-­‐Sep-­‐12  36  

Slide not used

Page 37: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Categoriza<on  Iden<fica<on  

No    

localiza<

on  

1.   PCA  &  Eigenfaces  (Turk  &  Pentland,  1991)  2.   LDA  &  Fisherfaces  (Bellumeur  et  al.  1997)  

3.   AdaBoost  (Viola  &  Jones,  2001)  

Detec<on

 or  

Localizatoin  

Milestone  Face  Recogni<on  methods  

24-­‐Sep-­‐12  37  

Page 38: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

                       Features  

Decision  boundary  

Computer  screen  

Background  

In  some  feature  space  

Detec<ng  foreground  objects:  A  binary  classifica<on  formula<on  

24-­‐Sep-­‐12  38  

Page 39: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Linear  classifiers  •  Find  linear  func<on  (hyperplane)  to  separate  posi<ve  and  nega<ve  examples  

0:negative0:positive

<+⋅

≥+⋅

bb

ii

ii

wxxwxx

Which hyperplane is best?

w, b

24-­‐Sep-­‐12  39  

Page 40: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Support  vector  machines  •  Find  hyperplane  that  maximizes  the  margin  between  the  

posi<ve  and  nega<ve  examples  

Margin Support vectors

24-­‐Sep-­‐12  40  

Page 41: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

•  Datasets  that  are  linearly  separable  work  out  great:    

•       

•     

•  But  what  if  the  dataset  is  just  too  hard?      

•  We  can  map  it  to  a  higher-­‐dimensional  space:  

0 x

0 x

0 x

x2

Nonlinear  SVMs  

Slide credit: Andrew Moore

24-­‐Sep-­‐12  41  

Page 42: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Φ: x → φ(x)

Nonlinear  SVMs  •  General  idea:  the  original  input  space  can  always  be  mapped  

to  some  higher-­‐dimensional  feature  space  where  the  training  set  is  separable:  

li~ing  transforma<on  

24-­‐Sep-­‐12  42  

Slide credit: Andrew Moore

Page 43: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Each  data  point  has  

a  class  label:  

 

wt  =1  and  a  weight:  

+1  (          )  

-­‐1  (        )  yt  =  

Boos<ng  

•  It  is  a  sequen<al  procedure:    

 

xt=1  

xt=2  

xt  

Y. Freund and R. Schapire, A short introduction to boosting, Journal of Japanese Society for Artificial Intelligence, 14(5):771-780, September, 1999.

24-­‐Sep-­‐12  43  

Page 44: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Toy  example  Weak  learners  from  the  family  of  lines  

h  =>  p(error)  =  0.5    it  is  at  chance  

Each  data  point  has  

a  class  label:  

 

wt  =1  and  a  weight:  

24-­‐Sep-­‐12  44  

+1  (          )  

-­‐1  (        )  yt  =  

Page 45: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Toy  example  

This  one  seems  to  be  the  best  

This  is  a  ‘weak  classifier’:  It  performs  slightly  berer  than  chance.  

Each  data  point  has  

a  class  label:  

 

wt  =1  and  a  weight:  

24-­‐Sep-­‐12  45  

+1  (          )  

-­‐1  (        )  yt  =  

Page 46: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Toy  example  

Each  data  point  has  

a  class  label:  

 

wt          wt  exp{-­‐yt  Ht}  

We  update  the  weights:  

24-­‐Sep-­‐12  46  

+1  (          )  

-­‐1  (        )  yt  =  

Page 47: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Toy  example  

Each  data  point  has  

a  class  label:  

 

wt          wt  exp{-­‐yt  Ht}  

We  update  the  weights:  

24-­‐Sep-­‐12  47  

+1  (          )  

-­‐1  (        )  yt  =  

Page 48: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Toy  example  

Each  data  point  has  

a  class  label:  

 

wt          wt  exp{-­‐yt  Ht}  

We  update  the  weights:  

24-­‐Sep-­‐12  48  

+1  (          )  

-­‐1  (        )  yt  =  

Page 49: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Toy  example  

Each  data  point  has  

a  class  label:  

 

wt          wt  exp{-­‐yt  Ht}  

We  update  the  weights:  

24-­‐Sep-­‐12  49  

+1  (          )  

-­‐1  (        )  yt  =  

Page 50: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Toy  example  

The  strong  (non-­‐  linear)  classifier  is  built  as  the  combina<on  of  all  the  weak  (linear)  classifiers.  

f1   f2  

f3  

f4  

24-­‐Sep-­‐12  50  

Page 51: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

•  Defines  a  classifier  using  an  addi<ve  model:  

 

Boos<ng  

Strong    classifier  

Weak  classifier  

Weight  Features  vector  

24-­‐Sep-­‐12  

ℎ(𝑥)= 𝛼↓1 ℎ↓1 (𝑥)+ 𝛼↓2 ℎ↓2 (𝑥)+ 𝛼↓3 ℎ↓3 (𝑥)+…  

51  

Page 52: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

•  Defines  a  classifier  using  an  addi<ve  model:  

 

•  We  need  to  define  a  family  of  weak  classifiers  

 

Boos<ng  

Strong    classifier  

Weak  classifier  

Weight  Features  vector  

 form  a  family  of  weak  classifiers  

24-­‐Sep-­‐12  

ℎ(𝑥)= 𝛼↓1 ℎ↓1 (𝑥)+ 𝛼↓2 ℎ↓2 (𝑥)+ 𝛼↓3 ℎ↓3 (𝑥)+…  

ℎ↓𝑘 (𝑥)  

52  

Page 53: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

•  A  simple  algorithm  for  learning  robust  classifiers  –  Freund  &  Shapire,  1995  –  Friedman,  Has<e,  Tibshhirani,  1998  

•  Provides  efficient  algorithm  for  sparse  visual  feature  selec<on  –  Tieu  &  Viola,  2000  –  Viola  &  Jones,  2003  

•  Easy  to  implement,  not  requires  external  op<miza<on  tools.  

 

Why  boos<ng?  

24-­‐Sep-­‐12  53  

Page 54: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

•  Weak  learners  

value of rectangle feature

threshold

1 if ( )( )

0 otherwisej j

j

f xh x

θ>⎧= ⎨⎩

Boos<ng  -­‐  mathema<cs    

1 1

11 ( )( ) 2

0 otherwise

T Tt t tt th x

h xα α

= =

⎧ ≥⎪= ⎨⎪⎩

∑ ∑

•     Final  strong  classifier    

24-­‐Sep-­‐12  54  

Page 55: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Weak  classifier  

• 4  kind  of  Rectangle  filters    • Value  =      ∑  (pixels  in  white  area)  –    ∑  (pixels  in  black  area)  

 

Credit  slide:  S.  Lazebnik  

24-­‐Sep-­‐12  55  

Page 56: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Source

Result

Credit  slide:  S.  Lazebnik  

Weak  classifier  

24-­‐Sep-­‐12  56  

Page 57: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

….. 1( ,1)x 2( ,1)x 3( ,0)x 4( ,0)x

( , )n nx y1α

5( ,0)x 6( ,0)x

Weak classifier threshold

1 if ( )( )

0 otherwisej j

j

f xh x

θ>⎧= ⎨⎩

1.  Evaluate  each  rectangle  filter  on  each  example  

Viola  &  Jones  algorithm  

0.8   0.7   0.2   0.3   0.8   0.1  

24-­‐Sep-­‐12  

P. Viola and M. Jones. Rapid object detection using a boosted cascade of simple features. CVPR 2001.

57  

Page 58: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

•  For  a  24x24  detec<on  region,    

24-­‐Sep-­‐12  

Viola  &  Jones  algorithm  

P. Viola and M. Jones. Rapid object detection using a boosted cascade of simple features. CVPR 2001.

58  

Page 59: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

b. For each feature, j   ( )j i j i iiw h x yε = −∑

1 if ( )( )

0 otherwisej j

j

f xh x

θ>⎧= ⎨⎩

c. Choose the classifier, ht with the lowest error tε

1 ( )1, ,

t i ih x yt i t i tw w β − −+ =

1t

tt

εβ

ε=

2.  Select  best  filter/threshold  combina<on  ,

,,1

t it i n

t jj

ww

w=

←∑a. Normalize the weights

3.  Reweight  examples  

24-­‐Sep-­‐12  

Viola  &  Jones  algorithm  

P. Viola and M. Jones. Rapid object detection using a boosted cascade of simple features. CVPR 2001.

59  

Page 60: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

4.  The  final  strong  classifier  is  

1 1

11 ( )( ) 2

0 otherwise

T Tt t tt th x

h xα α

= =

⎧ ≥⎪= ⎨⎪⎩

∑ ∑1logtt

αβ

=

The  final  hypothesis  is  a  weighted  linear  combina<on  of  the  T    hypotheses  where  the  weights  are  inversely  propor<onal  to  the  training  errors  

24-­‐Sep-­‐12  

Viola  &  Jones  algorithm  

P. Viola and M. Jones. Rapid object detection using a boosted cascade of simple features. CVPR 2001.

60  

Page 61: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Feature  selec<on  

Discrimina<ve  features  Non  discrimina<ve  features  

24-­‐Sep-­‐12  61  

Slide not used

Page 62: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

•  A  “paradigma<c”  method  for  real-­‐<me  object  detec<on    

•  Training  is  slow,  but  detec<on  is  very  fast  •  Key  ideas  

–  Integral  images  for  fast  feature  evalua<on  – Boos6ng  for  feature  selec<on  – A>en6onal  cascade  for  fast  rejec<on  of  non-­‐face  windows  

Cred

it  slide

:  S.  Lazeb

nik  

24-­‐Sep-­‐12  

Viola  &  Jones  algorithm  

P. Viola and M. Jones. Rapid object detection using a boosted cascade of simple features. CVPR 2001.

62  

Page 63: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

•  For  each  round  of  boos<ng:  1.  Evaluate  each  rectangle  filter  on  each  example  2.  Select  best  filter/threshold  combina<on  3.  Reweight  examples  

Boos<ng  for  face  detec<on  

24-­‐Sep-­‐12  63  

Slide not used

Page 64: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

The  implemented  system  •  Training  Data  

–  5000  faces  •  All  frontal,  rescaled  to    24x24  pixels  

–  300  million    non-­‐faces  •  9500  non-­‐face  images  

–  Faces  are  normalized  •  Scale,  transla<on  

•  Many  varia<ons  –  Across  individuals  –  Illumina<on  –  Pose  

24-­‐Sep-­‐12  

P. Viola and M. Jones. Rapid object detection using a boosted cascade of simple features. CVPR 2001.

64  

Page 65: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

System  performance  •  Training  <me:  “weeks”  on  466  MHz  Sun  worksta<on  •  38  layers,  total  of  6061  features  •  Average  of  10  features  evaluated  per  window  on  test  set  •  “On  a  700  Mhz  Pen<um  III  processor,  the  face  detector  can  

process  a  384  by  288  pixel  image  in  about  .067  seconds”    –  15  Hz  –  15  <mes  faster  than  previous  detector  of  comparable  accuracy  

(Rowley  et  al.,  1998)  

24-­‐Sep-­‐12  

P. Viola and M. Jones. Rapid object detection using a boosted cascade of simple features. CVPR 2001.

65  

Page 66: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Output  of  Face  Detector  on  Test  Images  

24-­‐Sep-­‐12  

P. Viola and M. Jones. Rapid object detection using a boosted cascade of simple features. CVPR 2001.

66  

Page 67: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Other  detec<on  tasks    

Facial Feature Localization

Male vs. female

Profile Detection

24-­‐Sep-­‐12  67  

Page 68: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Profile  Detec<on  

24-­‐Sep-­‐12  68  

Page 69: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Profile  Features    

24-­‐Sep-­‐12  69  

Page 70: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Face  Image  Databases  

•  Databases  for  face  recogni<on  can  be  best  u<lized  as  training  sets  – Each  image  consists  of  an  individual  on  a  uniform  and  unclurered  background  

•  Test  Sets  for  face  detec<on  – MIT,  CMU  (frontal,  profile),  Kodak  

24-­‐Sep-­‐12  70  

Page 71: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Experimental  Results  

•  Test  dataset  – MIT+CMU  frontal  face  test  set  –  130  images  with  507  labeled  frontal  faces  

MIT test set: 23 images with 149 faces Sung & poggio: detection rate 79.9% with 5 false positive AdaBoost: detection rate 77.8% with 5 false positives

False detection 10 31 50 65 78 95 110 167 422

AdaBoost 78.3 85.2 88.8 89.8 90.1 90.8 91.1 91.8 93.7

Neural-net 83.2 86.0 - - - 89.2 - 90.1 89.9

24-­‐Sep-­‐12  71  

Page 72: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Experimental  Results  

-> not significantly different accuracy

-> but the cascade class. almost 10 times faster  

24-­‐Sep-­‐12  72  

Slide not used

Page 73: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Sharing  features  with  Boos<ng    

Matlab  code  

•   Gentle  boos<ng  

•   Object  detector  using  a  part  based  model  

hrp://people.csail.mit.edu/torralba/iccv2005/  

Sharing  features:  efficient  boos<ng  procedures  for  mul<class  object  detec<on  A.  Torralba,  K.  P.  Murphy  and  W.  T.  Freeman  Proceedings  of  the  IEEE  Computer  Society  Conference  on  Computer  Vision  and  Parern  Recogni<on  (CVPR).  pp  762-­‐769,  2004.    

24-­‐Sep-­‐12  73  

Slide not used

Page 74: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

What  we  have  learned  today  

24-­‐Sep-­‐12  

•  Recogni<on  problems  •  Face  discrimina<on  

–  Principal  Component  Analysis  (PCA)  and  Eigenfaces  (Problem  Set  1  (Q1))  

–  Linear  Discriminant  Analysis  (LDA)  and  Fisherfaces  (supplementary  materials)  

•  Face  detec<on  –  SVM  (Problem  Set  0  (Q2))  –  Boos<ng  

74  

Page 75: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Supplementary  materials  

24-­‐Sep-­‐12  75  

Page 76: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Fisher  Faces:  Linear  Discriminant  Analysis  

24-­‐Sep-­‐12  76  

Page 77: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Linear  Discriminant  Analysis  (LDA)    Fisher’s  Linear  Discriminant  (FLD)  

   

•  Eigenfaces  exploit  the  max  scarer  of  the  training  images  in  face  space  

•  Fisherfaces  arempt  to  maximise  the  between  class  scaPer,  while  minimising  the  within  class  scaPer.  

24-­‐Sep-­‐12  77  

Page 78: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Illustra<on  of  the  Projec<on  

               Poor  Projec<on  

x1

x2

x1

x2

w  Using  two  classes  as  example:  

Good  

24-­‐Sep-­‐12  78  

Page 79: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Comparing  with  PCA  

24-­‐Sep-­‐12  79  

Page 80: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Variables  

•  N  Sample  images:    •  c  classes:  

•  Average  of  each  class:    

•  Total  average:    

{ }Nxx ,,1

{ }cχχ ,,1

∑=∈ ikx

ki

i xN χ

µ1

∑==

N

kkxN 1

24-­‐Sep-­‐12  80  

Page 81: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Scarers  

•  Scarer  of  class  i:   ( )( )Tikx

iki xxSik

µµχ

−∑ −=∈

∑==

c

iiW SS

1

( )( )∑ −−==

c

i

TiiiBS

1µµµµχ

BWT SSS +=

• Within  class  scarer:  

•  Between  class  scarer:  

•  Total  scarer:  

24-­‐Sep-­‐12  81  

Page 82: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Illustra<on  

2S

1S

BS

21 SSSW +=

x1

x2 Within  class  scarer  

Between  class  scarer  

( )( )Tikx

iki xxSik

µµχ

−∑ −=∈

∑==

c

iiW SS

1( )( )∑ −−=

=

c

i

TiiiBS

1µµµµχ

24-­‐Sep-­‐12  82  

Page 83: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Mathema<cal  Formula<on  (1)  

•  A~er  projec<on:

•  Between  class  scarer  (of  y’s):  • Within  class  scarer  (of  y’s):  

kT

k xWy =

WSWS BT

B =~

WSWS WT

W =~

24-­‐Sep-­‐12  83  

Page 84: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Illustra<on  

2~S

1~S

BS~

21~~~ SSSW +=

x1

x2 kT

k xWy =

WSWS BT

B =~WSWS W

TW =~

∑==

c

iiW SS

1( )( )∑ −−=

=

c

i

TiiiBS

1µµµµχ

24-­‐Sep-­‐12  84  

Page 85: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Mathema<cal  Formula<on  •  The  desired  projec<on:  

WSW

WSW

SS

WW

TB

T

W

Bopt WW

max arg~~

max arg ==

miwSwS iWiiB ,,1 …== λ

•  How  is  it  found  ?  à  Generalized  Eigenvectors  

•  If  Sw  has  full  rank,  the  generalized  eigenvectors  are  eigenvectors  of  SW-­‐1  SB    with  largest  eigen-­‐values  

24-­‐Sep-­‐12  85  

Page 86: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Training/  Tes%ng      

Projec<on  in  Eigenface      Projec<on  ωi  =  W  opt  (X  –  u),        Wopt  =  {fisher-­‐faces}  

 

24-­‐Sep-­‐12  86  

Page 87: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Results:  Eigenface  vs.  Fisherface  (1)  

•  Variation in Facial Expression, Eyewear, and Lighting

•  Input:  160  images  of  16  people  •  Train:  159  images  •  Test:  1  image  

With glasses  

Without glasses  

3 Lighting conditions   5 expressions  

24-­‐Sep-­‐12  87  

Page 88: Lecture’2:’’ A’Case’Study’of’Computer’Vision’– Face ...vision.stanford.edu/teaching/cs231a_autumn1213/...Lecture 2 - !!! Fei-Fei Li! Lecture’2:’’ A’Case’Study’of’Computer’Vision’–

Lecture 2 - !!!

Fei-Fei Li!

Eigenface  vs.  Fisherface  (2)  

24-­‐Sep-­‐12  88