Open rameses666 opened 4 years ago
And the prediction was all black.
@milesial Can you help me?Thank you very much.
Yes the mask images should be B&W, not RGB. Try that.
Hi! I changed the mask images to B&W,but the loss is negative when I was trainning,and Dice coeff is > 1.I don't know why.Thank you very much.
if the loss is negative you are loading your masks wrong, check that you correctly modified the preprocess method
I had the same problem. When my mask images were B&W, the loss is negetive and Dice coeff >1. Can you be more specific,please?
@Cassie0207 You have to check that your loaded masks after the preprocess method, if you have 2 or 1 classes, are 0s and 1s only. If they are not, you should modify this method to fit your dataset
I had the same problem.The prediction was all black. what is B&W,is that a kind of color style in PIL?
B&W means black & white. With PIL you can convert to greyscale https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.convert .
Thank you so much, I have changed the mask to grayscale and the predictions are still all black, I think it may caused by things below, but I am not sure about it, could you please help me? 1、the flollowing picture is dataset.py , I just add one line in get_item() to get B&W masks, and I remove the scale set and resize all pictures to 224,224. I think it is safe but I am not sure... 2、I set lr=0.001 and epochs=200 or more, the final loss is about 0.05552403015846556,but the result is still bad, I only have 50 training data, does it cause the bad result? I am trying to add data argumention, but I hope to make sure I didn't do something wrong here. Could you please give me some suggestions, thank you very much!!!
With 50 training data and no data augmentation I don't think you can expect good generalization results. The line you added seems fine if you have binary labels, you need to check that you have only 0s and 1s in your mask. If you have more than 2 classes, the mask should contain class indices.
With 50 training data and no data augmentation I don't think you can expect good generalization results. The line you added seems fine if you have binary labels, you need to check that you have only 0s and 1s in your mask. If you have more than 2 classes, the mask should contain class indices.
how many images does the training set need?
I have the same question, Dice coefficient doesn't change and is always very close to 0.
I don't change the code, what is the problem?
I have the same issue that even though the training is completed and prediction works and it outputs almost correct labels, the Dice coefficient is always very close to 0
@Quebradawill
how many images does the training set need?
It depends on the difficulty of your task and the data augmentation you're willing to do. For Carvana the training set was more than 4000 images.
To help me debug the DICE issue, could you please give me a sample of what your self.inter
and self.union
values look like in https://github.com/milesial/Pytorch-UNet/blob/84f8392b619940bd542dc670761a0a7a1357001d/dice_loss.py#L11-L12 ?
Also, how many images are in your validation set?
@Quebradawill
how many images does the training set need?
It depends on the difficulty of your task and the data augmentation you're willing to do. For Carvana the training set was more than 4000 images.
thanks for your advice
My dice score now seems to be representing the correct number and it's fixed. I think the problem was the learning rate, and after adjusting that, the model seemed to learn much better even though I was getting mask prediction while the dice score was very close to 0.
I meet same issue, but I have solved it when I changed the learn rate to 0.0001. I hope it can help you.
I meet same issue, but I have solved it when I changed the learn rate to 0.0001. I hope it can help you.
it works for me ,thanks
I meet same issue, but I have solved it when I changed the learn rate to 0.0001. I hope it can help you.
It works for me , too . Thanks a lot !
I meet same issue, but I have solved it when I changed the learn rate to 0.0001. I hope it can help you. It works for me , too. Thank you. But sometimes I can train normally,sometimes the dice coefficient still no change and very close to 0. Have you ever encountered such a problem?
You can try changing the optimizer.
I have a similar problem. The dice score is very close to zero and the training is stopped by an error (IndexError: Target 198 is out of bounds.) This happens on line 93 when calculating the loss function. I tried changing the learning rate with no success. I use b&w masks.
preprocess() missing 1 required positional argument: 'is_mask'
preprocess() missing 1 required positional argument: 'is_mask'
But why did the car dataset work successfully? I replaced the dataset with my own dataset, and the format was the same as the original dataset, but an error occurred : IndexError: Target 225 is out of bounds. I searched all methods about this error but.... could you explained the 'missing' in more details please?
I converted the mask to black and white and changed the learning rate to 0.0001, but Dice coefficient also no change during training,is always very close to 0. @milesial can you help me?
I converted the mask to black and white and changed the learning rate to 0.0001, but Dice coefficient also no change during training,is always very close to 0. @milesial can you help me?
I encountered the same problem. After adjusting the learning rate, dice remains unchanged and approaches 0. Have you solved this problem?
I converted the mask to black and white and changed the learning rate to 0.0001, but Dice coefficient also no change during training,is always very close to 0. @milesial can you help me?
I encountered the same problem. After adjusting the learning rate, dice remains unchanged and approaches 0. Have you solved this problem?
any updates on this? i have tried everything from adjusting the learning rate, removing amp,... everything else is like in the README, i am using the carvana dataset. @milesial
Hi!I trained the model on the ultrasonic grayscale image, since there are only two classes, I changed the code to net = UNet(n_channels=1, n_classes=1, bilinear=True), and when I trained, the loss (batch) was around 0.1, but the validation dice coeff was always low, like 7.218320015785669e-9. Is this related to the number of channels? My dataset MASK background is black and the target is red, does it need to be changed to black and white? The dataset MASK and IMG are both 8-bit.