Skip to content

Commit

Permalink
Add filename pattern to cli (#5525)
Browse files Browse the repository at this point in the history
Add ability to create task with `filename_pattern` by cli.
  • Loading branch information
Marishka17 authored Dec 31, 2022
1 parent f0311a9 commit c91cf8a
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## \[2.4.0] - Unreleased
### Added
- Filename pattern to simplify uploading cloud storage data for a task (<https://github.com/opencv/cvat/pull/5498>)
- Filename pattern to simplify uploading cloud storage data for a task (<https://github.com/opencv/cvat/pull/5498>, <https://github.com/opencv/cvat/pull/5525>)
- \[SDK\] Configuration setting to change the dataset cache directory
(<https://github.com/opencv/cvat/pull/5535>)
- \[SDK\] Class to represent a project as a PyTorch dataset
Expand Down
74 changes: 59 additions & 15 deletions cvat-cli/src/cvat_cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import json
import logging
import os
import textwrap
from distutils.util import strtobool

from cvat_sdk.core.proxies.tasks import ResourceType
Expand Down Expand Up @@ -90,10 +91,15 @@ def make_cmdline_parser() -> argparse.ArgumentParser:
#######################################################################
task_create_parser = task_subparser.add_parser(
"create",
description="""Create a new CVAT task. To create a task, you need
to specify labels using the --labels argument or
attach the task to an existing project using the
--project_id argument.""",
description=textwrap.dedent(
"""\
Create a new CVAT task. To create a task, you need
to specify labels using the --labels argument or
attach the task to an existing project using the
--project_id argument.
"""
),
formatter_class=argparse.RawTextHelpFormatter,
)
task_create_parser.add_argument("name", type=str, help="name of the task")
task_create_parser.add_argument(
Expand Down Expand Up @@ -124,38 +130,56 @@ def make_cmdline_parser() -> argparse.ArgumentParser:
dest="status_check_period",
default=2,
type=float,
help="""number of seconds to wait until checking
if data compression finished (necessary before uploading annotations)""",
help=textwrap.dedent(
"""\
number of seconds to wait until checking
if data compression finished (necessary before uploading annotations)
"""
),
)
task_create_parser.add_argument(
"--copy_data",
default=False,
action="store_true",
help="""set the option to copy the data, only used when resource type is
share (default: %(default)s)""",
help=textwrap.dedent(
"""\
set the option to copy the data, only used when resource type is
share (default: %(default)s)
"""
),
)
task_create_parser.add_argument(
"--dataset_repository_url",
default="",
type=str,
help=(
"git repository to store annotations e.g."
" https://github.com/user/repos [annotation/<anno_file_name.zip>]"
help=textwrap.dedent(
"""\
git repository to store annotations e.g.
https://github.com/user/repos [annotation/<anno_file_name.zip>]
"""
),
)
task_create_parser.add_argument(
"--frame_step",
default=None,
type=int,
help="""set the frame step option in the advanced configuration
when uploading image series or videos (default: %(default)s)""",
help=textwrap.dedent(
"""\
set the frame step option in the advanced configuration
when uploading image series or videos (default: %(default)s)
"""
),
)
task_create_parser.add_argument(
"--image_quality",
default=70,
type=int,
help="""set the image quality option in the advanced configuration
when creating tasks.(default: %(default)s)""",
help=textwrap.dedent(
"""\
set the image quality option in the advanced configuration
when creating tasks.(default: %(default)s)
"""
),
)
task_create_parser.add_argument(
"--labels",
Expand Down Expand Up @@ -201,6 +225,26 @@ def make_cmdline_parser() -> argparse.ArgumentParser:
action="store_true", # automatically sets default=False
help="""zip chunks before sending them to the server""",
)
task_create_parser.add_argument(
"--cloud_storage_id",
default=None,
type=int,
help="cloud storage ID if you would like to use data from cloud storage",
)
task_create_parser.add_argument(
"--filename_pattern",
type=str,
help=textwrap.dedent(
"""\
pattern for filtering data from the manifest file for the upload.
Only shell-style wildcards are supported:
* - matches everything
? - matches any single character
[seq] - matches any character in 'seq'
[!seq] - matches any character not in seq
"""
),
)

#######################################################################
# Delete
Expand Down
2 changes: 2 additions & 0 deletions cvat-sdk/cvat_sdk/core/proxies/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def upload_data(
"stop_frame",
"use_cache",
"use_zip_chunks",
"filename_pattern",
"cloud_storage_id",
],
)
)
Expand Down
12 changes: 12 additions & 0 deletions site/content/en/docs/api_sdk/cli/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ by using the [label constructor](/docs/manual/basics/creating_an_annotation_task
--dataset_repository_url https://github.com/user/dataset/blob/main/annotation/anno_file_name.zip \
--lfs share //share/large_dataset/images/
```
- Create a task named "task with filtered cloud storage data", with filename_pattern `test_images/*.jpeg`
and using the data from the cloud storage resource described in the manifest.jsonl:
```bash
cvat-cli create "task with filtered cloud storage data" --labels '[{"name": "car"}]'\
--use_cache --cloud_storage_id 1 --filename_pattern "test_images/*.jpeg" share manifest.jsonl
```
- Create a task named "task with filtered cloud storage data" using all data from the cloud storage resource
described in the manifest.jsonl by specifying filename_pattern `*`:
```bash
cvat-cli create "task with filtered cloud storage data" --labels '[{"name": "car"}]'\
--use_cache --cloud_storage_id 1 --filename_pattern "*" share manifest.jsonl
```

### Delete

Expand Down

0 comments on commit c91cf8a

Please sign in to comment.