part 3: discriminative methods antonio torralba. overview of section object detection with...

71
Part 3: discriminative methods Antonio Torralba

Upload: lilian-rice

Post on 29-Dec-2015

219 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Part 3: discriminative methodsAntonio Torralba

Page 2: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Overview of section

• Object detection with classifiers

• Boosting– Gentle boosting– Weak detectors– Object model– Object detection

• Multiclass object detection

Page 3: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Discriminative methodsObject detection and recognition is formulated as a classification problem.

Bag of image patches

Decision boundary

… and a decision is taken at each window about if it contains a target object or not.

Computer screen

Background

In some feature space

Where are the screens?

The image is partitioned into a set of overlapping windows

Page 4: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

(The lousy painter)

Discriminative vs. generative

0 10 20 30 40 50 60 700

0.05

0.1

x = data

• Generative model

0 10 20 30 40 50 60 700

0.5

1

x = data

• Discriminative model

0 10 20 30 40 50 60 70 80

-1

1

x = data

• Classification function

(The artist)

Page 5: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Discriminative methods

106 examples

Nearest neighbor

Shakhnarovich, Viola, Darrell 2003Berg, Berg, Malik 2005…

Neural networks

LeCun, Bottou, Bengio, Haffner 1998Rowley, Baluja, Kanade 1998…

Support Vector Machines and Kernels Conditional Random Fields

McCallum, Freitag, Pereira 2000Kumar, Hebert 2003…

Guyon, VapnikHeisele, Serre, Poggio, 2001…

Page 6: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

• Formulation: binary classification

Formulation

+1-1

x1 x2 x3 xN

… xN+1 xN+2 xN+M

-1 -1 ? ? ?

Training data: each image patch is labeledas containing the object or background

Test data

Features x =

Labels y =

Where belongs to some family of functions

• Classification function

• Minimize misclassification error(Not that simple: we need some guarantees that there will be generalization)

Page 7: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Overview of section

• Object detection with classifiers

• Boosting– Gentle boosting– Weak detectors– Object model– Object detection

• Multiclass object detection

Page 8: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

A simple object detector with Boosting

Download

• Toolbox for manipulating dataset

• Code and dataset

Matlab code

• Gentle boosting

• Object detector using a part based model

Dataset with cars and computer monitors

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

Page 9: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

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

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

• Easy to implement, not requires external optimization tools.

Why boosting?

Page 10: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

• Defines a classifier using an additive model:

Boosting

Strong classifier

Weak classifier

WeightFeaturesvector

Page 11: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

• Defines a classifier using an additive model:

• We need to define a family of weak classifiers

Boosting

Strong classifier

Weak classifier

WeightFeaturesvector

from a family of weak classifiers

Page 12: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Each data point has

a class label:

wt =1and a weight:

+1 ( )

-1 ( )yt =

Boosting• It is a sequential procedure:

xt=1

xt=2

xt

Page 13: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Toy exampleWeak learners from the family of lines

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

Each data point has

a class label:

wt =1and a weight:

+1 ( )

-1 ( )yt =

Page 14: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Toy example

This one seems to be the best

Each data point has

a class label:

wt =1and a weight:

+1 ( )

-1 ( )yt =

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

Page 15: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Toy example

We set a new problem for which the previous weak classifier performs at chance again

Each data point has

a class label:

wt wt exp{-yt Ht}

We update the weights:

+1 ( )

-1 ( )yt =

Page 16: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Toy example

We set a new problem for which the previous weak classifier performs at chance again

Each data point has

a class label:

wt wt exp{-yt Ht}

We update the weights:

+1 ( )

-1 ( )yt =

Page 17: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Toy example

We set a new problem for which the previous weak classifier performs at chance again

Each data point has

a class label:

wt wt exp{-yt Ht}

We update the weights:

+1 ( )

-1 ( )yt =

Page 18: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Toy example

We set a new problem for which the previous weak classifier performs at chance again

Each data point has

a class label:

wt wt exp{-yt Ht}

We update the weights:

+1 ( )

-1 ( )yt =

Page 19: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Toy example

The strong (non- linear) classifier is built as the combination of all the weak (linear) classifiers.

f1 f2

f3

f4

Page 20: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Boosting

• Different cost functions and minimization algorithms result is various flavors of Boosting

• In this demo, I will use gentleBoosting: it is simple to implement and numerically stable.

Page 21: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Overview of section

• Object detection with classifiers

• Boosting– Gentle boosting– Weak detectors– Object model– Object detection

• Multiclass object detection

Page 22: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Boosting Boosting fits the additive model

by minimizing the exponential loss

Training samples

The exponential loss is a differentiable upper bound to the misclassification error.

Page 23: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Exponential loss

-1.5 -1 -0.5 0 0.5 1 1.5 20

