Install and Use Vatic Annotation Tool

A. How to install Vatic in one line code

Vatic is a very convinient online annotation tool for labeling objects of videos. The vatic annotation tool enables users to easily annotate video files, where bounding boxes are automatically interpolated in both size and position. Annotation is performed in a web browser, and annotations are stored in a MySQL database. For this, videos need to be locally published using command line interfacing. Extracting the annotation is also performed using the command line interface.

The installation requires a lot of configurations, and it is super painful. The installation steps are shown in Vatic . Instead of installing it step by step manually and encountering lots of bugs, we can easily use other people’s docker environment and run it by VM.

1. Install docker

Step1: undate inner core:

sudo apt-get install -y --install-recommends linux-generic-lts-trusty

Step2: Use scripts to install the docker

curl -sSL https://get.docker.com/ | sh

2. Install and use Vatic

reference: vatic-docker

Step1: Create “data” folder in the directory where you want to run.

Step2: Create “labels.txt” file in data folder. Put all the object types that you want to label on the first line separated by spaces.

Step3: Create “videos_in” folder in data folder, and put in the video you want to label.

Step4: Run the vatic in docker:

sudo docker run -it -p 8111:80 -v $PWD/data:/root/vatic/data npsvisionlab/vatic-docker /bin/bash -C /root/vatic/example.sh

8111 is the port. We can change it when needed.

Step5: Annotation

Open the browser, type:

<Your IP address>:8111/directory

(Show ip address: ifconfig)

Label the objects in the video, go back to /directory whenever you finish the annotations and click output labels button. Find the output file in the root directory.

Docker Commands

  1. Show all containers:

    sudo docker ps -a        
    
  2. Kill the running container:

    sudo docker kill <Container id>
    
  3. Remove the container:

    sudo docker rm <Container id>
    

B. Another installation method

The previous method is quite easy and all set-up commands are wrapped in one line code. However, what if you want to do some modifications? For example, you want to modify the length of each segment for the video. Have a look of the Original Vatic Code , you can see that we can modify it by using the --length option while publishing the video.

We can’t use those options in the first installation method. So, here is another method, which is a step-by-step installation for vatic in docker.

Reference

1. Install Docker (the same as method #1)

Create one folder named “data” in your current location. Put the video inside, and create another folder named “frames” inside the folder “data”.

Then, save the address as a value “DATA_DIR”.

DATA_DIR=`pwd`/data/
mkdir -p $DATA_DIR

3. Start the Vatic server

docker run -it -p 8080:80 -v $DATA_DIR:/home/vagrant/vagrant_data jldowns/vatic-docker-contrib:0.1

4. Start the MySQL and Apache

/home/vagrant/start_services.sh

5. Extract the frames from video

cd /home/vagrant/vatic
turkic extract /home/vagrant/vagrant_data/your_video_name.mp4 /home/vagrant/vagrant_data/frames/

Here, we can use different options to extract the frames, such as modify the ratio by adding --width 1000 --height 800 at the end of above code. More options, see Vatic.

6. Load and Publish

turkic load job_id /home/vagrant/vagrant_data/frames/ car skateboard airplane --offline

Here, car skateboard airplane are different labels.

And in order to modify the length of each segment for the video as we mentioned at the begin. We can use --length option. Just like,

turkic load job_id /home/vagrant/vagrant_data/frames/ pedestrain sedan truck van bicycle --offline --length 4000

More options, Vatic.

7. Check all the URLS

turkic publish --offline

or open the browser and type in

 http://localhost:8080/?id=1&hitId=offline
http://localhost:8080/?id=2&hitId=offline
http://localhost:8080/?id=3&hitId=offline
...

If does not work, try:

http://<your_IP_address>:8080/?id=1&hitId=offline

8. Save the annotation

turkic dump job_id -o /home/vagrant/vagrant_data/annotations.txt

The command can also output to many different formats. Available formats are:

--xml       Use XML
--json      Use JSON
--matlab    Use MATLAB
--pickle    Use Python's Pickle
--labelme   Use LabelMe video's XML format
--pascal    Use PASCAL VOC format, treating each frame as an image

9. Re-open the vatic

If you close the terminal or kill the job accidentally, you definitely need the following tutorial (I suffered a lot from closing something accidentally..).

Step 1: Check the docker job id

docker ps -a

Step 2: Restart the job

docker start <Container id>

Step 3: Go back to the docker folder

docker attach <Container id>

Step 4: Change to the vatic folder

cd /home/vagrant/vatic

Step 5: Restart MySQL and Apache

/home/vagrant/start_services.sh

Step 6: Use the same url you worked before! Done!