qubvel-org / segmentation_models.pytorch

Semantic segmentation models with 500+ pretrained convolutional and transformer-based backbones.
https://smp.readthedocs.io/
MIT License
9.52k stars 1.66k forks source link

dice_loss - -ve, iou_score - -ve #234

Closed PareshKamble closed 2 years ago

PareshKamble commented 4 years ago

Dear @qubvel Thank you for this amazing library.

I tried to build a UNet model with ResNet152 as a backbone and 1 class 'person'. I used input images of 512x512 as input and corresponding binary masks. I used your sample code of CamVid notebook as a base and did some tuning in the same to make it work for my dataset. However, I am getting dice loss and iou score as negative. dice_loss - -10.63, iou_score - -1.209 Have you ever come across such an issue? Can you suggest some solution for this?

m-birke commented 4 years ago

Just got the same problem, currently no idea what the reason is....

qubvel commented 4 years ago

Make sure your mask is scaled to [0, 1] values, not 0 and 255.

Interstell commented 4 years ago

Check if your mask tensor has shape (1, N, M), not (N, M). It worked for me.

m-birke commented 4 years ago

Yes, I also had an alterring tensor shape

junjun1023 commented 3 years ago

Just met the same problem, dice-loss becoming negative and iou becoming more than 1 I have checked the following points:

  1. Shape of input image/mask tensor
  2. Scaled value to [0, 1]
  3. Use activation function for model or losses, instead of both

But the problem still exists...

junjun1023 commented 3 years ago

I resolved my problem. It turns out that the shape of my groundtruth is [batch, 3, N, M] while my prediction's is [batch, 1, N, M].

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 2 years ago

This issue was closed because it has been stalled for 7 days with no activity.