0.5

1

1.5

2

2.5

3

3.5

4 Squared error

Exponential loss

yF(x) = margin

Misclassification errorLoss

Squared error

Exponential loss

Page 24: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Boosting Sequential procedure. At each step we add

For more details: Friedman, Hastie, Tibshirani. “Additive Logistic Regression: a Statistical View of Boosting” (1998)

to minimize the residual loss

inputDesired outputParametersweak classifier

Page 25: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

gentleBoosting

For more details: Friedman, Hastie, Tibshirani. “Additive Logistic Regression: a Statistical View of Boosting” (1998)

We chose that minimizes the cost:

At each iterations we just need to solve a weighted least squares problem

Weights at this iteration

• At each iteration:

Instead of doing exact optimization, gentle Boosting minimizes a Taylor approximation of the error:

Page 26: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Weak classifiers

• The input is a set of weighted training samples (x,y,w)

• Regression stumps: simple but commonly used in object detection.

Four parameters:

b=Ew(y [x> ])

a=Ew(y [x< ])x

fm(x)

fitRegressionStump.m

Page 27: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

gentleBoosting.m

function classifier = gentleBoost(x, y, Nrounds)

for m = 1:Nrounds

fm = selectBestWeakClassifier(x, y, w); w = w .* exp(- y .* fm); % store parameters of fm in classifier …end

Solve weighted least-squares

Re-weight training samples

Initialize weights w = 1

Page 28: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Demo gentleBoosting

> demoGentleBoost.m

Demo using Gentle boost and stumps with hand selected 2D data:

Page 29: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Flavors of boosting

• AdaBoost (Freund and Shapire, 1995)

• Real AdaBoost (Friedman et al, 1998)

• LogitBoost (Friedman et al, 1998)

• Gentle AdaBoost (Friedman et al, 1998)

• BrownBoosting (Freund, 2000)

• FloatBoost (Li et al, 2002)

• …

Page 30: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Overview of section

• Object detection with classifiers

• Boosting– Gentle boosting– Weak detectors– Object model– Object detection

• Multiclass object detection

Page 31: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

From images to features:Weak detectors

We will now define a family of visual features that can be used as weak classifiers (“weak detectors”)

Takes image as input and the output is binary response.The output is a weak detector.

Page 32: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Weak detectorsTextures of textures Tieu and Viola, CVPR 2000

Every combination of three filters generates a different feature

This gives thousands of features. Boosting selects a sparse subset, so computations on test time are very efficient. Boosting also avoids overfitting to some extend.

Page 33: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Weak detectorsHaar filters and integral imageViola and Jones, ICCV 2001

The average intensity in the block is computed with four sums independently of the block size.

Page 34: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Weak detectors

Other weak detectors:• Carmichael, Hebert 2004• Yuille, Snow, Nitzbert, 1998• Amit, Geman 1998• Papageorgiou, Poggio, 2000• Heisele, Serre, Poggio, 2001• Agarwal, Awan, Roth, 2004• Schneiderman, Kanade 2004 • …

Page 35: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Weak detectorsPart based: similar to part-based generative

models. We create weak detectors by using parts and voting for the object center location

Car model Screen model

These features are used for the detector on the course web site.

Page 36: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Weak detectorsFirst we collect a set of part templates from a set of training objects.

Vidal-Naquet, Ullman (2003)

Page 37: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Weak detectorsWe now define a family of “weak detectors” as:

= =

Better than chance

*

Page 38: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Weak detectorsWe can do a better job using filtered images

Still a weak detectorbut better than before

* * ===

Page 39: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

TrainingFirst we evaluate all the N features on all the training images.

Then, we sample the feature outputs on the object center and at random locations in the background:

Page 40: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Representation and object model

4 10

Selected features for the screen detector

1 2 3

100

Lousy painter

Page 41: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Representation and object modelSelected features for the car detector

1 2 3 4 10 100

… …

Page 42: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Overview of section

• Object detection with classifiers

• Boosting– Gentle boosting– Weak detectors– Object model– Object detection

• Multiclass object detection

Page 43: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Example: screen detectionFeature output

Page 44: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Example: screen detectionFeature output

Thresholded output

Weak ‘detector’Produces many false alarms.

Page 45: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Example: screen detectionFeature output

Thresholded output

Strong classifier at iteration 1

Page 46: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Example: screen detectionFeature output

Thresholded output

Strongclassifier

Second weak ‘detector’Produces a different set of false alarms.

Page 47: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Example: screen detection

+

Feature output

Thresholded output

Strongclassifier

Strong classifier at iteration 2

Page 48: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Example: screen detection

+

Feature output

Thresholded output

Strongclassifier

Strong classifier at iteration 10

Page 49: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Example: screen detection

+

