Add ExtractedMask and update importers who can use it to use it#1480
Conversation
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1480 +/- ##
===========================================
- Coverage 80.85% 80.84% -0.02%
===========================================
Files 271 273 +2
Lines 30689 31402 +713
Branches 6197 6316 +119
===========================================
+ Hits 24815 25386 +571
- Misses 4489 4592 +103
- Partials 1385 1424 +39
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
| >>> | ||
| >>> index_mask = np.random.randint(low=1, high=3, size=(10, 10), dtype=np.uint8) | ||
| >>> mask1 = ExtractedMask(index_mask=index_mask, index=1, label=1) # | ||
| >>> mask2 = ExtractedMask(index_mask=index_mask, index=2, label=2) # |
There was a problem hiding this comment.
What is the difference between index and label here?
There was a problem hiding this comment.
As described here
https://github.com/openvinotoolkit/datumaro/blob/e2e945e5d25d3e1437c8a42f756eab14bd144d25/src/datumaro/components/annotation.py#L513-L515
index can denote an instance id or a label id. It depends on the dataset. Anyway, I enhanced the example docstring in af03f29 to make it more descriptive.
There was a problem hiding this comment.
I am still confused. The updated example have the same index and label. In my understanding, mask1 is a binary mask with 0 and 1, where all 1s indicate the index indeed. This looks fine. But index might be label for all cases. Is there any case that index is not equal to label?
There was a problem hiding this comment.
mask is a binary mask and its 1s actually indicate label=1 (not index=1) in this example. index is just used to extract a binary mask from index_mask. It is possible that index can be different with label by dataset transformation. For example, if the label remapping transform merges label=1, index=1 (1: apple) and label=2, index=2 (2: orange) to label=3 (3: fruits). Then, apple masks will have index=1, label=3 and orange masks will have index=2, label=3.
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
Summary
ExtractedMaskwhich is a dedicated mask annotation class to use a single index mask source. The index mask is a integer 2D array and its pixel can indicate a label id (class) or instance id.ExtractedMaskand it share the same index mask, 2) Just extract the source index maskIt can save huge computations required for 2D array manipulations: creating a binary mask and merging binary masks.
How to test
Checklist
License
Feel free to contact the maintainers if that's a concern.