import torch


def get_accuracy(SR, GT, threshold=0.5):
    """
    Get the accuracy between Ground Truth and Segmentation Results

    Args:
        SR: tensor  Segmentation Results
        GT: tensor  Ground Truth
        threshold: the threshold of segmentation

    Returns:
        acc: accuracy between SR and GT
    """
    SR = SR > threshold
    GT = GT > 0
    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