Skip to content
Advertisement

How to draw the precision-recall curve for a segmentation model?

I am using an U-Net for segmenting my data of interest. The masks are grayscale and of size (256,256,1). There are 80 images in the test set. The test images (X_ts) and their respective ground-truth masks (Y_ts) are constructed, saved, and loaded like this:

JavaScript

The shape of Y_ts (ground truth) is therefore (80,256,256,1) and these are of type “Array of type float32”. I predicted the masks using the trained model like this:

JavaScript

The shape of Y_ts_pred is (80,256,256,1) and these are of type “Array of type float32”. Now, I compute the precision recall curves using the Y_ts (ground truth masks) and Y_ts_pred (predicted masks) like this:

JavaScript

I get the following error:

JavaScript

Advertisement

Answer

I have to convert my ground truth and predicted masks into one-dimensional vectors and binarize them using a threshold value like below. Then, the above code will work.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement