drprojects / superpoint_transformer

Official PyTorch implementation of Superpoint Transformer introduced in [ICCV'23] "Efficient 3D Semantic Segmentation with Superpoint Transformer" and SuperCluster introduced in [3DV'24 Oral] "Scalable 3D Panoptic Segmentation As Superpoint Graph Clustering"
MIT License
545 stars 71 forks source link

Focal Loss #56

Closed StevenZhangzhexu closed 8 months ago

StevenZhangzhexu commented 8 months ago

Hi @drprojects , I saw there was an implementation src/loss/focal.py of focal loss and I would like to apply it as loss function during traning on my dataset (imbalanced). Could you please advise how to do so? Thanks

drprojects commented 8 months ago

Hi, you can try moving from CrossEntropy to FocalLoss by changing these lines to:

criterion:
     _target_: src.loss.FocalLoss

In my experiments, this did not change much for the benchmarked datasets. The code for the Focal and Lovasz losses is a remnant of past experiments, I cannot guarantee that they will work well with the multi-stage loss formulation (triggered by the multi_stage_loss_lambdas parameter). If it causes any issue, you can turn it off by setting multi_stage_loss_lambdas: null in the corresponding config.