ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.34k stars 16.25k forks source link

question about Object loss #5108

Closed yongjingli closed 3 years ago

yongjingli commented 3 years ago

❔Question

@glenn-jocher Thank you for your nice work! And now I have a question. When the IOU of the target and predict are the same but not 0 or 1(for example, 0.5) , the BCEloss = 0.5log(0.5) + (1- 0.5) log(1-0.5) != 0. At this situtation, BCEloss is not 0. which I think should be 0. Can you give me some explanation why use IOU as the target of Objectness?

Additional context

glenn-jocher commented 3 years ago

@yongjingli yes IoU range from 0 to 1, but G/D/CIoU family of losses (https://giou.stanford.edu/GIoU.pdf) range from -1 to 1. When used for Objectness target we clamp this to 0 at the lower range. https://github.com/ultralytics/yolov5/blob/276b6745132f2da0641706124c466b69f21b670c/utils/loss.py#L138-L144

yongjingli commented 3 years ago

@glenn-jocher , yes, thank you for you quick answer. As obji = self.BCEobj(pi[..., 4], tobj), I also want to know the reason why when sigmoid(pi[..., 4]) = tobj, but BCEloss != 0.

glenn-jocher commented 3 years ago

@yongjingli I'm sorry I don't understand the question.

yongjingli commented 3 years ago

@glenn-jocher sorry, maybe I can't express it clearly enough to make you wonder. And now I maybe figure it out, thank you for your answer.