医学病变分割:计算IoU发现结果大于1!(标签-ar|关键词-numpy)

医学病变分割:计算IoU发现结果大于1!以下是计算IoU的函数,请指教!

def iou_score(output, target):
    smooth = 1e-5
 
    if torch.is_tensor(output):
        output = torch.sigmoid(output).data.cpu().numpy()
    if torch.is_tensor(target):
        target = target.data.cpu().numpy()
    output_ = (output > 0.5)
    target_ = (target > 0.5)
    intersection = (output_ * target_).sum()
    total = (output_ + target_).sum()
    union = total - intersection