OpenDriveLab / TopoNet

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

batch size #11

Closed eeeric1 closed 10 months ago

eeeric1 commented 10 months ago

Hi, I want to know if the code supports batch_size>1 TopoNet/projects/toponet/models/detectors/toponet.py L165 will check the gt_bboxes number. If batch_size>1, some images may contain gt_bboxes and the others may not contain gt_bboxes. How should I deal with this situation? Looking forward to your reply

sephyli commented 10 months ago

Good question. In the current implementation, when the batch size is 1, the bbox head's loss is set to 0 for images that do not contain traffic elements. This approach mitigates the issue of imbalanced positive and negative samples in the dataset.

However, as you pointed out, when the batch size > 1, images without traffic elements are still supervised. This leads to a slight difference in the network's performance when the batch size is larger than 1 compared to when it is 1. But empirically, the performance is not significantly affected by this.

If it's essential to align the performance of both cases, we could move this check inside the bbox head. We can set the loss to 0 for images in the batch that do not have traffic elements.

eeeric1 commented 10 months ago

thank you for your reply. Intuitively speaking, we also need to do the same processing in lcte_head. for images without bbox, their lcte_score should not be calculated either.