czczup / ViT-Adapter

[ICLR 2023 Spotlight] Vision Transformer Adapter for Dense Predictions
https://arxiv.org/abs/2205.08534
Apache License 2.0
1.27k stars 140 forks source link

About num_classes for binary semantic segmentation in loss config #93

Open gjustin40 opened 1 year ago

gjustin40 commented 1 year ago

I'm still working for binary semantic segmentation that has two classes(background:0 / foreground:1 == building)

I have some questions about config of loss.

num_classes=2

        loss_cls=dict(
            type='CrossEntropyLoss',
            use_sigmoid=False,
            loss_weight=2.0,
            reduction='mean',
            class_weight=[1.0] * num_classes + [0.1]),
        loss_mask=dict(
            type='CrossEntropyLoss',
            use_sigmoid=True,
            reduction='mean',
            loss_weight=5.0),
        loss_dice=dict(
            type='DiceLoss',
            use_sigmoid=True,
            activate=True,
            reduction='mean',
            naive_dice=True,
            eps=1.0,
            loss_weight=5.0)
  1. Should i use use_sigmoid= in loss_cls to True if binary segmentation?
  2. In loss_cls, why 'class_weight' has one more class? [1.0]*num_class and extra [0.1]

Thanks

XinzheGeng commented 1 year ago

I also meet the same problem. Have you successfully trained on the binary semantic segmentation? @gjustin40