OpenDriveLab / TopoNet

Topology Reasoning for Scene Perception in Autonomous Driving
Apache License 2.0
280 stars 11 forks source link

Relationship loss #10

Closed artest08 closed 11 months ago

artest08 commented 11 months ago

Hello,

Thank you for your nice study. Why are using (1-target) instead of directly the targets in the focal loss? I am having difficulty in understanding the concept behind that manipulation.

https://github.com/OpenDriveLab/TopoNet/blob/b933f2817b02bdef4a47c90117dda3ba9544755a/projects/toponet/models/dense_heads/relationship_head.py#L100

Thanks in advance

sephyli commented 11 months ago

Hi, thanks for the good questuon.

In TopoNet, we utilize focal loss for relationship loss, proposed to address the imbalance between foreground and background predictions in object detection. Our implementation employs the built-in version of focal loss from mmdet, available here. In this loss calculation, a ground truth class value of 0 indicates the foreground, while 1 refers the background. However, in our the ground truth of adjacent matrix, 1 denotes a positive connection. So the 1 - target operation is utilized for this gap.

Empirically, the gap come from the implement convenience of detection loss and classification loss. In mmdet, some detection loss will use one-hot operation on the class label by default. For instance, if you replace the focal loss to the cross entropy loss in this scenario, this operation is not need.

A related and detailed discussion can be also found in the OpenLane-V2 repo issue #17.

artest08 commented 11 months ago

Thank you so much. It is an excellent explanation. However, it is weird that mmdet library has implemented in that way :)