deeplake
deeplake copied to clipboard
[DL-720] Polygon support
🚀 🚀 Pull Request
Checklist:
- [ ] My code follows the style guidelines of this project and the Contributing document
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have kept the
coverage-rate
up - [ ] I have performed a self-review of my own code and resolved any problems
- [ ] I have checked to ensure there aren't any other open Pull Requests for the same change
- [ ] I have described and made corresponding changes to the relevant documentation
- [ ] New and existing unit tests pass locally with my changes
Changes
Adds support for polygon htype
Usage
ds.create_tensor("polygons", htype="polygon")
Default dtype is float32
. Other dtypes can be specified:
ds.create_tensor("polygons", htype="polygon", dtype="int32")
- Each sample is a list of polygons. Each polygon is a list of points.
- All points in a sample should have same dimensions. (Can not mix 2D points with 3D points etc).
- Different samples can have different number of polygons.
- And different polygons can have different number of points.
poly1 = [(1, 2), (2, 3), (3, 4)]
poly2 = [(10, 12), (14, 19)]
poly3 = [(33, 32), (54, 67), (67, 43), (56, 98)]
sample = [poly1, poly2, poly3]
ds.polygons.append(sample)
Data Layout
-
Each sample in the chunk has the following format:
[Header][Data]
-
The header looks like this:
[num polygons (uint16)][list of lengths of each polygon (uint16)]
-
The data is simply all the points as a flat buffer.
-
The dtype and number of dimensions can be inferred from tensor meta (
.dtype
and.max_shape[-1]
respectively). This information is NOT stored in chunks. -
Sample compression and chunk compression with lz4 are supported.
-
NOTE: Whole buffer will be empty for empty samples. Even header will not be present.
Codecov Report
:exclamation: No coverage uploaded for pull request base (
deeplake@42d7e6d
). Click here to learn what that means. Patch has no changes to coverable lines.
:exclamation: Current head 65e77b5 differs from pull request most recent head 8186135. Consider uploading reports for the commit 8186135 to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## deeplake #1890 +/- ##
===========================================
Coverage ? 92.59%
===========================================
Files ? 247
Lines ? 26249
Branches ? 0
===========================================
Hits ? 24305
Misses ? 1944
Partials ? 0
Flag | Coverage Δ | |
---|---|---|
unittests | 92.59% <0.00%> (?) |
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Also need to make hub.core.Polygons page visible on docs