I'm trying to implement a custom version of YOLO neural network. Originally it was described in this paper. I have some problems understanding the loss function they used.
- An input image is divided into S by S grid (that gives the total of S^2 cells) and each cell predicts B bounding boxes and c conditional class probabilities. Each bbox predicts 5 values: x,y,w,h,C (center of bbox, width and height and confidence score). This makes the output of yolo a SxSx(5B*c) tensor.
- The (x,y) coordinates are calculated relative to the bounds of the cell and (w,h) is relative to the whole image.
- I understand that the first term penalizes the wrong prediction of the center of a bbox; 2-nd term penalizes wrong width and height prediction, 3-rd term - wrong confidence prediction, 4-th is responsible for pushing confidence to zero when there is no object in a cell; the last term penalizes wrong class prediction.
I don't understand when 1^obj_ij should be 1 or 0. In the paper, they write: "1^obj_ij denotes that the j-th bbox predictor in i-th cell is responsible for that prediction" and also "Loss function only penalizes bounding box coordinate error if that predictor is responsible for ground truth box".
So is it right that for every object in the image there should be exactly one pair of ij such taht 1^obj_ij=1? And if this is correct, this means that the center of the ground truth bbox should fall into i-th cell, right?
If this is not the case, what are other possibilities when 1^obj_ij=1 and what ground truth labels x_i and y_i should be in these cases?
Also, I assume that ground truth p_i(c) should be 1 if there is an object of class c in the cell i, but what ground truth p_i(c) should be equal to in case there are several objects of different classes in the cell?