Discriminatively Trained Part Based Models notes

The LSVM (SVM with latent variable) is mostly used for human figure detection, it is very efficiency because it puts the human figure’s structure into consideration: a human figure has hands, head and legs. The LSVM models the human figure structure with 6 parts, and the position of these 6 parts are latent value.

The basic logic is sliding a window on the image, for every position we get a small image patch, by scoring this image patch we can predict whether this image patch contains a human figure or not.

Defining the score function

Anyway, the first thing to do: defining a score function:

Assumptions: we already trained the model and now we are using this model to find the image patch which contains a human figure by computing the score.

Just as a normal sliding window method, we search the whole image pyramid, so the position of a image patch will be defined by x, y and l. l short for “level” represents the level in a image pyramid.

We are evaluating a image patch, instead of directly using its pixel values, we will use the feature vector computed from this image patch, is the feature vector extracted from the image I.

is short for HoG feature, as we are using HoG feature , more precisely, is the pyramid of HoG features computed from I.

p is the position of the upper left corner of the current image patch

w and h are the width and height of the image patch.

will be the weights vector, in this paper it is called filter, because it is represented by a weighted window filter which only has none-zero weights at the position of image patch.

Finally we get the score by computing the dot product of and :

score_filter

Remember that we consider a human figure to be a structured model with 6 separate parts, let’s visualize it in the following image:

structure

Our model has a root filter highlighted as cyan rectangle, this root filter is used to find the whole human figure as a rough prediction. It will be computed in the feature pyramid’s high level to locate the human.

Apart from the root filter, we have the other 6 part filters highlighted as yellow rectangles in the above image. These filters will be positioned with some flexibility relative to the root filter, each filter of cause provide their own scores, the following diagram shows how are all these scores combined together to form a final score:

is the root filter, are the part filters and is the bias.

For one part filter :

is its filter

is the anchor of the filter, the position of where it should be:

​ - it is learned from the learning process.

is the parameters used to compute the penalty of the ith part:

​ - The part filter should not be too far away from where it should be

​ - The final score will be penalized by the position of the ith filter:

score

So the score of a complete model is a summation of:

the scores of the root and part filters and

the penalty of the part filters’ position.

Matching

Now we have the function to score a hypothesis image patch, as we can see, there are some variables which are unclear:

How can we find the location of the root filter?

That’s easy, we are simply sliding the foot filter in the whole image pyramid, defining its position only by computing the root filter’s score

How can we find the location of the part filters?

Once we find the location of the root filter, we can say it is very possible that there is a human figure in the image patch covered by the filter.

Then we can further position the part filters and compute the final score to evaluate if this image patch is really a human figure.

Positioning the part filters allows some flexibility, that’s why it’s called “latent”:

again, the ith part filter at position :

The latent part: position of the ith filter is latent, move it around to find the best position:

so adding the score of the root filter, we get the final score:

So the matching process can be described as:

  1. sliding the root filter to find the root position

  2. sliding the 1st part filter around its anchor position(learned in the training) relative to the root position until this part filter gets the max score, fix it.

  3. sliding the 2nd, 3rd …. until all part filters are fixed

  4. sum all the scores of root and part filters and the penalty part

When we find a postion with a score bigger than the threshold, we can say we find a human figure image patch.

One more thing to add: making the position of the root filter latent can help to improve the result.

Training

The left part:

The left part of the diagram shows a normal SVM problem using the Hinge Loss function to achieve the optimization goal .

We have a training image set with a series of images labeled with their class , in this case, if the image is human figure, we label it as 1, if it doesn’t contain a human figure, it will be labelled -1.

is short for “data set”, which contains all the sample images.

is the model parameter vector which is our training target, the weights.

is the feature vector

are the latent values to locate the part filters

Just as the normal gradient descent algorithm, we differentiate according to , with the step length , is the current iteration.

traning

The right part:

The right part of the diagram shows how the learning process is done.

The learning process has 2 steps:

In the 1st step, we fix and search in the whole image to locate the part filters’ positions (find the latent variables). As we are now learning, so we know that this image contains a human figure, then we don’t need to care about the root filter, or we can say, the root filter’s position is (0,0).

In the 2nd step, we fix the latent variables and update .

Training in practice

traning_practice

Initialization: initialization

Appendix:

How to solve the optimization problem?

For an input pair ,we get a prediction from ω:

Using the normal hinge loss function as the loss function, we get the following optimization problem:

as a normal SVM problem, it’s easy to solve.

But in this case, we introduce the latent value h, is no longer a easy linear function like .

It is now:

Which means,prediction turns to be a discrete non-linear function related to latent value, which cause the above problem difficult to solve.

But you will find out that and are independent to each other, so we can treat them as two independent variables, then we can use coordinate descent algorithm to solve this optimization problem.

The first step, fix , update

Which means, assuming that we know already, we compute a using:

now we fix , then turns to be a normal convex linear function to .

The second step, fix , update :

So for each , after we computed the based on the already existed , turns to be a convex function.

And we know that the summation of convex functions will be still convex.

So we can find the sum of all for , the summation will be still convex.

Original Paper :

A Discriminatively Trained, Multiscale, Deformable Part Model

Object Detection with Discriminatively Trained Part Based Model

Wangxin

I am algorithm engineer focused in computer vision, I know it will be more elegant to shut up and show my code, but I simply can't stop myself learning and explaining new things ...

NN Backpropagation

Published on March 11, 2017

NN Softmax loss function

Published on March 09, 2017