@ -2,7 +2,7 @@
title: 'Command line interface (CLI)'
title: 'Command line interface (CLI)'
linkTitle: 'CLI'
linkTitle: 'CLI'
weight: 29
weight: 29
description: 'Guide to working with CVAT tasks in the command line interface. This section on [GitHub ](https://github.com/openvinotoolkit/cvat/tree/develop/ utils/ cli).'
description: 'Guide to working with CVAT tasks in the command line interface. This section on [GitHub ](https://github.com/openvinotoolkit/cvat/tree/develop/ cvat- cli).'
---
---
## Description
## Description
@ -28,15 +28,13 @@ To access the CLI, you need to have python in environment,
as well as a clone of the CVAT repository and the necessary modules:
as well as a clone of the CVAT repository and the necessary modules:
```bash
```bash
git clone https://github.com/openvinotoolkit/cvat.git
pip install 'git+https://github.com/openvinotoolkit/cvat#subdirectory=cvat-cli'
cd cvat/utils/cli
pip install -r requirements.txt
```
```
You will get help with `cli.py `.
You can get help with `cvat-cli --help `.
```
```
usage: cli.py [-h] [--auth USER:[PASS]] [--server-host SERVER_HOST]
usage: cvat-c li [-h] [--auth USER:[PASS]] [--server-host SERVER_HOST]
[--server-port SERVER_PORT] [--debug]
[--server-port SERVER_PORT] [--debug]
{create,delete,ls,frames,dump,upload,export,import} ...
{create,delete,ls,frames,dump,upload,export,import} ...
@ -61,10 +59,10 @@ optional arguments:
You can get help for each positional argument, e.g. `ls` :
You can get help for each positional argument, e.g. `ls` :
```bash
```bash
cli.py ls -h
cvat- cli ls -h
```
```
```
```
usage: cli.py ls [-h] [--json]
usage: cvat-c li ls [-h] [--json]
List all CVAT tasks in simple or JSON format.
List all CVAT tasks in simple or JSON format.
@ -103,25 +101,25 @@ by using the [label constructor](/docs/manual/basics/creating_an_annotation_task
- Create a task named "new task" on the default server "localhost:8080", labels from the file "labels.json"
- Create a task named "new task" on the default server "localhost:8080", labels from the file "labels.json"
and local images "file1.jpg" and "file2.jpg", the task will be created as current user:
and local images "file1.jpg" and "file2.jpg", the task will be created as current user:
```bash
```bash
cli.py create "new task" --labels labels.json local file1.jpg file2.jpg
cvat-c li create "new task" --labels labels.json local file1.jpg file2.jpg
```
```
- Create a task named "task 1" on the server "example.com" labels from the file "labels.json"
- Create a task named "task 1" on the server "example.com" labels from the file "labels.json"
and local image "image1.jpg", the task will be created as user "user-1":
and local image "image1.jpg", the task will be created as user "user-1":
```bash
```bash
cli.py --server-host example.com --auth user-1 create "task 1" \
cvat-c li --server-host example.com --auth user-1 create "task 1" \
--labels labels.json local image1.jpg
--labels labels.json local image1.jpg
```
```
- Create a task named "task 1", labels from the project with id 1 and with a remote video file,
- Create a task named "task 1", labels from the project with id 1 and with a remote video file,
the task will be created as user "user-1":
the task will be created as user "user-1":
```bash
```bash
cli.py --auth user-1:password create "task 1" --project_id 1 \
cvat-c li --auth user-1:password create "task 1" --project_id 1 \
remote https://github.com/opencv/opencv/blob/master/samples/data/vtest.avi?raw=true
remote https://github.com/opencv/opencv/blob/master/samples/data/vtest.avi?raw=true
```
```
- Create a task named "task 1 sort random", with labels "cat" and "dog", with chunk size 8,
- Create a task named "task 1 sort random", with labels "cat" and "dog", with chunk size 8,
with sorting-method random, frame step 10, copy the data on the CVAT server,
with sorting-method random, frame step 10, copy the data on the CVAT server,
with use zip chunks and the video file will be taken from the shared resource:
with use zip chunks and the video file will be taken from the shared resource:
```bash
```bash
cli.py create "task 1 sort random" --labels '[{"name": "cat"},{"name": "dog"}]' --chunk_size 8 \
cvat-c li create "task 1 sort random" --labels '[{"name": "cat"},{"name": "dog"}]' --chunk_size 8 \
--sorting-method random --frame_step 10 --copy_data --use_zip_chunks share //share/dataset_1/video.avi
--sorting-method random --frame_step 10 --copy_data --use_zip_chunks share //share/dataset_1/video.avi
```
```
- Create a task named "task from dataset_1", labels from the file "labels.json", with link to bug tracker,
- Create a task named "task from dataset_1", labels from the file "labels.json", with link to bug tracker,
@ -129,21 +127,21 @@ by using the [label constructor](/docs/manual/basics/creating_an_annotation_task
from the file "annotation.xml", the data will be loaded from "dataset_1/images/",
from the file "annotation.xml", the data will be loaded from "dataset_1/images/",
the task will be created as user "user-2", and the password will need to be entered additionally:
the task will be created as user "user-2", and the password will need to be entered additionally:
```bash
```bash
cli.py --auth user-2 create "task from dataset_1" --labels labels.json \
cvat-c li --auth user-2 create "task from dataset_1" --labels labels.json \
--bug_tracker https://bug-tracker.com/0001 --image_quality 75 --annotation_path annotation.xml \
--bug_tracker https://bug-tracker.com/0001 --image_quality 75 --annotation_path annotation.xml \
--annotation_format "CVAT 1.1" local dataset_1/images/
--annotation_format "CVAT 1.1" local dataset_1/images/
```
```
- Create a task named "segmented task 1", labels from the file "labels.json", with overlay size 5,
- Create a task named "segmented task 1", labels from the file "labels.json", with overlay size 5,
segment size 100, with frames 5 through 705, using cache and with a remote video file:
segment size 100, with frames 5 through 705, using cache and with a remote video file:
```bash
```bash
cli.py create "segmented task 1" --labels labels.json --overlap 5 --segment_size 100 \
cvat-c li create "segmented task 1" --labels labels.json --overlap 5 --segment_size 100 \
--start_frame 5 --stop_frame 705 --use_cache \
--start_frame 5 --stop_frame 705 --use_cache \
remote https://github.com/opencv/opencv/blob/master/samples/data/vtest.avi?raw=true
remote https://github.com/opencv/opencv/blob/master/samples/data/vtest.avi?raw=true
```
```
- Create a task named "task 1 with sync annotation", with label "person",
- Create a task named "task 1 with sync annotation", with label "person",
with annotation storage in `git` repository, enable `lfs` and the image files from the shared resource:
with annotation storage in `git` repository, enable `lfs` and the image files from the shared resource:
```bash
```bash
cli.py create "task 1 with sync annotation" --labels '[{"name": "person"}]' \
cvat-c li create "task 1 with sync annotation" --labels '[{"name": "person"}]' \
--dataset_repository_url https://github.com/user/dataset/blob/main/annotation/anno_file_name.zip \
--dataset_repository_url https://github.com/user/dataset/blob/main/annotation/anno_file_name.zip \
--lfs share //share/large_dataset/images/
--lfs share //share/large_dataset/images/
```
```
@ -152,55 +150,55 @@ by using the [label constructor](/docs/manual/basics/creating_an_annotation_task
- Delete tasks with id "100", "101", "102" , the command will be executed from "user-1" having delete permissions:
- Delete tasks with id "100", "101", "102" , the command will be executed from "user-1" having delete permissions:
```bash
```bash
cli.py --auth user-1:password delete 100 101 102
cvat-c li --auth user-1:password delete 100 101 102
```
```
### List
### List
- List all tasks:
- List all tasks:
```bash
```bash
cli.py ls
cvat-c li ls
```
```
- Save list of all tasks into file "list_of_tasks.json":
- Save list of all tasks into file "list_of_tasks.json":
```bash
```bash
cli.py ls --json > list_of_tasks.json
cvat-c li ls --json > list_of_tasks.json
```
```
### Frames
### Frames
- Save frame 12, 15, 22 from task with id 119, into "images" folder with compressed quality:
- Save frame 12, 15, 22 from task with id 119, into "images" folder with compressed quality:
```bash
```bash
cli.py frames --outdir images --quality compressed 119 12 15 22
cvat-c li frames --outdir images --quality compressed 119 12 15 22
```
```
### Dump annotation
### Dump annotation
- Dump annotation task with id 103, in the format `CVAT for images 1.1` and save to the file "output.zip":
- Dump annotation task with id 103, in the format `CVAT for images 1.1` and save to the file "output.zip":
```bash
```bash
cli.py dump --format "CVAT for images 1.1" 103 output.zip
cvat-c li dump --format "CVAT for images 1.1" 103 output.zip
```
```
- Dump annotation task with id 104, in the format `COCO 1.0` and save to the file "output.zip":
- Dump annotation task with id 104, in the format `COCO 1.0` and save to the file "output.zip":
```bash
```bash
cli.py dump --format "COCO 1.0" 104 output.zip
cvat-c li dump --format "COCO 1.0" 104 output.zip
```
```
### Upload annotation
### Upload annotation
- Upload annotation into task with id 105, in the format `CVAT 1.1` from the file "annotation.xml":
- Upload annotation into task with id 105, in the format `CVAT 1.1` from the file "annotation.xml":
```bash
```bash
cli.py upload --format "CVAT 1.1" 105 annotation.xml
cvat-c li upload --format "CVAT 1.1" 105 annotation.xml
```
```
### Export task
### Export task
- Export task with id 136 to file "task_136.zip":
- Export task with id 136 to file "task_136.zip":
```bash
```bash
cli.py export 136 task_136.zip
cvat-c li export 136 task_136.zip
```
```
### Import
### Import
- Import task from file "task_backup.zip":
- Import task from file "task_backup.zip":
```bash
```bash
cli.py import task_backup.zip
cvat-c li import task_backup.zip
```
```