-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Add option to SDK allowing upload of annotation as masks instead of polygon. #8823
base: develop
Are you sure you want to change the base?
Add option to SDK allowing upload of annotation as masks instead of polygon. #8823
Conversation
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughA new optional parameter, Changes
Poem
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
CodeRabbit Configuration File (
|
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: 2
🧹 Outside diff range and nitpick comments (1)
cvat-sdk/cvat_sdk/core/proxies/projects.py (1)
Line range hint
115-131
: Pass theconv_mask_to_poly
parameter toimport_dataset
.The parameter is added to the method signature but not passed through to the
import_dataset
call.Apply this diff to fix the issue:
project.import_dataset( format_name=dataset_format, filename=dataset_path, pbar=pbar, status_check_period=status_check_period, + conv_mask_to_poly=conv_mask_to_poly, )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
changelog.d/20241212_185016_knotekjaroslav_add_mask_poly_conv_param.md
(1 hunks)cvat-sdk/cvat_sdk/core/proxies/projects.py
(3 hunks)cvat-sdk/cvat_sdk/core/uploading.py
(1 hunks)
🔇 Additional comments (1)
cvat-sdk/cvat_sdk/core/proxies/projects.py (1)
67-67
:
Fix indentation and parameter usage.
The conv_mask_to_poly
parameter is incorrectly indented and defined as a parameter but not passed in the method call.
Apply this diff to fix the issues:
- conv_mask_to_poly: Optional[bool] = None,
pbar=pbar,
status_check_period=status_check_period,
+ conv_mask_to_poly=conv_mask_to_poly,
Likely invalid or redundant comment.
cvat-sdk/cvat_sdk/core/uploading.py
Outdated
if conv_mask_top_poly is not None: | ||
value = "true" if conv_mask_to_poly else "false" | ||
params["conv_mask_to_poly"] = value |
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.
Fix typo in variable name.
There's a typo in the variable name that would cause the feature to fail.
Apply this diff to fix the typo:
- if conv_mask_top_poly is not None:
+ if conv_mask_to_poly is not None:
value = "true" if conv_mask_to_poly else "false"
params["conv_mask_to_poly"] = value
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if conv_mask_top_poly is not None: | |
value = "true" if conv_mask_to_poly else "false" | |
params["conv_mask_to_poly"] = value | |
if conv_mask_to_poly is not None: | |
value = "true" if conv_mask_to_poly else "false" | |
params["conv_mask_to_poly"] = value |
### Added <!-- pick one --> | ||
|
||
- Added parameter `conv_mask_to_poly` to SDK's `project.export_dataset` method to allow conversion upon adding annotations. | ||
(<https://github.com/cvat-ai/cvat/pull/feature/add_mask_poly_conv_param>) |
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.
Update the changelog entry to include all affected methods and fix PR reference.
The changelog entry needs the following improvements:
- Include all affected methods that received the new parameter:
import_dataset
create_from_dataset
upload_file_and_wait
- Fix the PR reference format
Apply this diff to update the changelog:
### Added <!-- pick one -->
-Added parameter `conv_mask_to_poly` to SDK's `project.export_dataset` method to allow conversion upon adding annotations.
-(<https://github.com/cvat-ai/cvat/pull/feature/add_mask_poly_conv_param>)
+Added parameter `conv_mask_to_poly` to the following SDK methods to control mask-to-polygon conversion:
+- `project.export_dataset`
+- `project.import_dataset`
+- `project.create_from_dataset`
+- `DatasetUploader.upload_file_and_wait`
+([#8823](https://github.com/cvat-ai/cvat/pull/8823))
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
### Added <!-- pick one --> | |
- Added parameter `conv_mask_to_poly` to SDK's `project.export_dataset` method to allow conversion upon adding annotations. | |
(<https://github.com/cvat-ai/cvat/pull/feature/add_mask_poly_conv_param>) | |
### Added <!-- pick one --> | |
Added parameter `conv_mask_to_poly` to the following SDK methods to control mask-to-polygon conversion: | |
- `project.export_dataset` | |
- `project.import_dataset` | |
- `project.create_from_dataset` | |
- `DatasetUploader.upload_file_and_wait` | |
([#8823](https://github.com/cvat-ai/cvat/pull/8823)) |
Quality Gate passedIssues Measures |
Hi, could you add at least 1 test for this? |
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.
Probably, it makes sense to support this in jobs and tasks, and in CLI as well.
Motivation and context
I am using SDK to create project with pre-annotations. Having data in Camvid 1.0 format, I create a project and upload annotations using the following code:
After that I noticed that the mask-type annotations are represented as polygons which is the problem I wanted to overcome by implementing
conv_mask_to_poly
parameter tocreate_from_dataset
method aboveThis change corresponds to the UI toggle Convert Masks to Polygons. Which does exactly the same.
How has this been tested?
Given the impact of this change, no extensive tests were done appart of running the code.
Checklist
develop
branch- [ ] I have updated the documentation accordinglyI looked around the code and there were no docsstrings/comments to update- [ ] I have linked related issues (see GitHub docs)(cvat-canvas,
cvat-core,
cvat-data and
cvat-ui)
License
Feel free to contact the maintainers if that's a concern.
Summary by CodeRabbit
New Features
Bug Fixes