I am doing a binary segmentation of brain tumors from CT scan images. Following is the code I am using for precision and recall

```
def get_precision(PR,GT,threshold=0.5):
PR = PR > threshold
GT = GT == torch.max(GT)
TP = ((PR==1)&(GT==1))
FP = ((PR==1)&(GT==0))
Precision = float(torch.sum(TP))/(float(torch.sum(TP)+torch.sum(FP)) + 1e-6)
return Precision
```

```
def get_recall(PR,GT,threshold=0.5):
PR = PR > threshold
GT = GT == torch.max(GT)
TP = ((PR==1)&(GT==1))
FN = ((PR==0)&(GT==0))
Recall = float(torch.sum(TP))/(float(torch.sum(TP)+torch.sum(FN)) + 1e-6)
return Recall
```

PR is the predicted probabilities of the model from sigmoid layer and GT is the ground truth images divided by 255.Is this the right implementation of the metrics for binary segmentation as I am getting both values in high 90’s. Also can I follow same approach for calculating mIOU.