Back to Cvat

CVAT SDK Examples

cvat-sdk/examples/README.md

2.74.03.1 KB
Original Source

CVAT SDK Examples

Complete, copy-and-run examples for the CVAT Python SDK. Each example is a command-line script. Invoke a script with the --help parameter to see all its options. Example:

sh
python tasks_bulk_from_cloud.py --help
python tasks_bulk_from_cloud.py \
    --host 'https://app.cvat.ai' \
    --token '<your token>' \
    --cloud-storage-id 7 --project-id 42 \
    --task 'videos/clip_01.mp4' \
    --task 'videos/clip_02.mp4'

Most of the examples use Personal Access Tokens for user authentication. You'll need to create one to run a script, the instructions are available here.

Conventions:

  • examples that create resources keep them by default. Pass --cleanup to delete them at the end
  • examples that operate with existing server objects take an id as the parameter (e.g. --project-id)
  • list-valued options accept multiple values (e.g. --labels car person)
ExampleWhat it doesParameters
auth_token.pyAuthenticate with a Personal Access Token, get current user
auth_profile.pyAuthenticate from a saved profile--profile (omit for the default profile)
auth_cli.pyBuild a CLI-compatible script via make_client_from_clireuses cvat-cli's flags: --server-host, --auth, --profile, ...
project_create_and_list.pyCreate, list, filter, retrieve, rename a project--name, --labels, --cleanup
project_backup.pyDownload a backup zip of an existing project--project-id, --output
project_restore.pyRestore a project from a backup zip--backup, --cleanup
project_export_dataset.pyExport a project's tasks individually (all, or a --task-id list), locally and to a bucket--project-id, --cloud-storage-id, --export-format, --task-id (optional, space-separated)
task_create_from_cloud.pyCreate a task from bucket object keys--cloud-storage-id, --cloud-keys, --cleanup
tasks_bulk_from_cloud.pyBulk-create tasks in a project, from bucket object keys or wildcard patterns--cloud-storage-id, --project-id, --task (repeat), --task-pattern (repeat), --manifest, --cleanup
task_inspect_and_export.pyInspect a task; export its dataset and event-log analytics--task-id, --export-format
job_list.pyList a task's or project's jobs with stage/state/assignee; optional CSV report--task-id or --project-id, --stage, --state, --csv
job_assign.pyRound-robin assign unassigned jobs; CSV report--task-id, --org or --org-id, --assignees or --search
job_workflow.pyBatch-advance completed jobs to the next stage--from-stage, --task-id
cloud_storage_register.pyAttach an S3-compatible bucket to CVAT--bucket, --access-key, --secret-key, --endpoint-url, --page-size, --cleanup

Every recipe additionally takes --host and --token. Wrap values that contain URL punctuation in single quotes, e.g. --host 'https://app.cvat.ai'.