Feature output

Thresholded output

Strongclassifier

Adding features

Finalclassification

Strong classifier at iteration 200

Page 50: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Demo

> runDetector.m

Demo of screen and car detectors using parts, Gentle boost, and stumps:

Page 51: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Probabilistic interpretation

• Generative model

• Discriminative (Boosting) model. Boosting is fitting an additive logistic regression model:

It can be a set of arbitrary functions of the image

This provides a great flexibility, difficult to beat by current generative models. But also there is the danger of not understanding what are they really doing.

Page 52: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Weak detectors

• Generative model

fi, Pigi

ImageFeature

Part template

Relative positionwrt object center

• Discriminative (Boosting) model. Boosting is fitting an additive logistic regression model:

Page 53: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Object models

• Invariance: search strategy

• Part based fi, Pigi

Here, invariance in translation and scale is achieved by the search strategy: the classifier is evaluated at all locations (by translating the image) and at all scales (by scaling the image in small steps).

The search cost can be reduced using a cascade.

Page 54: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

We want the complexity of the 3 features classifier with the performance of the 100 features classifier:

Cascade of classifiersFleuret and Geman 2001, Viola and Jones 2001

Recall

Precision

0% 100%

100%

3 features

30 features

100 features

Select a threshold with high recall for each stage.

We increase precision using the cascade

Page 55: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Single category object detection and the

“Head in the coffee beans problem”

Page 56: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

“Head in the coffee beans problem”Can you find the head in this image?

Page 57: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Overview of section

• Object detection with classifiers

• Boosting– Gentle boosting– Weak detectors– Object model– Object detection

• Multiclass object detection

Page 58: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Multiclass object detection

Multiclass object detection benefits from:

• Contextual relationships between objects

• Transfer between classes by sharing features

Studying the multiclass problem, we can build detectors that are:

• more efficient,

• that generalize better, and

• more robust

Page 59: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Context

2

What do you think are the hidden objects?

1

Page 60: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

ContextWhat do you think are the hidden objects?

Even without local object models, we can make reasonable detections!

Page 61: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Context: relationships between objects

Detect first simple objects (reliable detectors) that provide strongcontextual constraints to the target (screen -> keyboard -> mouse)

Page 62: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Context

• Murphy, Torralba & Freeman (NIPS 03)Use global context to predict presence and location of objects

Op1,c1

vp1,c1

OpN,c1

vpN,c1. . .

Op1,c2

vp1,c2

OpN,c2

vpN,c2. . .

Class 1 Class 2

E1 E2

S

c2maxVc1

maxV

X1X2vg

Keyboards

Page 63: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Context

• Fink & Perona (NIPS 03)Use output of boosting from other objects at previous

iterations as input into boosting for this iteration

Page 64: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Context

• Hoiem, Efros, Hebert (ICCV 05)Boosting used for combining local and contextual features:

Page 65: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Features

Parts

Objects

Scene

Context (generative model)• Sudderth, Torralba, Freeman, Willsky (ICCV 2005).

Context

Sharing

Page 66: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Some references on context

• Strat & Fischler (PAMI 91) • Torralba & Sinha (ICCV 01), • Torralba (IJCV 03) • Fink & Perona (NIPS 03)• Murphy, Torralba & Freeman (NIPS 03)• Kumar and M. Hebert (NIPS 04)• Carbonetto, Freitas & Barnard (ECCV 04)• He, Zemel & Carreira-Perpinan (CVPR 04)• Sudderth, Torralba, Freeman, Wilsky (ICCV 05)• Hoiem, Efros, Hebert (ICCV 05)• …

With a mixture of generative and discriminative approaches

Page 67: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Sharing features

Shared features achieve the same performances with five times less training data.

We train 12 classifies with shared features

• Torralba, Murphy & Freeman (CVPR 04)

Page 68: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Sharing features

shared weak detector

• Torralba, Murphy & Freeman (CVPR 04)

Strength of feature response

Part template

Page 69: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Sharing representations

• Bart and Ullman, 2004For a new class, use only features similar to features that where good for other classes:

Proposed Dog features

Page 70: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Some references on multiclass

• Caruana 1997• Schapire, Singer, 2000• Thrun, Pratt 1997• Krempp, Geman, Amit, 2002• E.L.Miller, Matsakis, Viola, 2000• Mahamud, Hebert, Lafferty, 2001• Fink 2004• LeCun, Huang, Bottou, 2004• Holub, Welling, Perona, 2005• …

Page 71: Part 3: discriminative methods Antonio Torralba. Overview of section Object detection with classifiers Boosting –Gentle boosting –Weak detectors –Object

Summary

Many techniques are used for training discriminative models that I have not mention here:

• Conditional random fields

• Kernels for object recognition

• Learning object similarities

• …