RazvanDu / DUCK-Net

Using DUCK-Net for polyp image segmentation. ( Nature Scientific Reports 2023 )
Creative Commons Attribution 4.0 International
101 stars 25 forks source link

loss is always 1 #6

Closed Terminal-K closed 11 months ago

Terminal-K commented 1 year ago

Hi, when I run the notebook for training, I find the loss is always 1, is this normal? Snipaste_2023-11-07_17-33-23 By the way, I couldn't install tensorflow2.10.0 for some reason with the server, so I used tensorflow2.3.0 instead and also made the code running.

maenstru56 commented 1 year ago

Hello,

This is not normal behaviour, the loss function should be decreasing during training. To fix the issue, please try the following;

I hope this helps!

Terminal-K commented 11 months ago

@maenstru56 Hi, I think I have identified where the problem lies. When reading the mask image, I set 'asgrey' to True in the imread function as #4 , which causes the mask values to be in the range of (0,1), leading to an error (no raise) in the judgment of 'mask'. I suggest modifying https://github.com/RazvanDu/DUCK-Net/blob/44eca89e5ce79aedac805b09d0b38e545ca696de/ImageLoader/ImageLoader2D.py#L54-L57 as follows: mask[mask_[:, :, 0] > 127] = 1 and it can harness the features of NumPy for acceleration as well.

I successfully made the code work using this approach with the environment of tf2.3.0. image

maenstru56 commented 11 months ago

Hello,

In our original data loader the "imread" function is called without the "as_grey=True" parameter, so the original code should work as intended.

Thanks for pointing out the issue and finding a fix when the "as_grey" parameter is set to "True"!