How to label training data for YOLO

I am having a question on how to label training data for YOLO algorithm.

Let's say that each label Y, we need to specify $$[P_c, b_x, b_y, b_h, b_w]$$, where $$P_c$$ is the indicator for presence (1=present, 0=not present), $$(b_x, b_y)$$ is the relative position of the center of the object-of-interest, and $$(b_h, b_w)$$ is the relative dimension of the bounding box containing the object.

Using picture below as an example, the cell (1,2), which contains a black car, should have a label $$Y = [1, 0.4, 0.3, 0.9, 0.5]$$. And for any cells without cars, they should have a label $$[0, ?, ?, ?, ?]$$ [Coursera Deep Learning Specialization Materials]

But if we have a finer grid like this, where the dimension of each cells is smaller than the ground truth bounding box.

Let's say that the ground truth bounding box for the car is the red box, and the ground truth center point is the red dot, which is in cell 2.

For cell 2 it will have label $$Y = [1, 0.9, 0.1, 2, 2]$$, is this correct? And for cell $$1, 3, 4$$ what kind of label will they have? Do they have $$P_c=1$$ or $$P_c = 0$$? And if $$P_c=1$$, how will the $$b_x$$ and $$b_y$$ be? (As I remember that $$b_x, b_y$$ should have value between $$0$$ and $$1$$. But in cell $$1,3,4$$ there is no center point of the object-of-interest)

In effect, the midpoint is contained in cell $$2$$. Cells $$1,3,4$$ will be shown at $$P_c=0$$ according to the YOLO algorithm, which only takes in count the cell that contains the midpoint and calculates the bounding box, as you mentioned, with $$b_y b_x, b_y, b_h, b_w$$. With the proposition of $$Y = [1, 0.9, 0.1, 2, 2]$$, I would think that if you take the point $$(0,0)$$ as the left-upper corner, $$Y$$ would be more likely to be $$Y = [1,0.2,0.57,0.21,0.15]$$, being calculated with a grid of $$19 \times 19$$.

• Thank you for answering my question. Still I have queries. But What bx, by, bh, bw values should I give for cell 1,3,4 as we are giving Pc as 0? Are you sure that we have to take only the cell contains mid points? Also can you explain the calculations being done for Y = [1,0.2,0.57,0.21,0.15]? Thank you for the help. – Gokulakannan Jul 13 '18 at 4:38
• In fact, Y.O.L.O. algorithm doesn't compute any calculations in cells with Pc=0, then the values over these cells (1,3,4) are irrelevant for the algorithm, that's why the representation is [0, ?, ?, ?, ?] . Calculations over bx, by, bh, and bw are computed with a simple rule of three. I attached an image in the answer to represent it. – Bitzel Jul 13 '18 at 5:09
• Thank you for the answer. what about bh and bw? – Gokulakannan Jul 13 '18 at 5:15