yolov5-face icon indicating copy to clipboard operation
yolov5-face copied to clipboard

It should be a BUG

Open Dpaul891 opened this issue 3 years ago • 2 comments

Bug explain

When the number of classes equals 1, which means single class. There is a bug. (The original code is single class, only Face)

During the training process, the loss of classification lcls will be 0, so lcls will not backpropagate, the weights related to cls_conf will not be trained. Refer to utlis/loss.py.

But, during the NMS process, the final confidence for comparing with threshold is calculated by x[:, 15:] *= x[:, 4:5] # conf = obj_conf * cls_conf, refer to utlis/general.py. Which means the random value cls_conf (not trained) is used in the NMS process, which should cause problem.

Fortunately, the values of cls_conf are near 1 during the process (about 0.98, but randomly). So, the code seems to be working well, but a bug is behind it.

To fix the bug

When the number of classes equals 1, during the NMS process, we should only use obj_conf to compare with threshold. However, when the number of classes is graeter than 1, there is no bug.

Dpaul891 avatar Apr 19 '22 09:04 Dpaul891

Hello, I ran into some problems when modifying the category number of the program. The program could not carry backward, lcls += BCEcls(ps[:, 15:], t), there is something wrong with this statement

Do you have any good suggestions, thank you very much

gatzf avatar Nov 10 '22 06:11 gatzf