I am trying to understand the concept of Faster RCNN.
For example, in an image(224×224), there are only two objects. To create a mini-batch of anchors of length 256(128-Foreground, 128-background) from the image, I get only 30 anchors which IOU is greater than 0.7 when compared with the ground truth bounding box.
In this situation, how should I make the foreground objects balanced with background?
You can just get rid or set a predefined ratio between the foreground to the background.
In the following link, he set the ratio of foreground to background to be 1/3.
The github of this tutorial is:
https://github.com/dongjk/faster_rcnn_keras/blob/master/RPN.py
It's a full tutorial that walks through the steps before training a Faster-RCNN, in your case the RPN script in the GitHub has the solution you are after.
Note that you do not want a full balance but a reasonable ratio, because in most cases the background is the majority of the image in case of a very specific dataset that this is not the case.
Sir, if I set the ratio as 1/3, even in that case, if I face the foreground Object is lesser, then shall I add the rest as zero. Is it give good results...
@vishakraj it really depend on your data. basically in most cases you will have much more background then foreground, so you should probably need to fine tune it to your data. I would try several ratios and test each one see which gives the best results (some sore of ablation study on the ratio)