kbardool / Keras-frcnn

Keras Implementation of Faster R-CNN
Apache License 2.0
394 stars 314 forks source link

self.std_scaling = 4.0 variable in config #73

Open sanojdimri opened 4 years ago

sanojdimri commented 4 years ago

what is this variable for? I see that the bounding box offsets are multiplied by this factor in 'get_anchor_gt( )' function, but why?

Arthur023 commented 4 years ago

I wrote down that this is for scaling the image. This is because the VGG16 will scale your image down with a factor of 4. So the following line will be on the original scale

P_rpn = model_rpn.predict_on_batch(X)

But later you use the P_rpn in rpn_to_roi and here you want the rpn_layer to be on the smaller scale so you have to scale it down with factor 4.

To be honest I'm not sure but this is what I think is happening.

sanojdimri commented 4 years ago

VGG16 will scale down by a factor of 16 right? apart from that i don't think there is a need to scale because bounding box offsets are calculated considering the original image only and not the feature map. Only thing i can think of is that it is scaled it to increase the rpn regression loss.

Arthur023 commented 4 years ago

Yes of course you're right here. VGG16 will scale down with factor 16.

It is used on the rpn_out_regress_loss indeed. But I'm not sure why. Maybe it is because you have 4 points of loss in the rpn_out_regress_loss that it is devised my 4 to get the average loss on one point.

But it is first used in the part of the code where you generate ground true boxes. There you do 4 so I assume the /4 that is used later on is just a reaction on the 4 in the beginnen. So it's probably better to shift the focus to why we do *4 when generating ground true boxes.

image

sanojdimri commented 4 years ago

Exactly my point. My question was based on this snip only which you have attached.

Arthur023 commented 4 years ago

Yes I realized that when I answered. Maybe it would be useful to look into y_rpn_regr.shap() to see what the shame is and what it becomes after scaling. My model is running for the moment so I could take a look when that's done. (Hopefully tomorrow)

sanojdimri commented 4 years ago

Cool. Let me know about the updates. thanks :)

Arthur023 commented 4 years ago

Is there any chance that you know the answer on my question. On where or how we can add a validation set.

sanojdimri commented 4 years ago

I have not applied it but i have read about it. There is parameter of validation data in fit( ) function in keras. I think if you use it to train the model, you will be able to use validation data. Here, in this code, validation is not used in training.

Arthur023 commented 4 years ago

That's what I thought as well. I'm an a little confused why there is no validation set since that is kinda the basics of machine learning as far as I know. At least to avoid overfitting. So I'm wondering how train_on_batch avoids the overfitting problem

sanojdimri commented 4 years ago

Yes, if you have validation, its good, but its not necessary. Here, you can solve overfitting problem by seeing if training error is very low, but, test error is high, you go back and train the model to less number of iterations or change hyper parameters. It will be a more tidious way, but its the only way out as far as i know. Or stop training as soon as error ceases to decrease.

Arthur023 commented 4 years ago

I took a look but sadly I can't figure it out. If you have any idea please let me know

sanojdimri commented 4 years ago

I am following the same code as of now. If I get to know something, will surely share.

dcb-framatome commented 4 years ago

I have the same question regarding std_scaling. What is the actual purpose of this parameter?