Welcome to this section on modeling and the section which I'll work with the CSR net model, which,
when given an input image and output density map can be used to train a people account and model.
This model is based on the paper dialectic convolutional neural networks for understanding the highly
congested scenes by you hung Li Zhao and Zheng and Deming Cheng in this paper the proposed the CSR need
to provide a data driven and deep learning matter that can understand highly congested scenes and perform
accurate count estimation as well as present high quality density maps.
The proposed CSR net is composed of two major components a convolutional neural network as the front
end for 2D feature extraction.
This, while we generally call our base model and a dilated scene for the back end, which uses dilated
canals to deliver larger receptive fields and to replace pulling operations, CSR net is easy to train
because of its purely convolutional structure, the backbone of the CSR net.
So VG 16 model and this was picked because of its flexible architecture for easily concatenate in the
back end.
For density map generation, we shall look at it shortly and also because of its strong transfer learning
ability.
Looking at this configuration right here, we have four different possibilities.
That's A, B, C, and D, which are later on choose the B because of the results they obtained right
here.
Thus, B had the lowest mean average error and mean square error.
Anyway, we have this four possibilities A, b, c, and D.
Initially all of them have the same kind of input.
In this case it's 768 by 1024.
Then we have our base model, which is fine tuned from the VG 16.
Yeah, we remove the top layers so we're left with the first layers.
Now to see exactly the layers from the G 16, which we shall use for the feature extraction we have
this year.
This two three by three conv layers with 64 channels.
We have a max pool, we have this two three by three conv layers, 128 channels max pull this one max
pool three by three 512 and note that the dilation rate is equals one all throughout the VG model.
So basically this is our base model, which is the VG now coming to the back end.
That's what we call the back end year.
We have this fall.
Let's take the case.
B we have this three by three conv layer with 512 channels and dilation rate of two.
Also notice how it's very easy for us to leave from this output here and then continue with those back
end layers.
Now, after going through this back and layers, we now finish up with us one by one conv layer with
one channel and then dilation rate of one.
And then we notice that we live from our we have this input and then the outputs need to be divided
by eight of this input.
So we note is that after going to this first max pooling would divide our input by two.
That is, the input dimension is divided by two.
Then one will go to this.
Next we divide it again by two.
So now we've divided by four with respect to the input and then this will divide it by eight with respect
to the input.
So this is how we ensure that we actually get an output, which is eight times.
Smaller than the input right here.
Now, looking at the code, we are going to fine tune our Widget 16 model, which has been trained on
Image Net.
We have the input and in fact we have the input chip right here.
We don't include the top, so let's run this.
You have the results we obtained for our VG 16 model will see that.
So 40 million parameter model which goes from which takes in this input and then goes right up to this
because we don't we don't include the top.
Now, since we are having an output which has this, we will notice that we shall actually use this
first layers right up to this one right here as given in the paper.
Because in the paper we have this first tool.
Max, pull this tool.
Max pull this to re Max pull this to re.
So we wouldn't consider this last all layers before the last layer because this already, this isn't
the last layers because we've already decided not to include the top right here.
Now what we'll do is we shall copy out this name.
So we take this block for conf three.
And then it shall be used now.
So instead of having to output the model itself, we shall have this model output only at the level
of this block for comfortably right here.
So we have this block fork after which we pick out, and then we have it as our output.
So that's it way.
Now return this model which has the inputs and then returns the output at this point.
BLOCK for count three right here.
Now let's rerun it again and see what we get, what we obtain.
Now we see we have this suitable output right here which matches what we had in the paper.
Also recall that from the paper we have fine tuning the VG 16 model, so we are not setting this layers
to untraceable so we don't freeze this first layers right here.
Now we've had this base model we could now go ahead to adding up the last layers, which in the paper
to call the back end.
We now define this layers where we have our input in X, in Y, we get the base model that has the inputs
into our base model, which is what we've just defined.
We have this random initialization which is still in the paper, and then the purpose to have the standard
deviation of 0.01.
Then following what's given the paper, we have this 512 number of channels, three by three channel
activation radio dilation raid two we fill in the Part B, so that's why we have this dilation rates
of 2 to 2.
And then finally, this is one and the pattern is the same so that we maintain this dimension of 96
by 128.
Now we could run this and there we go.
That's way we have.
So that's fine.
Now we'll note that we also have to do this reshape because after going through this Conv layer, we
have this 96 by 188 by one.
So we ship this to obtain this value right here.
Now, once we have this, we are ready to train our model.