I have been reading various articles and watching videos on YouTube, but I can't seem to understand one thing.

How does YOLO make a bounding box for an object if it is in multiple grid cells? For example, in the picture given below, how does it predicts the bounding box for the classes, because they fall in multiple cells? How does it know what object is in a grid cell even when it sees a small part of it?

It's been very difficult for me to get these answers.


1 Answer 1


Lets say you split the image by 13x13 (SxS) cells. For each grid cell, you predict 5 (older YOLO) or 9 (newer versions) bounding boxes.

These (anchors) are supposed to have various shapes and scales, so they vertical, horizontal and squared rectangle at small scale, and middle scale and bigger scale.

So for each cell (13x13) and for each anchor (9) , you predict (width offset ,height offset,center x,center y, objectness, class1 ,class2,... class k ). You actually predict scaling of the width and height of the box, so you can end up with variable sizes.

Ojectness marks if there is any object in this cell for this anchor, if not, it is discarded later.

Since you end up with lot of predicted bounding boxes of various shapes, you need to filter them out, this is called non maximum supression. For each anchor you take class with highest confidence.


So to answer your questions, If an object is in multiple cells, it is contained in multiple predicted boxes, and you take the one with maximum confidence and discard others.

Each cell does not see only part of the image, it sees the whole image. Before you get to 13x13 cells, you have 50 or more layers of conv & max pooling layers, which gives each cell receptive field of the whole image.

  • $\begingroup$ Firstly, thank you very much for taking your valuable time to answer my question. Secondly, can you please brief me a little more about anchors boxes? Are bounding boxes and anchors boxes mean the same thing? Are their positions are fixed for each grid? What if the objects that we are looking for doesn't falls in any of the 9 anchors boxes? What do we do then? Do we get any prediction if objects doesn't falls in those 9 anchors boxes or we don't? $\endgroup$ Jun 24 at 13:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .