SlideShare a Scribd company logo
Bag-of-Words models
Lecture 9
Slides from: S. Lazebnik, A. Torralba, L. Fei-Fei, D. Lowe, C. Szurka
Bag-of-features models
Overview: Bag-of-features models
• Origins and motivation
• Image representation
• Discriminative methods
– Nearest-neighbor classification
– Support vector machines
• Generative methods
– Naïve Bayes
– Probabilistic Latent Semantic Analysis
• Extensions: incorporating spatial information
Origin 1: Texture recognition
• Texture is characterized by the repetition of basic
elements or textons
• For stochastic textures, it is the identity of the textons,
not their spatial arrangement, that matters
Julesz, 1981; Cula & Dana, 2001; Leung & Malik 2001; Mori, Belongie & Malik, 2001; Schmid
2001; Varma & Zisserman, 2002, 2003; Lazebnik, Schmid & Ponce, 2003
Origin 1: Texture recognition
Universal texton dictionary
histogram
Julesz, 1981; Cula & Dana, 2001; Leung & Malik 2001; Mori, Belongie & Malik, 2001; Schmid
2001; Varma & Zisserman, 2002, 2003; Lazebnik, Schmid & Ponce, 2003
Origin 2: Bag-of-words models
• Orderless document representation: frequencies
of words from a dictionary Salton & McGill (1983)
Origin 2: Bag-of-words models
US Presidential Speeches Tag Cloud
http://chir.ag/phernalia/preztags/
• Orderless document representation: frequencies
of words from a dictionary Salton & McGill (1983)
Origin 2: Bag-of-words models
US Presidential Speeches Tag Cloud
http://chir.ag/phernalia/preztags/
• Orderless document representation: frequencies
of words from a dictionary Salton & McGill (1983)
Origin 2: Bag-of-words models
US Presidential Speeches Tag Cloud
http://chir.ag/phernalia/preztags/
• Orderless document representation: frequencies
of words from a dictionary Salton & McGill (1983)
Bags of features for image
classification
1. Extract features
1. Extract features
2. Learn “visual vocabulary”
Bags of features for image
classification
1. Extract features
2. Learn “visual vocabulary”
3. Quantize features using visual vocabulary
Bags of features for image
classification
1. Extract features
2. Learn “visual vocabulary”
3. Quantize features using visual vocabulary
4. Represent images by frequencies of
“visual words”
Bags of features for image
classification
• Regular grid
– Vogel & Schiele, 2003
– Fei-Fei & Perona, 2005
1. Feature extraction
• Regular grid
– Vogel & Schiele, 2003
– Fei-Fei & Perona, 2005
• Interest point detector
– Csurka et al. 2004
– Fei-Fei & Perona, 2005
– Sivic et al. 2005
1. Feature extraction
• Regular grid
– Vogel & Schiele, 2003
– Fei-Fei & Perona, 2005
• Interest point detector
– Csurka et al. 2004
– Fei-Fei & Perona, 2005
– Sivic et al. 2005
• Other methods
– Random sampling (Vidal-Naquet & Ullman, 2002)
– Segmentation-based patches (Barnard et al. 2003)
1. Feature extraction
Normalize patch
Detect patches
[Mikojaczyk and Schmid ’02]
[Mata, Chum, Urban & Pajdla, ’02]
[Sivic & Zisserman, ’03]
Compute SIFT
descriptor
[Lowe’99]
Slide credit: Josef Sivic
1. Feature extraction
…
1. Feature extraction
2. Learning the visual vocabulary
…
2. Learning the visual vocabulary
Clustering
…
Slide credit: Josef Sivic
2. Learning the visual vocabulary
Clustering
…
Slide credit: Josef Sivic
Visual vocabulary
K-means clustering
• Want to minimize sum of squared
Euclidean distances between points xi and
their nearest cluster centers mk
• Algorithm:
• Randomly initialize K cluster centers
• Iterate until convergence:
– Assign each data point to the nearest center
– Recompute each cluster center as the mean of
all points assigned to it
k
k
i
ki mxMXD
cluster
cluster
inpoint
2
)(),(
From clustering to vector quantization
• Clustering is a common method for learning a visual
vocabulary or codebook
– Unsupervised learning process
– Each cluster center produced by k-means becomes a
codevector
– Codebook can be learned on separate training set
– Provided the training set is sufficiently representative,
the codebook will be “universal”
• The codebook is used for quantizing features
– A vector quantizer takes a feature vector and maps it to
the index of the nearest codevector in a codebook
– Codebook = visual vocabulary
– Codevector = visual word
Example visual vocabulary
Fei-Fei et al. 2005
Image patch examples of visual words
Sivic et al. 2005
Visual vocabularies: Issues
• How to choose vocabulary size?
– Too small: visual words not representative of all
patches
– Too large: quantization artifacts, overfitting
• Generative or discriminative learning?
• Computational efficiency
– Vocabulary trees
(Nister & Stewenius, 2006)
3. Image representation
…..
frequency
codewords
Image classification
• Given the bag-of-features representations of
images from different classes, how do we
learn a model for distinguishing them?
Discriminative and generative methods for
bags of features
Zebra
Non-zebra
Image classification
• Given the bag-of-features representations of
images from different classes, how do we
learn a model for distinguishing them?
Discriminative methods
• Learn a decision rule (classifier) assigning bag-
of-features representations of images to
different classes
Zebra
Non-zebra
Decision
boundary
Classification
• Assign input vector to one of two or more
classes
• Any decision rule divides input space into
decision regions separated by decision
boundaries
Nearest Neighbor Classifier
• Assign label of nearest training data point
to each test data point
Voronoi partitioning of feature space
for two-category 2D and 3D data
from Duda et al.
Source: D. Lowe
• For a new point, find the k closest points from training
data
• Labels of the k points “vote” to classify
• Works well provided there is lots of data and the distance
function is good
K-Nearest Neighbors
k = 5
Source: D. Lowe
Functions for comparing histograms
• L1 distance
• χ2 distance
• Quadratic distance (cross-bin)
N
i
ihihhhD
1
2121 |)()(|),(
Jan Puzicha, Yossi Rubner, Carlo Tomasi, Joachim M. Buhmann: Empirical Evaluation of
Dissimilarity Measures for Color and Texture. ICCV 1999
N
i ihih
ihih
hhD
1 21
2
21
21
)()(
)()(
),(
ji
ij jhihAhhD
,
2
2121 ))()((),(
Earth Mover’s Distance
• Each image is represented by a signature S consisting of a
set of centers {mi } and weights {wi }
• Centers can be codewords from universal vocabulary,
clusters of features in the image, or individual features (in
which case quantization is not required)
• Earth Mover’s Distance has the form
where the flows fij are given by the solution of a
transportation problem
Y. Rubner, C. Tomasi, and L. Guibas: A Metric for Distributions with Applications to Image
Databases. ICCV 1998
ji ij
jiij
f
mmdf
SSEMD
,
21
21
),(
),(
Linear classifiers
• Find linear function (hyperplane) to separate
positive and negative examples
0:negative
0:positive
b
b
ii
ii
wxx
wxx
Which hyperplane
is best?
Slide: S. Lazebnik
Support vector machines
• Find hyperplane that maximizes the margin
between the positive and negative examples
C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining and
Knowledge Discovery, 1998
Support vector machines
• Find hyperplane that maximizes the margin
between the positive and negative examples
1:1)(negative
1:1)(positive
by
by
iii
iii
wxx
wxx
MarginSupport vectors
C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining and
Knowledge Discovery, 1998
Distance between point
and hyperplane: ||||
||
w
wx bi
For support vectors, 1bi wx
Therefore, the margin is 2 / ||w||
Finding the maximum margin
hyperplane
1. Maximize margin 2/||w||
2. Correctly classify all training data:
• Quadratic optimization problem:
• Minimize
Subject to yi(w·xi+b) ≥ 1
C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining and
Knowledge Discovery, 1998
wwT
2
1
1:1)(negative
1:1)(positive
by
by
iii
iii
wxx
wxx
Finding the maximum margin
hyperplane
• Solution: i iii y xw
C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining and
Knowledge Discovery, 1998
Support
vector
learned
weight
Finding the maximum margin hyperplane
• Solution:
b = yi – w·xi for any support vector
• Classification function (decision boundary):
• Notice that it relies on an inner product between
the test point x and the support vectors xi
• Solving the optimization problem also involves
computing the inner products xi · xj between all
pairs of training points
i iii y xw
C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining and
Knowledge Discovery, 1998
byb i iii xxxw
• 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
Φ: 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:
Slide credit: Andrew Moore
Nonlinear SVMs
• The kernel trick: instead of explicitly
computing the lifting transformation φ(x),
define a kernel function K such that
K(xi,xj) = φ(xi ) · φ(xj)
• (to be valid, the kernel function must satisfy
Mercer’s condition)
• This gives a nonlinear decision boundary in
the original feature space:
bKy
i
iii ),( xx
C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining and
Knowledge Discovery, 1998
Kernels for bags of features
• Histogram intersection kernel:
• Generalized Gaussian kernel:
• D can be Euclidean distance, χ2 distance, Earth
Mover’s Distance, etc.
N
i
ihihhhI
1
2121 ))(),(min(),(
2
2121 ),(
1
exp),( hhD
A
hhK
J. Zhang, M. Marszalek, S. Lazebnik, and C. Schmid, Local Features and Kernels for Classifcation
of Texture and Object Categories: A Comprehensive Study, IJCV 2007
Summary: SVMs for image classification
1. Pick an image representation (in our case, bag
of features)
2. Pick a kernel function for that representation
3. Compute the matrix of kernel values between
every pair of training examples
4. Feed the kernel matrix into your favorite SVM
solver to obtain support vectors and weights
5. At test time: compute kernel values for your
test example and each support vector, and
combine them with the learned weights to get
the value of the decision function
What about multi-class SVMs?
• Unfortunately, there is no “definitive” multi-class SVM
formulation
• In practice, we have to obtain a multi-class SVM by
combining multiple two-class SVMs
• One vs. others
– Traning: learn an SVM for each class vs. the others
– Testing: apply each SVM to test example and assign to it the
class of the SVM that returns the highest decision value
• One vs. one
– Training: learn an SVM for each pair of classes
– Testing: each learned SVM “votes” for a class to assign to the
test example
Slide: S. Lazebnik
SVMs: Pros and cons
• Pros
– Many publicly available SVM packages:
http://www.kernel-machines.org/software
– Kernel-based framework is very powerful, flexible
– SVMs work very well in practice, even with very
small training sample sizes
• Cons
– No “direct” multi-class SVM, must combine two-
class SVMs
– Computation, memory
• During training time, must compute matrix of kernel
values for every pair of examples
• Learning can take a very long time for large-scale
problems
Slide: S. Lazebnik
Summary: Discriminative methods
• Nearest-neighbor and k-nearest-neighbor classifiers
– L1 distance, χ2 distance, quadratic distance,
Earth Mover’s Distance
• Support vector machines
– Linear classifiers
– Margin maximization
– The kernel trick
– Kernel functions: histogram intersection, generalized
Gaussian, pyramid match
– Multi-class
• Of course, there are many other classifiers out there
– Neural networks, boosting, decision trees, …
Generative learning methods for bags of features
• Model the probability of a bag of features
given a class
Generative methods
• We will cover two models, both inspired by
text document analysis:
– Naïve Bayes
– Probabilistic Latent Semantic Analysis
The Naïve Bayes model
Csurka et al. 2004
• Assume that each feature is conditionally
independent given the class
fi: ith feature in the image
N: number of features in the image
N
i
iN cfpcffp
1
1 )|()|,,( 
The Naïve Bayes model
Csurka et al. 2004
M
j
wn
j
N
i
iN
j
cwpcfpcffp
1
)(
1
1 )|()|()|,,( 
• Assume that each feature is conditionally
independent given the class
wj: jth visual word in the vocabulary
M: size of visual vocabulary
n(wj): number of features of type wj in the image
fi: ith feature in the image
N: number of features in the image
The Naïve Bayes model
Csurka et al. 2004
• Assume that each feature is conditionally
independent given the class
No. of features of type wj in training images of class c
Total no. of features in training images of class c
p(wj | c) =
M
j
wn
j
N
i
iN
j
cwpcfpcffp
1
)(
1
1 )|()|()|,,( 
The Naïve Bayes model
Csurka et al. 2004
• Assume that each feature is conditionally
independent given the class
No. of features of type wj in training images of class c + 1
Total no. of features in training images of class c + M
p(wj | c) =
(Laplace smoothing to avoid zero counts)
M
j
wn
j
N
i
iN
j
cwpcfpcffp
1
)(
1
1 )|()|()|,,( 
M
j
jjc
M
j
wn
jc
cwpwncp
cwpcpc j
1
1
)(
)|(log)()(logmaxarg
)|()(maxarg*
The Naïve Bayes model
Csurka et al. 2004
• Maximum A Posteriori decision:
(you should compute the log of the likelihood
instead of the likelihood itself in order to avoid
underflow)
The Naïve Bayes model
Csurka et al. 2004
w
N
c
• “Graphical model”:
Probabilistic Latent Semantic Analysis
T. Hofmann, Probabilistic Latent Semantic Analysis, UAI 1999
zebra grass treeImage
= p1 + p2 + p3
“visual topics”
Probabilistic Latent Semantic Analysis
• Unsupervised technique
• Two-level generative model: a document is a
mixture of topics, and each topic has its own
characteristic word distribution
wd z
T. Hofmann, Probabilistic Latent Semantic Analysis, UAI 1999
document topic word
P(z|d) P(w|z)
Probabilistic Latent Semantic Analysis
• Unsupervised technique
• Two-level generative model: a document is a
mixture of topics, and each topic has its own
characteristic word distribution
wd z
T. Hofmann, Probabilistic Latent Semantic Analysis, UAI 1999
K
k
jkkiji dzpzwpdwp
1
)|()|()|(
The pLSA model
K
k
jkkiji dzpzwpdwp
1
)|()|()|(
Probability of word i
in document j
(known)
Probability of
word i given
topic k
(unknown)
Probability of
topic k given
document j
(unknown)
The pLSA model
Observed codeword
distributions
(M×N)
Codeword distributions
per topic (class)
(M×K)
Class distributions
per image
(K×N)
K
k
jkkiji dzpzwpdwp
1
)|()|()|(
p(wi|dj) p(wi|zk)
p(zk|dj)
documents
words
words
topics
topics
documents
=
Maximize likelihood of data:
Observed counts of
word i in document j
M … number of codewords
N … number of images
Slide credit: Josef Sivic
Learning pLSA parameters
Inference
)|(maxarg dzpz
z
• Finding the most likely topic (class) for an image:
Inference
)|(maxarg dzpz
z
• Finding the most likely topic (class) for an image:
z
zz dzpzwp
dzpzwp
dwzpz
)|()|(
)|()|(
maxarg),|(maxarg
• Finding the most likely topic (class) for a visual
word in a given image:
Topic discovery in images
J. Sivic, B. Russell, A. Efros, A. Zisserman, B. Freeman, Discovering Objects and their Location
in Images, ICCV 2005
Application of pLSA: Action recognition
Juan Carlos Niebles, Hongcheng Wang and Li Fei-Fei, Unsupervised Learning of Human Action
Categories Using Spatial-Temporal Words, IJCV 2008.
Space-time interest points
Application of pLSA: Action recognition
Juan Carlos Niebles, Hongcheng Wang and Li Fei-Fei, Unsupervised Learning of Human Action
Categories Using Spatial-Temporal Words, IJCV 2008.
pLSA model
– wi = spatial-temporal word
– dj = video
– n(wi, dj) = co-occurrence table
(# of occurrences of word wi in video dj)
– z = topic, corresponding to an action
K
k
jkkiji dzpzwpdwp
1
)|()|()|(
Probability of word i
in video j
(known)
Probability of
word i given
topic k
(unknown)
Probability of
topic k given
video j
(unknown)
Action recognition example
Multiple Actions
Multiple Actions
Summary: Generative models
• Naïve Bayes
– Unigram models in document analysis
– Assumes conditional independence of words given
class
– Parameter estimation: frequency counting
• Probabilistic Latent Semantic Analysis
– Unsupervised technique
– Each document is a mixture of topics (image is a
mixture of classes)
– Can be thought of as matrix decomposition
– Parameter estimation: Expectation-Maximization
Adding spatial information
• Computing bags of features on sub-windows
of the whole image
• Using codebooks to vote for object position
• Generative part-based models
Spatial pyramid representation
• Extension of a bag of features
• Locally orderless representation at several levels of resolution
level 0
Lazebnik, Schmid & Ponce (CVPR 2006) Slide: S. Lazebnik
Spatial pyramid representation
• Extension of a bag of features
• Locally orderless representation at several levels of resolution
level 0 level 1
Lazebnik, Schmid & Ponce (CVPR 2006) Slide: S. Lazebnik
Spatial pyramid representation
level 0 level 1 level 2
• Extension of a bag of features
• Locally orderless representation at several levels of resolution
Lazebnik, Schmid & Ponce (CVPR 2006) Slide: S. Lazebnik
Scene category dataset
Multi-class classification results
(100 training images per class)
Slide: S. Lazebnik
Caltech101 dataset
http://www.vision.caltech.edu/Image_Datasets/Caltech101/Caltech101.html
Multi-class classification results (30 training images per class)
Slide: S. Lazebnik
Examples from PASCAL VOC Challenge 2010
Boosting Classification with Exclusive Context, Yan et al. 2010
Boosting Classification with Exclusive Context, Yan et al. 2010
Boosting Classification with Exclusive Context, Yan et al. 2010
Boosting Classification with Exclusive Context, Yan et al. 2010

More Related Content

What's hot

Pattern recognition and Machine Learning.
Pattern recognition and Machine Learning.Pattern recognition and Machine Learning.
Pattern recognition and Machine Learning.
Rohit Kumar
 
Introduction to Natural Language Processing (NLP)
Introduction to Natural Language Processing (NLP)Introduction to Natural Language Processing (NLP)
Introduction to Natural Language Processing (NLP)
VenkateshMurugadas
 
Linear regression
Linear regressionLinear regression
Linear regression
MartinHogg9
 
Data mining: Classification and prediction
Data mining: Classification and predictionData mining: Classification and prediction
Data mining: Classification and prediction
DataminingTools Inc
 
Image Processing and Computer Vision
Image Processing and Computer VisionImage Processing and Computer Vision
Image Processing and Computer Vision
Silicon Mentor
 
Image feature extraction
Image feature extractionImage feature extraction
Image feature extractionRushin Shah
 
Machine learning
Machine learningMachine learning
Machine learning
Dr Geetha Mohan
 
Deep Learning in Computer Vision
Deep Learning in Computer VisionDeep Learning in Computer Vision
Deep Learning in Computer Vision
Sungjoon Choi
 
MachineLearning.ppt
MachineLearning.pptMachineLearning.ppt
MachineLearning.pptbutest
 
Bert
BertBert
Scaling and Normalization
Scaling and NormalizationScaling and Normalization
Scaling and Normalization
Kush Kulshrestha
 
An Introduction to Supervised Machine Learning and Pattern Classification: Th...
An Introduction to Supervised Machine Learning and Pattern Classification: Th...An Introduction to Supervised Machine Learning and Pattern Classification: Th...
An Introduction to Supervised Machine Learning and Pattern Classification: Th...
Sebastian Raschka
 
weak slot and filler structure
weak slot and filler structureweak slot and filler structure
weak slot and filler structure
Amey Kerkar
 
Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...
Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...
Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...
Simplilearn
 
Perceptron (neural network)
Perceptron (neural network)Perceptron (neural network)
Perceptron (neural network)
EdutechLearners
 
AI: Planning and AI
AI: Planning and AIAI: Planning and AI
AI: Planning and AI
DataminingTools Inc
 
Deep learning
Deep learningDeep learning
Deep learning
Mohamed Loey
 

What's hot (20)

Pattern recognition and Machine Learning.
Pattern recognition and Machine Learning.Pattern recognition and Machine Learning.
Pattern recognition and Machine Learning.
 
Introduction to Natural Language Processing (NLP)
Introduction to Natural Language Processing (NLP)Introduction to Natural Language Processing (NLP)
Introduction to Natural Language Processing (NLP)
 
Linear regression
Linear regressionLinear regression
Linear regression
 
Data mining: Classification and prediction
Data mining: Classification and predictionData mining: Classification and prediction
Data mining: Classification and prediction
 
Naive bayes
Naive bayesNaive bayes
Naive bayes
 
Object Recognition
Object RecognitionObject Recognition
Object Recognition
 
Image Processing and Computer Vision
Image Processing and Computer VisionImage Processing and Computer Vision
Image Processing and Computer Vision
 
Image feature extraction
Image feature extractionImage feature extraction
Image feature extraction
 
Machine learning
Machine learningMachine learning
Machine learning
 
Deep Learning in Computer Vision
Deep Learning in Computer VisionDeep Learning in Computer Vision
Deep Learning in Computer Vision
 
SIFT
SIFTSIFT
SIFT
 
MachineLearning.ppt
MachineLearning.pptMachineLearning.ppt
MachineLearning.ppt
 
Bert
BertBert
Bert
 
Scaling and Normalization
Scaling and NormalizationScaling and Normalization
Scaling and Normalization
 
An Introduction to Supervised Machine Learning and Pattern Classification: Th...
An Introduction to Supervised Machine Learning and Pattern Classification: Th...An Introduction to Supervised Machine Learning and Pattern Classification: Th...
An Introduction to Supervised Machine Learning and Pattern Classification: Th...
 
weak slot and filler structure
weak slot and filler structureweak slot and filler structure
weak slot and filler structure
 
Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...
Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...
Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...
 
Perceptron (neural network)
Perceptron (neural network)Perceptron (neural network)
Perceptron (neural network)
 
AI: Planning and AI
AI: Planning and AIAI: Planning and AI
AI: Planning and AI
 
Deep learning
Deep learningDeep learning
Deep learning
 

Similar to bag-of-words models

16 17 bag_words
16 17 bag_words16 17 bag_words
16 17 bag_words
khawarbashir
 
Lec18 bag of_features
Lec18 bag of_featuresLec18 bag of_features
Lec18 bag of_featuresBo Li
 
Lecture 7&8 computer vision face_recognition
Lecture 7&8 computer vision face_recognitionLecture 7&8 computer vision face_recognition
Lecture 7&8 computer vision face_recognition
cairo university
 
PPT s12-machine vision-s2
PPT s12-machine vision-s2PPT s12-machine vision-s2
PPT s12-machine vision-s2
Binus Online Learning
 
Machine Learning workshop by GDSC Amity University Chhattisgarh
Machine Learning workshop by GDSC Amity University ChhattisgarhMachine Learning workshop by GDSC Amity University Chhattisgarh
Machine Learning workshop by GDSC Amity University Chhattisgarh
Poorabpatel
 
(MS word document)
(MS word document)(MS word document)
(MS word document)butest
 
Iccv2009 recognition and learning object categories p1 c01 - classical methods
Iccv2009 recognition and learning object categories   p1 c01 - classical methodsIccv2009 recognition and learning object categories   p1 c01 - classical methods
Iccv2009 recognition and learning object categories p1 c01 - classical methodszukun
 
MAchine learning
MAchine learningMAchine learning
MAchine learning
JayrajSingh9
 
Machine Learning Machine Learnin Machine Learningg
Machine Learning Machine Learnin Machine LearninggMachine Learning Machine Learnin Machine Learningg
Machine Learning Machine Learnin Machine Learningg
ghsskchutta
 
PPT-3.ppt
PPT-3.pptPPT-3.ppt
PPT-3.ppt
Shibaprasad Sen
 
Fcv hist lowe
Fcv hist loweFcv hist lowe
Fcv hist lowezukun
 
Fcv rep darrell
Fcv rep darrellFcv rep darrell
Fcv rep darrellzukun
 
Chris Dyer - 2017 - Neural MT Workshop Invited Talk: The Neural Noisy Channel...
Chris Dyer - 2017 - Neural MT Workshop Invited Talk: The Neural Noisy Channel...Chris Dyer - 2017 - Neural MT Workshop Invited Talk: The Neural Noisy Channel...
Chris Dyer - 2017 - Neural MT Workshop Invited Talk: The Neural Noisy Channel...
Association for Computational Linguistics
 
Recognition
RecognitionRecognition
Recognition
Neelam Soni
 
Lecture 21 - Image Categorization - Computer Vision Spring2015
Lecture 21 - Image Categorization -  Computer Vision Spring2015Lecture 21 - Image Categorization -  Computer Vision Spring2015
Lecture 21 - Image Categorization - Computer Vision Spring2015Jia-Bin Huang
 
Low level vision - A tuturial
Low level vision - A tuturialLow level vision - A tuturial
Low level vision - A tuturial
potaters
 
MLIP - Chapter 3 - Introduction to deep learning
MLIP - Chapter 3 - Introduction to deep learningMLIP - Chapter 3 - Introduction to deep learning
MLIP - Chapter 3 - Introduction to deep learning
Charles Deledalle
 
Introduction talk to Computer Vision
Introduction talk to Computer Vision Introduction talk to Computer Vision
Introduction talk to Computer Vision
Chen Sagiv
 

Similar to bag-of-words models (20)

16 17 bag_words
16 17 bag_words16 17 bag_words
16 17 bag_words
 
Lec18 bag of_features
Lec18 bag of_featuresLec18 bag of_features
Lec18 bag of_features
 
Lecture 7&8 computer vision face_recognition
Lecture 7&8 computer vision face_recognitionLecture 7&8 computer vision face_recognition
Lecture 7&8 computer vision face_recognition
 
PPT s12-machine vision-s2
PPT s12-machine vision-s2PPT s12-machine vision-s2
PPT s12-machine vision-s2
 
Machine Learning workshop by GDSC Amity University Chhattisgarh
Machine Learning workshop by GDSC Amity University ChhattisgarhMachine Learning workshop by GDSC Amity University Chhattisgarh
Machine Learning workshop by GDSC Amity University Chhattisgarh
 
(MS word document)
(MS word document)(MS word document)
(MS word document)
 
Iccv2009 recognition and learning object categories p1 c01 - classical methods
Iccv2009 recognition and learning object categories   p1 c01 - classical methodsIccv2009 recognition and learning object categories   p1 c01 - classical methods
Iccv2009 recognition and learning object categories p1 c01 - classical methods
 
MAchine learning
MAchine learningMAchine learning
MAchine learning
 
Machine Learning Machine Learnin Machine Learningg
Machine Learning Machine Learnin Machine LearninggMachine Learning Machine Learnin Machine Learningg
Machine Learning Machine Learnin Machine Learningg
 
17.ppt
17.ppt17.ppt
17.ppt
 
PPT-3.ppt
PPT-3.pptPPT-3.ppt
PPT-3.ppt
 
Fcv hist lowe
Fcv hist loweFcv hist lowe
Fcv hist lowe
 
Part2
Part2Part2
Part2
 
Fcv rep darrell
Fcv rep darrellFcv rep darrell
Fcv rep darrell
 
Chris Dyer - 2017 - Neural MT Workshop Invited Talk: The Neural Noisy Channel...
Chris Dyer - 2017 - Neural MT Workshop Invited Talk: The Neural Noisy Channel...Chris Dyer - 2017 - Neural MT Workshop Invited Talk: The Neural Noisy Channel...
Chris Dyer - 2017 - Neural MT Workshop Invited Talk: The Neural Noisy Channel...
 
Recognition
RecognitionRecognition
Recognition
 
Lecture 21 - Image Categorization - Computer Vision Spring2015
Lecture 21 - Image Categorization -  Computer Vision Spring2015Lecture 21 - Image Categorization -  Computer Vision Spring2015
Lecture 21 - Image Categorization - Computer Vision Spring2015
 
Low level vision - A tuturial
Low level vision - A tuturialLow level vision - A tuturial
Low level vision - A tuturial
 
MLIP - Chapter 3 - Introduction to deep learning
MLIP - Chapter 3 - Introduction to deep learningMLIP - Chapter 3 - Introduction to deep learning
MLIP - Chapter 3 - Introduction to deep learning
 
Introduction talk to Computer Vision
Introduction talk to Computer Vision Introduction talk to Computer Vision
Introduction talk to Computer Vision
 

Recently uploaded

一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
dwreak4tg
 
The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
jerlynmaetalle
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
NABLAS株式会社
 
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
ahzuo
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Subhajit Sahu
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
Roger Valdez
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
haila53
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
Subhajit Sahu
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
slg6lamcq
 
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
u86oixdj
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
v3tuleee
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
Timothy Spann
 
My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.
rwarrenll
 
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
74nqk8xf
 
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
mbawufebxi
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Subhajit Sahu
 
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
2023240532
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
axoqas
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
ewymefz
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
ewymefz
 

Recently uploaded (20)

一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
 
The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
 
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
 
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
 
My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.
 
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
 
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
 
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
 

bag-of-words models

  • 1. Bag-of-Words models Lecture 9 Slides from: S. Lazebnik, A. Torralba, L. Fei-Fei, D. Lowe, C. Szurka
  • 3. Overview: Bag-of-features models • Origins and motivation • Image representation • Discriminative methods – Nearest-neighbor classification – Support vector machines • Generative methods – Naïve Bayes – Probabilistic Latent Semantic Analysis • Extensions: incorporating spatial information
  • 4. Origin 1: Texture recognition • Texture is characterized by the repetition of basic elements or textons • For stochastic textures, it is the identity of the textons, not their spatial arrangement, that matters Julesz, 1981; Cula & Dana, 2001; Leung & Malik 2001; Mori, Belongie & Malik, 2001; Schmid 2001; Varma & Zisserman, 2002, 2003; Lazebnik, Schmid & Ponce, 2003
  • 5. Origin 1: Texture recognition Universal texton dictionary histogram Julesz, 1981; Cula & Dana, 2001; Leung & Malik 2001; Mori, Belongie & Malik, 2001; Schmid 2001; Varma & Zisserman, 2002, 2003; Lazebnik, Schmid & Ponce, 2003
  • 6. Origin 2: Bag-of-words models • Orderless document representation: frequencies of words from a dictionary Salton & McGill (1983)
  • 7. Origin 2: Bag-of-words models US Presidential Speeches Tag Cloud http://chir.ag/phernalia/preztags/ • Orderless document representation: frequencies of words from a dictionary Salton & McGill (1983)
  • 8. Origin 2: Bag-of-words models US Presidential Speeches Tag Cloud http://chir.ag/phernalia/preztags/ • Orderless document representation: frequencies of words from a dictionary Salton & McGill (1983)
  • 9. Origin 2: Bag-of-words models US Presidential Speeches Tag Cloud http://chir.ag/phernalia/preztags/ • Orderless document representation: frequencies of words from a dictionary Salton & McGill (1983)
  • 10. Bags of features for image classification 1. Extract features
  • 11. 1. Extract features 2. Learn “visual vocabulary” Bags of features for image classification
  • 12. 1. Extract features 2. Learn “visual vocabulary” 3. Quantize features using visual vocabulary Bags of features for image classification
  • 13. 1. Extract features 2. Learn “visual vocabulary” 3. Quantize features using visual vocabulary 4. Represent images by frequencies of “visual words” Bags of features for image classification
  • 14. • Regular grid – Vogel & Schiele, 2003 – Fei-Fei & Perona, 2005 1. Feature extraction
  • 15. • Regular grid – Vogel & Schiele, 2003 – Fei-Fei & Perona, 2005 • Interest point detector – Csurka et al. 2004 – Fei-Fei & Perona, 2005 – Sivic et al. 2005 1. Feature extraction
  • 16. • Regular grid – Vogel & Schiele, 2003 – Fei-Fei & Perona, 2005 • Interest point detector – Csurka et al. 2004 – Fei-Fei & Perona, 2005 – Sivic et al. 2005 • Other methods – Random sampling (Vidal-Naquet & Ullman, 2002) – Segmentation-based patches (Barnard et al. 2003) 1. Feature extraction
  • 17. Normalize patch Detect patches [Mikojaczyk and Schmid ’02] [Mata, Chum, Urban & Pajdla, ’02] [Sivic & Zisserman, ’03] Compute SIFT descriptor [Lowe’99] Slide credit: Josef Sivic 1. Feature extraction
  • 19. 2. Learning the visual vocabulary …
  • 20. 2. Learning the visual vocabulary Clustering … Slide credit: Josef Sivic
  • 21. 2. Learning the visual vocabulary Clustering … Slide credit: Josef Sivic Visual vocabulary
  • 22. K-means clustering • Want to minimize sum of squared Euclidean distances between points xi and their nearest cluster centers mk • Algorithm: • Randomly initialize K cluster centers • Iterate until convergence: – Assign each data point to the nearest center – Recompute each cluster center as the mean of all points assigned to it k k i ki mxMXD cluster cluster inpoint 2 )(),(
  • 23. From clustering to vector quantization • Clustering is a common method for learning a visual vocabulary or codebook – Unsupervised learning process – Each cluster center produced by k-means becomes a codevector – Codebook can be learned on separate training set – Provided the training set is sufficiently representative, the codebook will be “universal” • The codebook is used for quantizing features – A vector quantizer takes a feature vector and maps it to the index of the nearest codevector in a codebook – Codebook = visual vocabulary – Codevector = visual word
  • 25. Image patch examples of visual words Sivic et al. 2005
  • 26. Visual vocabularies: Issues • How to choose vocabulary size? – Too small: visual words not representative of all patches – Too large: quantization artifacts, overfitting • Generative or discriminative learning? • Computational efficiency – Vocabulary trees (Nister & Stewenius, 2006)
  • 28. Image classification • Given the bag-of-features representations of images from different classes, how do we learn a model for distinguishing them?
  • 29. Discriminative and generative methods for bags of features Zebra Non-zebra
  • 30. Image classification • Given the bag-of-features representations of images from different classes, how do we learn a model for distinguishing them?
  • 31. Discriminative methods • Learn a decision rule (classifier) assigning bag- of-features representations of images to different classes Zebra Non-zebra Decision boundary
  • 32. Classification • Assign input vector to one of two or more classes • Any decision rule divides input space into decision regions separated by decision boundaries
  • 33. Nearest Neighbor Classifier • Assign label of nearest training data point to each test data point Voronoi partitioning of feature space for two-category 2D and 3D data from Duda et al. Source: D. Lowe
  • 34. • For a new point, find the k closest points from training data • Labels of the k points “vote” to classify • Works well provided there is lots of data and the distance function is good K-Nearest Neighbors k = 5 Source: D. Lowe
  • 35. Functions for comparing histograms • L1 distance • χ2 distance • Quadratic distance (cross-bin) N i ihihhhD 1 2121 |)()(|),( Jan Puzicha, Yossi Rubner, Carlo Tomasi, Joachim M. Buhmann: Empirical Evaluation of Dissimilarity Measures for Color and Texture. ICCV 1999 N i ihih ihih hhD 1 21 2 21 21 )()( )()( ),( ji ij jhihAhhD , 2 2121 ))()((),(
  • 36. Earth Mover’s Distance • Each image is represented by a signature S consisting of a set of centers {mi } and weights {wi } • Centers can be codewords from universal vocabulary, clusters of features in the image, or individual features (in which case quantization is not required) • Earth Mover’s Distance has the form where the flows fij are given by the solution of a transportation problem Y. Rubner, C. Tomasi, and L. Guibas: A Metric for Distributions with Applications to Image Databases. ICCV 1998 ji ij jiij f mmdf SSEMD , 21 21 ),( ),(
  • 37. Linear classifiers • Find linear function (hyperplane) to separate positive and negative examples 0:negative 0:positive b b ii ii wxx wxx Which hyperplane is best? Slide: S. Lazebnik
  • 38. Support vector machines • Find hyperplane that maximizes the margin between the positive and negative examples C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining and Knowledge Discovery, 1998
  • 39. Support vector machines • Find hyperplane that maximizes the margin between the positive and negative examples 1:1)(negative 1:1)(positive by by iii iii wxx wxx MarginSupport vectors C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining and Knowledge Discovery, 1998 Distance between point and hyperplane: |||| || w wx bi For support vectors, 1bi wx Therefore, the margin is 2 / ||w||
  • 40. Finding the maximum margin hyperplane 1. Maximize margin 2/||w|| 2. Correctly classify all training data: • Quadratic optimization problem: • Minimize Subject to yi(w·xi+b) ≥ 1 C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining and Knowledge Discovery, 1998 wwT 2 1 1:1)(negative 1:1)(positive by by iii iii wxx wxx
  • 41. Finding the maximum margin hyperplane • Solution: i iii y xw C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining and Knowledge Discovery, 1998 Support vector learned weight
  • 42. Finding the maximum margin hyperplane • Solution: b = yi – w·xi for any support vector • Classification function (decision boundary): • Notice that it relies on an inner product between the test point x and the support vectors xi • Solving the optimization problem also involves computing the inner products xi · xj between all pairs of training points i iii y xw C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining and Knowledge Discovery, 1998 byb i iii xxxw
  • 43. • 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
  • 44. Φ: 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: Slide credit: Andrew Moore
  • 45. Nonlinear SVMs • The kernel trick: instead of explicitly computing the lifting transformation φ(x), define a kernel function K such that K(xi,xj) = φ(xi ) · φ(xj) • (to be valid, the kernel function must satisfy Mercer’s condition) • This gives a nonlinear decision boundary in the original feature space: bKy i iii ),( xx C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining and Knowledge Discovery, 1998
  • 46. Kernels for bags of features • Histogram intersection kernel: • Generalized Gaussian kernel: • D can be Euclidean distance, χ2 distance, Earth Mover’s Distance, etc. N i ihihhhI 1 2121 ))(),(min(),( 2 2121 ),( 1 exp),( hhD A hhK J. Zhang, M. Marszalek, S. Lazebnik, and C. Schmid, Local Features and Kernels for Classifcation of Texture and Object Categories: A Comprehensive Study, IJCV 2007
  • 47. Summary: SVMs for image classification 1. Pick an image representation (in our case, bag of features) 2. Pick a kernel function for that representation 3. Compute the matrix of kernel values between every pair of training examples 4. Feed the kernel matrix into your favorite SVM solver to obtain support vectors and weights 5. At test time: compute kernel values for your test example and each support vector, and combine them with the learned weights to get the value of the decision function
  • 48. What about multi-class SVMs? • Unfortunately, there is no “definitive” multi-class SVM formulation • In practice, we have to obtain a multi-class SVM by combining multiple two-class SVMs • One vs. others – Traning: learn an SVM for each class vs. the others – Testing: apply each SVM to test example and assign to it the class of the SVM that returns the highest decision value • One vs. one – Training: learn an SVM for each pair of classes – Testing: each learned SVM “votes” for a class to assign to the test example Slide: S. Lazebnik
  • 49. SVMs: Pros and cons • Pros – Many publicly available SVM packages: http://www.kernel-machines.org/software – Kernel-based framework is very powerful, flexible – SVMs work very well in practice, even with very small training sample sizes • Cons – No “direct” multi-class SVM, must combine two- class SVMs – Computation, memory • During training time, must compute matrix of kernel values for every pair of examples • Learning can take a very long time for large-scale problems Slide: S. Lazebnik
  • 50. Summary: Discriminative methods • Nearest-neighbor and k-nearest-neighbor classifiers – L1 distance, χ2 distance, quadratic distance, Earth Mover’s Distance • Support vector machines – Linear classifiers – Margin maximization – The kernel trick – Kernel functions: histogram intersection, generalized Gaussian, pyramid match – Multi-class • Of course, there are many other classifiers out there – Neural networks, boosting, decision trees, …
  • 51. Generative learning methods for bags of features • Model the probability of a bag of features given a class
  • 52. Generative methods • We will cover two models, both inspired by text document analysis: – Naïve Bayes – Probabilistic Latent Semantic Analysis
  • 53. The Naïve Bayes model Csurka et al. 2004 • Assume that each feature is conditionally independent given the class fi: ith feature in the image N: number of features in the image N i iN cfpcffp 1 1 )|()|,,( 
  • 54. The Naïve Bayes model Csurka et al. 2004 M j wn j N i iN j cwpcfpcffp 1 )( 1 1 )|()|()|,,(  • Assume that each feature is conditionally independent given the class wj: jth visual word in the vocabulary M: size of visual vocabulary n(wj): number of features of type wj in the image fi: ith feature in the image N: number of features in the image
  • 55. The Naïve Bayes model Csurka et al. 2004 • Assume that each feature is conditionally independent given the class No. of features of type wj in training images of class c Total no. of features in training images of class c p(wj | c) = M j wn j N i iN j cwpcfpcffp 1 )( 1 1 )|()|()|,,( 
  • 56. The Naïve Bayes model Csurka et al. 2004 • Assume that each feature is conditionally independent given the class No. of features of type wj in training images of class c + 1 Total no. of features in training images of class c + M p(wj | c) = (Laplace smoothing to avoid zero counts) M j wn j N i iN j cwpcfpcffp 1 )( 1 1 )|()|()|,,( 
  • 57. M j jjc M j wn jc cwpwncp cwpcpc j 1 1 )( )|(log)()(logmaxarg )|()(maxarg* The Naïve Bayes model Csurka et al. 2004 • Maximum A Posteriori decision: (you should compute the log of the likelihood instead of the likelihood itself in order to avoid underflow)
  • 58. The Naïve Bayes model Csurka et al. 2004 w N c • “Graphical model”:
  • 59. Probabilistic Latent Semantic Analysis T. Hofmann, Probabilistic Latent Semantic Analysis, UAI 1999 zebra grass treeImage = p1 + p2 + p3 “visual topics”
  • 60. Probabilistic Latent Semantic Analysis • Unsupervised technique • Two-level generative model: a document is a mixture of topics, and each topic has its own characteristic word distribution wd z T. Hofmann, Probabilistic Latent Semantic Analysis, UAI 1999 document topic word P(z|d) P(w|z)
  • 61. Probabilistic Latent Semantic Analysis • Unsupervised technique • Two-level generative model: a document is a mixture of topics, and each topic has its own characteristic word distribution wd z T. Hofmann, Probabilistic Latent Semantic Analysis, UAI 1999 K k jkkiji dzpzwpdwp 1 )|()|()|(
  • 62. The pLSA model K k jkkiji dzpzwpdwp 1 )|()|()|( Probability of word i in document j (known) Probability of word i given topic k (unknown) Probability of topic k given document j (unknown)
  • 63. The pLSA model Observed codeword distributions (M×N) Codeword distributions per topic (class) (M×K) Class distributions per image (K×N) K k jkkiji dzpzwpdwp 1 )|()|()|( p(wi|dj) p(wi|zk) p(zk|dj) documents words words topics topics documents =
  • 64. Maximize likelihood of data: Observed counts of word i in document j M … number of codewords N … number of images Slide credit: Josef Sivic Learning pLSA parameters
  • 65. Inference )|(maxarg dzpz z • Finding the most likely topic (class) for an image:
  • 66. Inference )|(maxarg dzpz z • Finding the most likely topic (class) for an image: z zz dzpzwp dzpzwp dwzpz )|()|( )|()|( maxarg),|(maxarg • Finding the most likely topic (class) for a visual word in a given image:
  • 67. Topic discovery in images J. Sivic, B. Russell, A. Efros, A. Zisserman, B. Freeman, Discovering Objects and their Location in Images, ICCV 2005
  • 68. Application of pLSA: Action recognition Juan Carlos Niebles, Hongcheng Wang and Li Fei-Fei, Unsupervised Learning of Human Action Categories Using Spatial-Temporal Words, IJCV 2008. Space-time interest points
  • 69. Application of pLSA: Action recognition Juan Carlos Niebles, Hongcheng Wang and Li Fei-Fei, Unsupervised Learning of Human Action Categories Using Spatial-Temporal Words, IJCV 2008.
  • 70. pLSA model – wi = spatial-temporal word – dj = video – n(wi, dj) = co-occurrence table (# of occurrences of word wi in video dj) – z = topic, corresponding to an action K k jkkiji dzpzwpdwp 1 )|()|()|( Probability of word i in video j (known) Probability of word i given topic k (unknown) Probability of topic k given video j (unknown)
  • 74. Summary: Generative models • Naïve Bayes – Unigram models in document analysis – Assumes conditional independence of words given class – Parameter estimation: frequency counting • Probabilistic Latent Semantic Analysis – Unsupervised technique – Each document is a mixture of topics (image is a mixture of classes) – Can be thought of as matrix decomposition – Parameter estimation: Expectation-Maximization
  • 75. Adding spatial information • Computing bags of features on sub-windows of the whole image • Using codebooks to vote for object position • Generative part-based models
  • 76. Spatial pyramid representation • Extension of a bag of features • Locally orderless representation at several levels of resolution level 0 Lazebnik, Schmid & Ponce (CVPR 2006) Slide: S. Lazebnik
  • 77. Spatial pyramid representation • Extension of a bag of features • Locally orderless representation at several levels of resolution level 0 level 1 Lazebnik, Schmid & Ponce (CVPR 2006) Slide: S. Lazebnik
  • 78. Spatial pyramid representation level 0 level 1 level 2 • Extension of a bag of features • Locally orderless representation at several levels of resolution Lazebnik, Schmid & Ponce (CVPR 2006) Slide: S. Lazebnik
  • 79. Scene category dataset Multi-class classification results (100 training images per class) Slide: S. Lazebnik
  • 81. Examples from PASCAL VOC Challenge 2010
  • 82. Boosting Classification with Exclusive Context, Yan et al. 2010
  • 83. Boosting Classification with Exclusive Context, Yan et al. 2010
  • 84. Boosting Classification with Exclusive Context, Yan et al. 2010
  • 85. Boosting Classification with Exclusive Context, Yan et al. 2010