(mask_image)
| 99 | |
| 100 | # credits to https://stackoverflow.com/users/6076729/manuel-lagunas |
| 101 | def rle_encode(mask_image): |
| 102 | pixels = mask_image.flatten() |
| 103 | # We avoid issues with '1' at the start or end (at the corners of |
| 104 | # the original image) by setting those pixels to '0' explicitly. |
| 105 | # We do not expect these to be non-zero for an accurate mask, |
| 106 | # so this should not harm the score. |
| 107 | pixels[0] = 0 |
| 108 | pixels[-1] = 0 |
| 109 | runs = np.where(pixels[1:] != pixels[:-1])[0] + 2 |
| 110 | runs[1::2] = runs[1::2] - runs[:-1:2] |
| 111 | return runs |
| 112 | |
| 113 | |
| 114 | class AverageMeter(object): |
nothing calls this directly
no outgoing calls
no test coverage detected