Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems about JS=1 & DC>1 #41

Closed
Yiyiyimu opened this issue Sep 8, 2019 · 5 comments
Closed

Problems about JS=1 & DC>1 #41

Yiyiyimu opened this issue Sep 8, 2019 · 5 comments

Comments

@Yiyiyimu
Copy link

Yiyiyimu commented Sep 8, 2019

First of all, thank you for your code where I do learned a lot from. I work on a dataset looks like isic2018 where only got one category and around 900 images for training.

But I occur to a problem that when training, JS would keep equal to 1 and DC would even keeps greater than 1. I can't find reason since normalization in data_loader has already make sure DC could not larger than 1. Do you have any ideas?

I noticed things would happens when I use R2Unet and when SR output is totally black(nothing is divided out), maybe that would be helpful to find out where got something wrong.

Another problem is it seems the model cannot learn things during epoches processing, the best model would come out in first 5 epoches when training for like 200 epoches. Is that because model would get better result on small set and when it generalized to more images the score would drop?
By the way, implementing only U-net would not get DC>1 and get some result.

Thank you in advance for your help~


Edit:
Just found out JS would also stuck on 1.0 and DC greater than 1 when training Attention U-net but this time it get some result. So it maybe just JS and DC calculation problem
No way this time same situation happens to U-net and I changed nothing...

@Yiyiyimu
Copy link
Author

Yiyiyimu commented Sep 8, 2019

The original image looks like this
C3-1_C001S0001_1
and the output of image processed and normalized looks like this(save out at validation step)
R2U_Net_valid_1_image
So it seems not being normalized right? Cause you can find white and black on the same image so they are still range from 0 to 255. It seems weird to me


Edit:
Sorry I just find reason on pytorch documentation that it descale from [0,1] to [0, 255] at save_image function. You could add normalize==true to image's output to denormalize from [-1,1] to [0,1] to get not image in original color.
So this is not the reason of my problem, I still don't know why hah

@Yiyiyimu
Copy link
Author

Yiyiyimu commented Sep 9, 2019

DC and JS give possible values when I change evaluation function to (eg. DC)

def get_DC(SR,GT,threshold=0.5):
    # DC : Dice Coefficient
    SR = (SR > threshold).view(-1)
    GT = (GT == torch.max(GT)).view(-1)

    Inter = (SR*GT).sum()
    DC = float(2*Inter)/(float(SR.sum()+GT.sum()) + 1e-6)

    return DC

So basicly just change torch.max() to original array max, maybe there is something wrong here?
When I change all torch.max into max the result look like this

[Training] Acc: 0.9359, SE: 0.0742, SP: 0.9899, PC: 0.0742, F1: 0.0742, JS: 1.0000, DC: 1.7901
[TrainNEW] Acc: 0.9359, SE: 0.0742, SP: 0.9899, PC: 0.0742, F1: 0.0742, JS: 0.1408, DC: 0.2099
[Validation] Acc: 0.9408, SE: 0.1124, SP: 0.9468, PC: 0.1124, F1: 0.1124, JS: 1.0000, DC: 1.3627
[ValidatNEW] Acc: 0.9408, SE: 0.1124, SP: 0.9468, PC: 0.1124, F1: 0.1124, JS: 0.4825, DC: 0.6373

@Yiyiyimu
Copy link
Author

Seems the problem is solved, so I'd close this issue. Again, thank you for your contribution!

@CN-zdy
Copy link

CN-zdy commented Sep 18, 2019

Hi, @Yiyiyimu
How was the problem solved?
Could you help me?
Thank you very much!

@CN-zdy
Copy link

CN-zdy commented Dec 7, 2019

@Yiyiyimu
Could you help me?
In my test, SE & SP would keeps greater than 1.
Can you give me some advice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants