Image_Segmentation icon indicating copy to clipboard operation
Image_Segmentation copied to clipboard

SE: 0.0000, SP: 0.0000, PC: 0.0000, F1: 0.0000, JS: 0.0000, DC: 0.0000

Open wjj001-dl opened this issue 4 years ago • 9 comments

hello: Since I don't have a GPU, I reduced the number of pictures and the number of iterations.But the result shows 'SE: 0.0000, SP: 0.0000, PC: 0.0000, F1: 0.0000, JS: 0.0000, DC: 0.0000'

wjj001-dl avatar Apr 28 '20 08:04 wjj001-dl

I got the same results...

QianSiWang1 avatar May 05 '20 11:05 QianSiWang1

i have the same question. Except the ACC is not 0.0000

CodeXiaoLingYun avatar Jun 14 '20 07:06 CodeXiaoLingYun

Getting the same results for this. Any update?

DeVriesMatt avatar Jul 27 '20 17:07 DeVriesMatt

you can change TP and FN like this. TP = ((SR==1).byte()+(GT==1).byte())==2 .FN = ((SR==0).byte()+(GT==1).byte())==2.

wellfrogliu avatar Jul 28 '20 01:07 wellfrogliu

Anyone solve the problem...?

weiruchenai avatar Sep 04 '20 05:09 weiruchenai

hey guys. use pytorch<=1.2.0 (not confirmed) or change the funtion in "evaluation" to fit the calculation of bool tensor will sovle the problem e.g. change "TP = ((SR==1)+(GT==1))==2" to "TP = SR & GT"

apri0426 avatar Dec 06 '20 06:12 apri0426

hey guys. use pytorch<=1.2.0 (not confirmed) or change the funtion in "evaluation" to fit the calculation of bool tensor will sovle the problem e.g. change "TP = ((SR==1)+(GT==1))==2" to "TP = SR & GT"

thanks, i try it now, and do you have some recommend with pytorch > 1.2?

CodeXiaoLingYun avatar Dec 09 '20 01:12 CodeXiaoLingYun

when TP = ((SR==0)+(GT==1))==2 and TP = ((SR==1)+(GT==0))==2,how can i change?

rouchoo avatar Apr 09 '22 02:04 rouchoo

Hi everyone. I could give a summary here. Totally 10 lines need to be changed before you get it done.

TP = ((SR==1).byte()+(GT==1).byte()) == 2
FN = ((SR==0).byte()+(GT==1).byte()) == 2

TN = ((SR==0).byte()+(GT==0).byte()) == 2
FP = ((SR==1).byte()+(GT==0).byte()) == 2

TP = ((SR==1).byte()+(GT==1).byte()) == 2
FP = ((SR==1).byte()+(GT==0).byte()) == 2

Inter = torch.sum(SR.byte() + GT.byte() == 2)
Union = torch.sum(SR.byte() + GT.byte() >= 1)

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

ShugangZhang avatar Jun 15 '22 10:06 ShugangZhang

@ShugangZhang His code is right. If you are confuse, then copy and paste the below code. Replace evaluation.py . Then works well. Like this : [Training] Acc: 0.8920, SE: 0.7028, SP: 0.9610, PC: 0.8118, F1: 0.7290, JS: 0.5972, DC: 0.7290

(sorry, I don't know how to attach the code easy to copy and paste, so added the .zip file and code) `` import torch

SR : Segmentation Result

GT : Ground Truth

def get_accuracy(SR,GT,threshold=0.5): SR = SR > threshold GT = GT == torch.max(GT) corr = torch.sum(SR==GT) tensor_size = SR.size(0)*SR.size(1)*SR.size(2)*SR.size(3) acc = float(corr)/float(tensor_size)

return acc

def get_sensitivity(SR,GT,threshold=0.5): # Sensitivity == Recall SR = SR > threshold GT = GT == torch.max(GT)

# TP : True Positive
# FN : False Negative
TP = ((SR==1).byte()+(GT==1).byte()) == 2
FN = ((SR==0).byte()+(GT==1).byte()) == 2

SE = float(torch.sum(TP))/(float(torch.sum(TP+FN)) + 1e-6)     

return SE

def get_specificity(SR,GT,threshold=0.5): SR = SR > threshold GT = GT == torch.max(GT)

# TN : True Negative
# FP : False Positive
TN = ((SR==0).byte()+(GT==0).byte()) == 2
FP = ((SR==1).byte()+(GT==0).byte()) == 2

SP = float(torch.sum(TN))/(float(torch.sum(TN+FP)) + 1e-6)

return SP

def get_precision(SR,GT,threshold=0.5): SR = SR > threshold GT = GT == torch.max(GT)

# TP : True Positive
# FP : False Positive
TP = ((SR==1).byte()+(GT==1).byte()) == 2
FP = ((SR==1).byte()+(GT==0).byte()) == 2

PC = float(torch.sum(TP))/(float(torch.sum(TP+FP)) + 1e-6)

return PC

def get_F1(SR,GT,threshold=0.5): # Sensitivity == Recall SE = get_sensitivity(SR,GT,threshold=threshold) PC = get_precision(SR,GT,threshold=threshold)

F1 = 2*SE*PC/(SE+PC + 1e-6)

return F1

def get_JS(SR,GT,threshold=0.5): # JS : Jaccard similarity SR = SR > threshold GT = GT == torch.max(GT)

Inter = torch.sum(SR.byte() + GT.byte() == 2)
Union = torch.sum(SR.byte() + GT.byte() >= 1)

JS = float(Inter)/(float(Union) + 1e-6)

return JS

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

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

return DC

``

evaluation.zip

MangoINJuIce avatar Nov 21 '22 19:11 MangoINJuIce

i have the same question. Except the ACC is not 0.0000

Did you figure it out? I had the same problem

nit-xhg avatar Apr 22 '23 14:04 nit-xhg