This function takes the prediction and label of a single image, returns pixel-wise accuracy To compute over many images do: for i = range(Nimages): (pixel_accuracy[i], pixel_correct[i], pixel_labeled[i]) = \ pixelAccuracy(imPred[i], imLab[i]) mean_pixel_accuracy
(imPred, imLab)
| 112 | |
| 113 | |
| 114 | def pixelAccuracy(imPred, imLab): |
| 115 | """ |
| 116 | This function takes the prediction and label of a single image, returns pixel-wise accuracy |
| 117 | To compute over many images do: |
| 118 | for i = range(Nimages): |
| 119 | (pixel_accuracy[i], pixel_correct[i], pixel_labeled[i]) = \ |
| 120 | pixelAccuracy(imPred[i], imLab[i]) |
| 121 | mean_pixel_accuracy = 1.0 * np.sum(pixel_correct) / (np.spacing(1) + np.sum(pixel_labeled)) |
| 122 | """ |
| 123 | # Remove classes from unlabeled pixels in gt image. |
| 124 | # We should not penalize detections in unlabeled portions of the image. |
| 125 | pixel_labeled = np.sum(imLab >= 0) |
| 126 | pixel_correct = np.sum((imPred == imLab) * (imLab >= 0)) |
| 127 | pixel_accuracy = 1.0 * pixel_correct / pixel_labeled |
| 128 | return (pixel_accuracy, pixel_correct, pixel_labeled) |
| 129 | |
| 130 | |
| 131 | def intersectionAndUnion(imPred, imLab, numClass): |
nothing calls this directly
no outgoing calls
no test coverage detected