Image_Segmentation
Image_Segmentation copied to clipboard
SE: 0.0000, SP: 0.0000, PC: 0.0000, F1: 0.0000, JS: 0.0000, DC: 0.0000
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'
I got the same results...
i have the same question. Except the ACC is not 0.0000
Getting the same results for this. Any update?
you can change TP and FN like this. TP = ((SR==1).byte()+(GT==1).byte())==2 .FN = ((SR==0).byte()+(GT==1).byte())==2.
Anyone solve the problem...?
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"
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?
when TP = ((SR==0)+(GT==1))==2 and TP = ((SR==1)+(GT==0))==2,how can i change?
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 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
``
i have the same question. Except the ACC is not 0.0000
Did you figure it out? I had the same problem