# CVAT SOP
> [name=JayHsu][time=Thu, May 6, 2021 9:38 AM]

[TOC]
## CVAT Server Install
https://github.com/openvinotoolkit/cvat/blob/develop/cvat/apps/documentation/installation.md
1. 安裝docker, loging docker
```shell=
sudo apt-get update
sudo apt-get --no-install-recommends install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get --no-install-recommends install -y docker-ce docker-ce-cli containerd.io
sudo groupadd docker
sudo usermod -aG docker $USER
sudo apt-get --no-install-recommends install -y python3-pip python3-setuptools
sudo python3 -m pip install setuptools docker-compose
docker login
```
2. clone cvat project & docker image
```shell=
sudo apt-get --no-install-recommends install -y git
#git clone https://github.com/opencv/cvat
git clone https://github.com/openvinotoolkit/cvat.git
cd cvat
docker-compose up -d
```

如果download很慢可以從其他電腦export後import
```shell=
docker save -o {outputname.tar} {imagesname}
docker load -i {imagesname}
```
3. create cvat admin account
```
docker exec -it cvat bash -ic 'python3 ~/manage.py createsuperuser'
```
4. 修改port, mount volumes
```
vi docker-compose.yml
#修改以下內容
ports:
- '9090:80'
```
```shell=
vi docker-compose.override.yml
#copy&paste以下內容
version: '3.3'
services:
cvat_proxy:
environment:
CVAT_HOST: 10.109.6.13
ports:
- '81:81'
cvat:
environment:
CVAT_SHARE_URL: 'Mounted from /mnt/share host directory'
volumes:
- cvat_share:/home/django/share:ro
volumes:
cvat_share:
driver_opts:
type: none
device: /mnt/hdd/share
o: bind
```
5. launch cvat
```
cd cvat
docker-compose up -d
```
## CVAT Client
### 上傳Data
將資料上傳至/mnt/hdd/share
### 建立project
1. create new project
2. 輸入project name, 定義label
3. submit
  
### 建立task
1. create new task
2. 填寫task基本資訊
- 一個task可以是一個要被標注的video (mp4)
- 也可以是一個要被標注的影像資料夾 (jpg)
3. 填寫task進階設定
- Frame step: 每幾個frame標注一張
- Segment size: 把標注資料分成數個job, 設定每個job的影像數量
4. submit後回project頁面可以看到出現新的task
5. 進入task頁面
- 可以看到一段待標注影片被分成數個Job
- 可以將task assign給某個人標注
- 也可以將不同Job assign給不同人標注
- 可以設定Reviewer
  
 
### 開始標注
1. 點選Job進入標注頁面
2. 使用上方的控制列選擇要標注的影像
3. 點選左方的長方形按鈕(第7個)標注bounding box (for object detection model)
4. 選擇要標注物件的Label, 並點選Shape
- Shape按鈕標示標注一張影像
- Track按鈕表示在連續的影像標注同一個物件, 使用方法參考教學連結: [教學連結](https://github.com/openvinotoolkit/cvat/blob/develop/cvat/apps/documentation/user_guide.md#track-mode-basics)

5. 快捷鍵:
```
F Go to the next frame
D Go to the previous frame
V Go forward with a step
C Go backward with a step
N Repeat the latest procedure of drawing with the same parameters
```
## TODO
1. 如何在Server上用command export已標注資料
- https://openvinotoolkit.github.io/cvat/docs/administration/basics/rest_api_guide/
## Issue
1. 在12安裝的時候無法正常前用

2. 404
```shell
docker compose down
export CVAT_HOST=10.109.6.12
docker compose up -d
```