teamtomo / membrain-seg

membrane segmentation in 3D for cryo-ET
Other
47 stars 12 forks source link

Potential bug in `masked_accuracy`. #44

Closed DuskNgai closed 5 months ago

DuskNgai commented 6 months ago

In src/membrain_seg/segmentation/training/metric_utils.py, I found when ignore_label is set to None, the function returns a nan. I examined the code and found that there may be a bug in your function masked_accuracy:

def masked_accuracy(...):
    ...
    mask = (
        y_gt == ignore_label
        if ignore_label is not None
        else torch.ones_like(y_gt).bool()
    )

I think it should be torch.zeros_like(y_gt).bool() instead of torch.ones_like(y_gt).bool().

Looking forward to your reply and hope it can be fixed soon~

LorenzLamm commented 5 months ago

Thanks a lot for pointing out! I never used it without setting the ignore label, so this didn't appear to me. But you're absolutely correct. I fixed the bug in the latest PR (https://github.com/teamtomo/membrain-seg/pull/45).

LorenzLamm commented 5 months ago

Merged now into the main repository, so closing this issue