hank-ai / darknet

Darknet/YOLO object detection framework
https://darknetcv.ai/
Apache License 2.0
267 stars 43 forks source link

the role of compare_yolo_class #73

Open david0100101 opened 2 months ago

david0100101 commented 2 months ago

Hi guys, i want to apologize if this is misleading title, i 'm trying to comprehend yolo loss calculation in yolo_layer.cpp file, one detail particularly seems like a bug, on line 603 int class_id_match = compare_yolo_class(l.output, l.classes, class_index, l.w * l.h, objectness, class_id, 0.25f); Judging by variable name this function suppose to produce boolean value if current truth class we comparing box against appears in output in any way, yet inside this function we simply returning true if any random class is above certain threshold. Am i wrong ? Moreover it contains class_id as an argument but it is unused inside. This seems really counterintuitive. Again sorry if this was already brought up or this should be this way for some unknown reason. If this is correct maybe it can be renamed to any_class_response or something similar to better reflect function purpose and return value ?

Tony904 commented 1 month ago

I looked into this recently as I too am trying to understand yolo's loss function. I looked back at the change history when this change was made and it originally seemed to function the way you think it would, by checking if the passed class_id had a predicted score over 0.25, but then it was changed to what it is now. So that would lead me to believe the change was intentional and somehow provides better results, but ultimately I do not know.

david0100101 commented 1 month ago

I looked into this recently as I too am trying to understand yolo's loss function. I looked back at the change history when this change was made and it originally seemed to function the way you think it would, by checking if the passed class_id had a predicted score over 0.25, but then it was changed to what it is now. So that would lead me to believe the change was intentional and somehow provides better results, but ultimately I do not know.