Run Length Encoding/Decoding utility
See original GitHub issueDescribe the feature
Run-Length-Encoding or RLE is one of the encoded annotation formats mostly for the segmentation task. It would be nice to have a utility function to encode and decode segmentation mask to and from RLE.
(To whom it may concern: What is RLE - Issue) (To whom it may concern: How it works)
How API will change?
import keras_cv.utils.rle_encode
import keras_cv.utils.rle_decode
Reference Implementation
Here are few
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
RLE Compression (Run-Length Encoding)
Tool for encoding / decoding with Run-Length Encoding (RLE), a very basic data compression algorithm that consists in describing a string according to...
Read more >Run Length Encoding and Decoding
Run Length Encoding and Decoding · Pick the first character from the source string. · Append the picked character to the destination string....
Read more >Run-length encoding
Run -length encoding ... Given a string containing uppercase characters (A-Z), compress repeated 'runs' of the same character by storing the length ...
Read more >Python: Decode a run-length encoded given list
Run -length encoding (RLE) is a form of lossless data compression in which runs of data (sequences in which the same data value...
Read more >Run-Length Encode and Decode - John Shen - Medium
RLE is run-length encoding. It is used to encode the location of foreground objects in segmentation. Instead of outputting a mask image, you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I might be wrong, but I think RLE is industry-standard. Basing this on multiple Kaggle competitions.
I would say RLE is ideal for storing the mask since it requires less memory. But for training quickly Seg masks are better suited. Thus format conversion utilities will come in handy. Nevertheless, we should support seg maps and polygons before RLEs.
Thanks for sharing this @innat.
To quickly summarise, the RLE format contains a start position and a run length. E.g. ‘1 3’ implies starting at pixel 1 and running a total of 3 pixels (1,2,3).
Usually, RLE encoding has a string dtype with a space delimiter between the start position and run length. Thus RLE ‘1 3 10 5’ implies pixels 1,2,3,10,11,12,13,14 are to be included in the mask. Also, note that usually, the encoding starts from the top-left corner of the image.
Something that I have seen in few Kaggle competitions - given an image with 5 classes to segment, there are 5 rles per class like [rle1, rle2, rle3,…]. There can be overlap that complicate things a bit but I think we should start with encoding for 2D masks.