1

I recently have implemented the RESUNET for a parasite segmentation on blood sample images. The model is described in this papaer, https://arxiv.org/pdf/1711.10684.pdf and here is the code https://github.com/DuFanXin/deep_residual_unet/blob/master/res_unet.py. The segmentation output is a binary image. I trained the model with the weighted Binary cross-entropy Loss, given more weight to the parasite class since there is an imbalance of classes in my images. The last ouput layer has a sigmoid activation.

I calculate precision, recall, and Dice Coefficient value to verify how good is the segmentation on trainning. On training and validation I got good numerical results:

Training dice_coeff: .6895, f2: 0.8611, precision: 0.6320, recall: 0.9563

Validation val_dice_coeff: .6433, val_f2: 0.7752, val_precision: 0.6052, val_recall: 0.8499

However, when I try to visually see the segmentations of the validation set my algorithm outputs all black. After analyzing the predictions returned by the model, almost all values are close to zero, so it cannot correctly differenciate between background and foreground. The problems is: Why my metrics shows good numerical values but the segmentation ouput not? I mean, the metrics are not giving me good information? Why the recall value is higher even if the output is all black? I trained for about 50 epochs, and my training curves shows constantly learning. Is this because the vanishing gradient problem?

1 Answers1

2

No, you do not have a vanishing gradient issue.

I am almost 100% sure that the problem is related to the way in which you test.

The numbers in your training/validation do not lie.

Ensure that you use the exact same preprocessing on your test dataset, exactly the same preprocessing that is applied during the training.

E.g. : If you use "rescale = 1/255.0" parameter in Keras ImageDataGenerator(), ensure that when you load the test image, divide it by 255.0 before predicting on it.

Note that the aforementioned is a pure example; your inconsistency in train/test preprocessing may stem from other reasons.

Timbus Calin
  • 13,809
  • 5
  • 41
  • 59
  • 1
    Thanks. Yes you're right. My problem was in the test method. I use opencv for reading the input images, and I was wrong with the channels order so I was getting black output segmentations. – Allan Ojeda Jan 28 '20 at 15:04
  • You are welcome, if my answer led you on the path to solving your problem please accept it. – Timbus Calin Jan 28 '20 at 15:11