-
Notifications
You must be signed in to change notification settings - Fork 590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use CVAT brush tool (aka mask shape) when annotating instance segmentation masks #5319
Conversation
WalkthroughThe pull request enhances the CVAT integration in FiftyOne by introducing a new Changes
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
fiftyone/utils/cvat.py (1)
1590-1614
: Ensure robustness & unit testing for new RLE methodsThe new
HasCVATBinaryMask
class establishes a solid foundation for encoding and decoding RLE instance masks. However, consider these improvements:
- Edge-case handling: Large or malformed RLEs and negative or zero-height/width bounding boxes could pose issues. You might want to clamp or at least warn on out-of-range values.
- Unit tests: Creating round-trip tests (
_mask_to_cvat_rle
→_rle_to_binary_image_mask
→ compare original) will help detect off-by-one or indexing issues.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
fiftyone/utils/cvat.py
(4 hunks)
🔇 Additional comments (3)
fiftyone/utils/cvat.py (3)
5947-5949
: Consistent approach to rectangle shapes
The new condition branches on shape_type == "rectangle"
and correctly maps shapes to "detections"
. This ensures that bounding boxes become detections in FiftyOne. The logic is straightforward, and no immediate issues stand out.
6461-6510
: Consider validating coordinates for mask upload
This code path correctly handles instance segmentation when CVAT ≥ 2.3 by uploading RLE masks, otherwise reverting to polygons. One suggestion:
- Validate bounding boxes (xtl, ytl, xbr, ybr) or clamp them to [0, width-1] / [0, height-1] to avoid out-of-bounds or negative dimensions.
- Performance: For very large masks, reconciling memory usage with RLE might be worth testing.
Overall, the fallback to polygon-based representation for older servers is a good approach.
7160-7190
: Confirm RLE indexing consistency with upload path
The to_instance()
method decodes the last four points as the bounding box and interprets remaining points as RLE. This closely mirrors the upload logic (lines ~6461-6510) but with an opposite +1/-1 offset. Verify these offsets produce the correct mask size, especially near image boundaries.
Additionally, consider gracefully handling cases where xbr <= xtl
or ybr <= ytl
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for taking this over the finish line!
Finalizes #4483
Change log
Tested by
Summary by CodeRabbit
CVATShape
class to support instance masks in the conversion process.