Confusion matrix of UNET image sgemenation model
If your masks have only one channel and in the case of binary segmentation, you can easily compute a confusion matrix from one image thanks to:

TP: ground truth and predicted pixel are of class 1 (object)
TN: ground truth and predicted pixel are of class 0 (background)
FP: ground truth pixel=0 while predicted pixel=1
FN: ground truth pixel=1 while predicted pixel=0

On a dataset, you can get the confusion matrix from chosen iou thresholds.
For example if your iou threshold is 0.5:

TP += 1 for each image where iou(ground_truth, predicted) &gt;= 0.5
FP += 1 for each image where iou(ground_truth, predicted) &lt; 0.5 and predicted != empty
FN += 1 for each image where iou(ground_truth, predicted) &lt; 0.5 and gt != empty

It is just a suggestion, there is maybe better ways to deal with that.