Filter OOB points while training
Description
This PR converts all out-of-boundary and negative points to nans while generating the dataset and while computing the crop size to avoid errors while training.
Types of changes
- [ ] Bugfix
- [ ] New feature
- [ ] Refactor / Code style update (no logical changes)
- [ ] Build / CI changes
- [ ] Documentation Update
- [ ] Other (explain)
Does this address any currently open issues?
#1901
Outside contributors checklist
- [ ] Review the guidelines for contributing to this repository
- [ ] Read and sign the CLA and add yourself to the authors list
- [ ] Make sure you are making a pull request against the develop branch (not main). Also you should start your branch off develop
- [ ] Add tests that prove your fix is effective or that your feature works
- [ ] Add necessary documentation (if appropriate)
Thank you for contributing to SLEAP!
:heart:
Summary by CodeRabbit
Summary by CodeRabbit
-
New Features
- Enhanced dataset creation by filtering out-of-bounds points, ensuring only valid instance coordinates are included.
- Improved cropping functionality with robust calculations for crop size based on valid instance points.
- New utility function to handle out-of-bounds points in datasets.
-
Bug Fixes
- Adjusted expected output in model predictions for better accuracy.
-
Documentation
- Minor formatting updates in the configuration file for documentation settings.
-
Tests
- Added new tests to validate filtering of out-of-bounds points and crop size calculations.
- Introduced tests for model training with out-of-bounds points.
Walkthrough
The pull request introduces a minor formatting adjustment in the Sphinx documentation configuration file docs/conf.py, along with significant enhancements to the LabelsReader class in sleap/nn/data/providers.py. The modifications in the data providers file focus on improving data integrity by implementing a filtering mechanism for instance coordinates, removing out-of-bounds points and ensuring only valid data is processed. Additionally, new tests have been added to validate the filtering functionality and the cropping size calculations.
Changes
| File | Change Summary |
|---|---|
docs/conf.py |
Minor formatting change from single to double quotes for html_css_files path |
sleap/nn/data/providers.py |
- Added import for Instance from sleap.instance - Enhanced make_dataset method to filter out-of-bounds points - Replaced invalid coordinates with NaN - Removed instances with NaN coordinates |
tests/nn/data/test_providers.py |
Added test_labels_filter_oob_points to verify filtering of OOB points in LabelsReader |
sleap/nn/data/instance_cropping.py |
- Updated find_instance_crop_size to handle image dimensions and validate points - Adjusted transform_dataset in InstanceCropper and PredictedInstanceCropper for new cropping logic |
tests/nn/test_inference.py |
Modified assertion in test_topdown_model for expected output of n_valid key |
tests/nn/data/test_instance_cropping.py |
Added test_find_instance_crop_size to validate crop size calculations based on instance points |
tests/nn/test_training.py |
Added test_train_topdown_with_oob_pts to evaluate training with out-of-bounds points |
sleap/nn/data/utils.py |
Added new function filter_oob_points to filter out-of-bounds points |
Poem
🐰 In the realm of data's wild terrain,
Where pixels dance and numbers reign,
Our rabbit filters with keen delight,
Casting out points that just aren't right!
Clean data hops, no bounds too tight! 🌟
[!TIP] CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command
@coderabbitai generate docstringsto have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.
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?
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
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)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR. (Beta)@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Codecov Report
:x: Patch coverage is 44.73684% with 21 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 76.11%. Comparing base (7ed1229) to head (768ca90).
:warning: Report is 161 commits behind head on develop.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| sleap/nn/data/providers.py | 9.09% | 20 Missing :warning: |
| sleap/nn/data/instance_cropping.py | 90.00% | 1 Missing :warning: |
:x: Your patch status has failed because the patch coverage (44.73%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.
Additional details and impacted files
@@ Coverage Diff @@
## develop #2061 +/- ##
===========================================
+ Coverage 73.30% 76.11% +2.80%
===========================================
Files 134 134
Lines 24087 24786 +699
===========================================
+ Hits 17658 18865 +1207
+ Misses 6429 5921 -508
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Looks good! Code rabbits suggestions of parameterizing could be implemented.
Sure, added those in the latest commit!