CS 3710: Vsual Recognton Classfcaton and Detecton Adrana Kovashka Department of Computer Scence January 13, 2015
Plan for Today Vsual recognton bascs part 2: Classfcaton and detecton Adrana s research Net tme: Frst student presentaton
Classfcaton vs Detecton Classfcaton Gven an mage or an mage regon, determne whch of N categores t represents Detecton Determne where n the mage a category s to be found
Classfcaton
James Hays
The machne learnng framework Apply a predcton functon to a feature representaton of the mage to get the desred output: f( ) = apple f( ) = tomato f( ) = cow Svetlana Lazebnk
The machne learnng framework y = f() output predcton functon mage features Tranng: gven a tranng set of labeled eamples {( 1,y 1 ),, ( N,y N )}, estmate the predcton functon f by mnmzng the predcton error on the tranng set Testng: apply f to a never before seen test eample and output the predcted value y = f() Svetlana Lazebnk
Tranng Steps Tranng Images Tranng Labels Image Features Tranng Learned model Testng Test Image Image Features Learned model Predcton Derek Hoem, Svetlana Lazebnk
Recognton task and supervson Images n the tranng set must be annotated wth the correct answer that the model s epected to produce Contans a motorbke Svetlana Lazebnk
Generalzaton How well does a learned model generalze from the data t was traned on to a new test set? Tranng set (labels known) Test set (labels unknown) Svetlana Lazebnk
Classfcaton Assgn nput vector to one of two or more classes Any decson rule dvdes the nput space nto decson regons separated by decson boundares Svetlana Lazebnk
Supervsed classfcaton Gven a collecton of labeled eamples, come up wth a functon that wll predct the labels of new eamples. four nne Tranng eamples? Novel nput How good s some functon that we come up wth to do the classfcaton? Depends on Krsten Grauman Mstakes made Cost assocated wth the mstakes
Supervsed classfcaton Gven a collecton of labeled eamples, come up wth a functon that wll predct the labels of new eamples. Consder the two-class (bnary) decson problem L(4 9): Loss of classfyng a 4 as a 9 L(9 4): Loss of classfyng a 9 as a 4 Rsk of a classfer s s epected loss: 4 9 usng sl4 9 Pr9 4 usng sl9 4 R( s) Pr We want to choose a classfer so as to mnmze ths total rsk Krsten Grauman
Supervsed classfcaton Optmal classfer wll mnmze total rsk. Feature value At decson boundary, ether choce of label yelds same epected loss. If we choose class four at boundary, epected loss s: P( class s 9 ) L(9 4) P(class s 4 ) L(4 4) If we choose class nne at boundary, epected loss s: P( class s 4 ) L(4 9) So, best decson boundary s at pont where P( class s 9 ) L(9 4) P(class s 4 ) L(4 9) Krsten Grauman
Supervsed classfcaton Optmal classfer wll mnmze total rsk. Feature value At decson boundary, ether choce of label yelds same epected loss. To classfy a new pont, choose class wth lowest epected loss;.e., choose four f P( 9 ) L(9 4) P(4 ) L(4 9) Loss for choosng four Loss for choosng nne Krsten Grauman
Supervsed classfcaton P(4 ) P(9 ) Feature value Optmal classfer wll mnmze total rsk. At decson boundary, ether choce of label yelds same epected loss. To classfy a new pont, choose class wth lowest epected loss;.e., choose four f P( 9 ) L(9 4) P(4 ) L(4 9) Loss for choosng four Loss for choosng nne Krsten Grauman How to evaluate these probabltes?
Classfers: Nearest neghbor Tranng eamples from class 1 Test eample Tranng eamples from class 2 f() = label of the tranng eample nearest to All we need s a dstance functon for our nputs No tranng requred! Svetlana Lazebnk
1-nearest neghbor o o + o o o o + 2 o 1 James Hays
5-nearest neghbor o o + o o o o + 2 o 1 James Hays
Lnear classfers C. Burges, A Tutoral on Support Vector Machnes for Pattern Recognton, Data Mnng and Knowledge Dscovery, 1998
Lnes n R 2 Let w a c y a cy b 0 Krsten Grauman
Lnes n R 2 Let w a c y w a cy b 0 w b 0 Krsten Grauman
0, y 0 Lnes n R 2 Let w a c y w a cy b 0 w b 0 Krsten Grauman
0, y 0 D Lnes n R 2 Let w a c y w a cy b 0 w b 0 D Krsten Grauman a a 2 cy c 2 b w w 0 0 dstance from b pont to lne
0, y 0 D Lnes n R 2 Let w a c y w a cy b 0 w b 0 D Krsten Grauman a a 2 cy c 2 b w w 0 0 dstance from b pont to lne
Lnear classfers Fnd lnear functon to separate postve and negatve eamples postve negatve : : w w b b 0 0 Whch lne s best? C. Burges, A Tutoral on Support Vector Machnes for Pattern Recognton, Data Mnng and Knowledge Dscovery, 1998
Support vector machnes Dscrmnatve classfer based on optmal separatng lne (for 2d case) Mamze the margn between the postve and negatve tranng eamples C. Burges, A Tutoral on Support Vector Machnes for Pattern Recognton, Data Mnng and Knowledge Dscovery, 1998
Support vector machnes Want lne that mamzes the margn. postve negatve ( y ( y 1) : 1) : w b 1 w b 1 For support, vectors, w b 1 Support vectors Margn C. Burges, A Tutoral on Support Vector Machnes for Pattern Recognton, Data Mnng and Knowledge Dscovery, 1998
Support vector machnes Want lne that mamzes the margn. postve negatve ( y ( y 1) : 1) : w b 1 w b 1 Support vectors Margn For support, vectors, w b 1 Dstance between pont w b and lne: w For support vectors: Τ w b 1 1 1 2 M w w w w w C. Burges, A Tutoral on Support Vector Machnes for Pattern Recognton, Data Mnng and Knowledge Dscovery, 1998
Support vector machnes Want lne that mamzes the margn. postve negatve ( y ( y 1) : 1) : w b 1 w b 1 For support, vectors, w b 1 Dstance between pont w b and lne: w Support vectors Margn Therefore, the margn s 2 / w C. Burges, A Tutoral on Support Vector Machnes for Pattern Recognton, Data Mnng and Knowledge Dscovery, 1998
Fndng the mamum margn lne 1. Mamze margn 2/ w 2. Correctly classfy all tranng data ponts: postve ( y negatve ( y 1) : 1) : w b 1 w b 1 Quadratc optmzaton problem: Mnmze 1 w T w 2 Subject to y (w +b) 1 One constrant for each tranng pont. Note sgn trck. C. Burges, A Tutoral on Support Vector Machnes for Pattern Recognton, Data Mnng and Knowledge Dscovery, 1998
Fndng the mamum margn lne Soluton: w y Learned weght Support vector C. Burges, A Tutoral on Support Vector Machnes for Pattern Recognton, Data Mnng and Knowledge Dscovery, 1998
Fndng the mamum margn lne Soluton: w y b = y w Classfcaton functon: f ( ) sgn sgn (for any support vector) ( w b) y Notce that t reles on an nner product between the test pont and the support vectors (Solvng the optmzaton problem also nvolves computng the nner products j between all pars of tranng ponts) b If f() < 0, classfy as negatve, otherwse classfy as postve. C. Burges, A Tutoral on Support Vector Machnes for Pattern Recognton, Data Mnng and Knowledge Dscovery, 1998
Nonlnear SVMs Datasets that are lnearly separable work out great: 0 But what f the dataset s just too hard? 0 We can map t to a hgher-dmensonal space: 2 Andrew Moore 0
Nonlnear SVMs General dea: the orgnal nput space can always be mapped to some hgher-dmensonal feature space where the tranng set s separable: Φ: φ() Andrew Moore
Nonlnear SVMs The kernel trck: nstead of eplctly computng the lftng transformaton φ(), defne a kernel functon K such that K(, j ) = φ( ) φ( j ) Andrew Moore
Eamples of kernel functons Lnear: K(, j ) T j Gaussan RBF: K(, j ) ep( 2 2 Hstogram ntersecton: j 2 ) K (, j ) mn( ( k), j ( k)) k Andrew Moore
Summary: SVMs for mage classfcaton 1. Pck an mage representaton 2. Pck a kernel functon for that representaton 3. Compute the matr of kernel values between every par of tranng eamples 4. Feed the kernel matr nto your favorte SVM solver to obtan support vectors and weghts 5. At test tme: compute kernel values for your test eample and each support vector, and combne them wth the learned weghts to get the value of the decson functon Svetlana Lazebnk
What about mult-class SVMs? Unfortunately, there s no defntve mult-class SVM formulaton In practce, we have to obtan a mult-class SVM by combnng multple two-class SVMs One vs. others Tranng: learn an SVM for each class vs. the others Testng: apply each SVM to the test eample, and assgn t to the class of the SVM that returns the hghest decson value One vs. one Tranng: learn an SVM for each par of classes Testng: each learned SVM votes for a class to assgn to the test eample Svetlana Lazebnk
Detecton
PASCAL Vsual Object Challenge aeroplane bke brd boat bottle bus car cat char cow table dog horse motorbke person plant sheep sofa tran tv Deva Ramanan
Detecton: Scannng-wndow templates Dalal and Trggs CVPR05 (HOG) Papageorgou and Poggo ICIP99 (wavelets) pos neg w w = weghts for orentaton and spatal bns Deva Ramanan w > 0
Deformable part models Model encodes local appearance + sprng deformaton Deva Ramanan
Homework for Net Tme Paper revew for Features due at 10pm on 1/14, send to kovashka@cs.ptt.edu