The boundaries of the object are encoded into 4 scalars: Bx, By, Bh, Bw. Bh and Bw are calculated using the ratio of the width of the bounding box to the width of the relative grid cell. But I can't find any explanation on how exactly the coordinates Bx and By of the mid-point are selected?
As far as midpoint is considered, you already know it as it is given in the training dataset(or can be calculated from the labelled rectangle coordinates).
About calculating Bx and By from midpoint(let's say p,q):
A single grid block size: (m,m)
Bx = (p - m*floor(p/m))/m ,similar for By. [floor being the integer part of a decimal number]
Hope this helps...