Skip to content
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

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### 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))
3 changes: 3 additions & 0 deletions cvat-sdk/cvat_sdk/core/proxies/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def import_dataset(
format_name: str,
filename: StrPath,
*,
conv_mask_to_poly: Optional[bool] = None,
status_check_period: Optional[int] = None,
pbar: Optional[ProgressReporter] = None,
):
Expand All @@ -63,6 +64,7 @@ def import_dataset(
filename,
format_name,
url_params={"id": self.id},
conv_mask_to_poly=conv_mask_to_poly,
pbar=pbar,
status_check_period=status_check_period,
)
Expand Down Expand Up @@ -110,6 +112,7 @@ def create_from_dataset(
dataset_format: str = "CVAT XML 1.1",
status_check_period: int = None,
pbar: Optional[ProgressReporter] = None,
conv_mask_to_poly: Optional[bool] = None,
) -> Project:
"""
Create a new project with the given name and labels JSON and
Expand Down
6 changes: 6 additions & 0 deletions cvat-sdk/cvat_sdk/core/uploading.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,17 @@ def upload_file_and_wait(
format_name: str,
*,
url_params: Optional[dict[str, Any]] = None,
conv_mask_to_poly: Optional[bool] = None,
pbar: Optional[ProgressReporter] = None,
status_check_period: Optional[int] = None,
):
url = self._client.api_map.make_endpoint_url(upload_endpoint.path, kwsub=url_params)
params = {"format": format_name, "filename": filename.name}

if conv_mask_to_poly is not None:
value = "true" if conv_mask_to_poly else "false"
params["conv_mask_to_poly"] = value

response = self.upload_file(
url, filename, pbar=pbar, query_params=params, meta={"filename": params["filename"]}
)
Expand Down