Closed Yffy123456 closed 2 years ago
you can refer to the issue #8 and #14, and modify the evaluation code as follows
import numpy as np
def get_accuracy(SR,GT,threshold=0.5):
SR = SR.view(-1)
GT = GT.view(-1)
SR = SR.data.cpu().numpy()
GT = GT.data.cpu().numpy()
SR = SR > threshold
GT = GT == np.max(GT)
corr = np.sum(SR==GT)
acc = float(corr)/float(SR.shape[0])
return acc
def get_sensitivity(SR,GT,threshold=0.5):
SR = SR.view(-1)
GT = GT.view(-1)
SR = SR.data.cpu().numpy()
GT = GT.data.cpu().numpy()
SR = (SR > threshold).astype(np.float)
GT = (GT == np.max(GT)).astype(np.float)
# TP : True Positive
# FN : False Negative
TP = (((SR == 1.).astype(np.float) + (GT == 1.).astype(np.float)) == 2.).astype(np.float)
FN = (((SR == 0.).astype(np.float) + (GT == 1.).astype(np.float)) == 2.).astype(np.float)
SE = float(np.sum(TP)) / (float(np.sum(TP + FN)) + 1e-6)
return SE
def get_specificity(SR,GT,threshold=0.5):
SR = SR.view(-1)
GT = GT.view(-1)
SR = SR.data.cpu().numpy()
GT = GT.data.cpu().numpy()
SR = (SR > threshold).astype(np.float)
GT = (GT == np.max(GT)).astype(np.float)
# TN : True Negative
# FP : False Positive
TN = (((SR == 0.).astype(np.float) + (GT == 0.).astype(np.float)) == 2.).astype(np.float)
FP = (((SR == 1.).astype(np.float) + (GT == 0.).astype(np.float)) == 2.).astype(np.float)
SP = float(np.sum(TN)) / (float(np.sum(TN + FP)) + 1e-6)
return SP
def get_DC(SR,GT,threshold=0.5):
# DC : Dice Coefficient
SR = SR.view(-1)
GT = GT.view(-1)
SR = SR.data.cpu().numpy()
GT = GT.data.cpu().numpy()
SR = (SR > threshold).astype(np.float)
GT = (GT == np.max(GT)).astype(np.float)
Inter = np.sum(((SR+GT)==2).astype(np.float))
DC = float(2*Inter)/(float(np.sum(SR)+np.sum(GT)) + 1e-6)
return DC
Hello, sorry to bother you, See your article 《Automatic Segmentation and Classification of Thyroid Nodules in Ultrasound Images with Convolutional》 on Springer Unfortunately, I have to pay a fee. I am still a student, so I can't pay a Neural network. So I was wondering if you could send me a copy. I'm sorry to bother you.
------------------ 原始邮件 ------------------ 发件人: "WAMAWAMA/TNSCUI2020-Seg-Rank1st" @.>; 发送时间: 2022年8月19日(星期五) 下午2:14 @.>; @.**@.>; 主题: Re: [WAMAWAMA/TNSCUI2020-Seg-Rank1st] ask help (Issue #35)
you can refer to the issue #8 and #14, and modify the evaluation code as follows import numpy as np def get_accuracy(SR,GT,threshold=0.5): SR = SR.view(-1) GT = GT.view(-1) SR = SR.data.cpu().numpy() GT = GT.data.cpu().numpy() SR = SR > threshold GT = GT == np.max(GT) corr = np.sum(SR==GT) acc = float(corr)/float(SR.shape[0]) return acc def get_sensitivity(SR,GT,threshold=0.5): SR = SR.view(-1) GT = GT.view(-1) SR = SR.data.cpu().numpy() GT = GT.data.cpu().numpy() SR = (SR > threshold).astype(np.float) GT = (GT == np.max(GT)).astype(np.float) # TP : True Positive # FN : False Negative TP = (((SR == 1.).astype(np.float) + (GT == 1.).astype(np.float)) == 2.).astype(np.float) FN = (((SR == 0.).astype(np.float) + (GT == 1.).astype(np.float)) == 2.).astype(np.float) SE = float(np.sum(TP)) / (float(np.sum(TP + FN)) + 1e-6) return SE def get_specificity(SR,GT,threshold=0.5): SR = SR.view(-1) GT = GT.view(-1) SR = SR.data.cpu().numpy() GT = GT.data.cpu().numpy() SR = (SR > threshold).astype(np.float) GT = (GT == np.max(GT)).astype(np.float) # TN : True Negative # FP : False Positive TN = (((SR == 0.).astype(np.float) + (GT == 0.).astype(np.float)) == 2.).astype(np.float) FP = (((SR == 1.).astype(np.float) + (GT == 0.).astype(np.float)) == 2.).astype(np.float) SP = float(np.sum(TN)) / (float(np.sum(TN + FP)) + 1e-6) return SP def get_DC(SR,GT,threshold=0.5): # DC : Dice Coefficient SR = SR.view(-1) GT = GT.view(-1) SR = SR.data.cpu().numpy() GT = GT.data.cpu().numpy() SR = (SR > threshold).astype(np.float) GT = (GT == np.max(GT)).astype(np.float) Inter = np.sum(((SR+GT)==2).astype(np.float)) DC = float(2*Inter)/(float(np.sum(SR)+np.sum(GT)) + 1e-6) return DC
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
@Yffy123456 ok,just give me your Email😊
my @.*** very grateful.
------------------ 原始邮件 ------------------ 发件人: "WAMAWAMA/TNSCUI2020-Seg-Rank1st" @.>; 发送时间: 2022年8月21日(星期天) 中午11:59 收件人: @.>; 抄送: @.**@.>; 主题: Re: [WAMAWAMA/TNSCUI2020-Seg-Rank1st] ask help (Issue #35)
@Yffy123456ok,just give me your Email😊
— Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you were mentioned.Message ID: @.***>
@Yffy123456 please give your email in CODE format like abc123@gmail.com
, otherwise GitHub will mask it.
I would like to ask the author, when running step2to4_train_validate.py, the train [Validation] Acc: 0.9534, SE: 0.0000, SP: 0.0000, PC: 0.0000, Dice: 0.0000, IOU: 0.0000 Why do I get these results is 0?