MCG-NJU / SparseOcc

[ECCV 2024] Fully Sparse 3D Occupancy Prediction & RayIoU Evaluation Metric
https://arxiv.org/abs/2312.17118
Apache License 2.0
129 stars 13 forks source link

关于loss的疑问 #20

Open Sunway-s opened 1 month ago

Sunway-s commented 1 month ago

对于SparseOcc/models/loss_utils.py中291行的 loss_classes 计算我有一些疑惑

tgt_class = class_gt[b]
tgt_mask = (tgt_mask.unsqueeze(-1) == torch.arange(num_instances).to(mask_gt.device))
tgt_mask = tgt_mask.permute(1, 0)

src_idx, tgt_idx = indices[b]
src_mask = mask_pred[b][src_idx]   # [M, N], M is number of gt instances, N is number of remaining voxels
tgt_mask = tgt_mask[tgt_idx]   # [M, N]
src_class = class_pred[b]   # [Q, CLS]

# pad non-aligned queries' tgt classes with 'no class'
pad_tgt_class = torch.full(
       (src_class.shape[0], ), self.num_classes - 1, dtype=torch.int64, device=class_pred.device
)   # [Q]
pad_tgt_class[src_idx] = tgt_class

为什么这里的 tgt_class 不用加 tgt_class[tgt_idx] 呢,而是直接 tgt_class = class_gt[b]

afterthat97 commented 1 month ago

Sorry for the late reply. It is a BUG. We retrained the model but it doesn't seem to affect the performance. We are working to find out the reason. Thank you very very much!

afterthat97 commented 1 month ago

We investigated this bug and found that it only affects the initial stage of class loss. In the later stage, tgt_idx is mostly ordered, so it has little impact on the final performance.

Class loss:

image

RayIoU:

image
afterthat97 commented 1 month ago

Thank you so much for reading our code so carefully!