Skip to content

Commit

Permalink
Release 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Manovich committed Jun 29, 2018
0 parents commit eb9fba3
Show file tree
Hide file tree
Showing 235 changed files with 51,001 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/.git
/share
/data
/media
/.env
/.vscode
/db.sqlite3
/keys
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Project Specific
/data/
/share/
/static/
/db.sqlite3
/.env
/keys
/logs

# Ignore temporary files
docker-compose.override.yml
/.vscode
__pycache__
*.pyc
._*
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# How to contribute to Computer Vision Annotation Tool (CVAT)

When contributing to this repository, please first discuss the change you wish to make via issue,
email, or any other method with the owners of this repository before making a change.
99 changes: 99 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
FROM ubuntu:16.04

ARG http_proxy
ARG https_proxy
ARG no_proxy

ENV TERM=xterm \
http_proxy=${http_proxy} \
https_proxy=${https_proxy} \
no_proxy=${no_proxy}

ENV LANG='C.UTF-8' \
LC_ALL='C.UTF-8'

ARG USER
ARG TF_ANNOTATION
ENV TF_ANNOTATION=${TF_ANNOTATION}
ARG DJANGO_CONFIGURATION
ENV DJANGO_CONFIGURATION=${DJANGO_CONFIGURATION}

# Install necessary apt packages
RUN apt-get update && \
apt-get install -yq \
python-software-properties \
software-properties-common \
wget && \
add-apt-repository ppa:mc3man/xerus-media -y && \
add-apt-repository ppa:mc3man/gstffmpeg-keep -y && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq \
apache2 \
apache2-dev \
libapache2-mod-xsendfile \
supervisor \
ffmpeg \
gstreamer0.10-ffmpeg \
libldap2-dev \
libsasl2-dev \
python3-dev \
python3-pip \
unzip \
unrar \
p7zip-full \
vim && \
rm -rf /var/lib/apt/lists/*

# Add a non-root user
ENV USER=${USER}
ENV HOME /home/${USER}
WORKDIR ${HOME}
RUN adduser --shell /bin/bash --disabled-password --gecos "" ${USER}

# Install tf annotation if need
COPY cvat/apps/tf_annotation/docker_setup_tf_annotation.sh /tmp/tf_annotation/
COPY cvat/apps/tf_annotation/requirements.txt /tmp/tf_annotation/
ENV TF_ANNOTATION_MODEL_PATH=${HOME}/rcnn/frozen_inference_graph.pb

RUN if [ "$TF_ANNOTATION" = "yes" ]; then \
/tmp/tf_annotation/docker_setup_tf_annotation.sh; \
fi

ARG WITH_TESTS
RUN if [ "$WITH_TESTS" = "yes" ]; then \
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list && \
wget -qO- https://deb.nodesource.com/setup_9.x | bash - && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq \
google-chrome-stable \
nodejs && \
rm -rf /var/lib/apt/lists/*; \
mkdir tests && cd tests && npm install \
eslint \
eslint-detailed-reporter \
karma \
karma-chrome-launcher \
karma-coverage \
karma-junit-reporter \
karma-qunit \
qunit; \
echo "export PATH=~/tests/node_modules/.bin:${PATH}" >> ~/.bashrc; \
fi

# Install and initialize CVAT, copy all necessary files
COPY cvat/requirements/ /tmp/requirements/
COPY supervisord.conf mod_wsgi.conf wait-for-it.sh manage.py ${HOME}/
RUN pip3 install --no-cache-dir -r /tmp/requirements/${DJANGO_CONFIGURATION}.txt
COPY cvat/ ${HOME}/cvat
COPY tests ${HOME}/tests
RUN chown -R ${USER}:${USER} .

# RUN all commands below as 'django' user
USER ${USER}

RUN mkdir data share media keys logs /tmp/supervisord
RUN python3 manage.py collectstatic

EXPOSE 8080 8443
ENTRYPOINT ["/usr/bin/supervisord"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 annotation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
106 changes: 106 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Computer Vision Annotation Tool (CVAT)

CVAT is completely re-designed and re-implemented version of [Video Annotation Tool from Irvine, California](http://carlvondrick.com/vatic/) tool. It is free, online, interactive video and image annotation tool for computer vision. It is being used by our team to annotate million of objects with different properties. Many UI and UX decisions are based on feedbacks from professional data annotation team.

## LICENSE

Code released under the [MIT License](https://opensource.org/licenses/MIT).

## INSTALLATION

These instructions below should work for Ubuntu 16.04. Probably it will work on other OSes as well with minor modifications.

### Install [Docker CE](https://www.docker.com/community-edition) or [Docker EE](https://www.docker.com/enterprise-edition) from official site

Please read official manual [here](https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/).

### Install the latest driver for your graphics card

The step is necessary only to run tf_annotation app. If you don't have a Nvidia GPU you can skip the step.

```bash
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-cache search nvidia-* # find latest nvidia driver
sudo apt-get install nvidia-* # install the nvidia driver
sudo apt-get install mesa-common-dev
sudo apt-get install freeglut3-dev
sudo apt-get install nvidia-modprobe
```

Reboot your PC and verify installation by `nvidia-smi` command.

### Install [Nvidia-Docker](https://github.com/NVIDIA/nvidia-docker)

The step is necessary only to run tf_annotation app. If you don't have a Nvidia GPU you can skip the step. See detailed installation instructions on repository page.

### Install docker-compose (1.19.0 or newer)

```bash
sudo pip install docker-compose
```

### Build docker images

To build all necessary docker images run `docker-compose build` command. By default, in production mode the tool uses PostgreSQL as database, Redis for caching.

### Run containers without tf_annotation app

To start all containers run `docker-compose up -d` command. Go to [localhost:8080](http://localhost:8080/). You should see a login page.

### Run containers with tf_annotation app

If you would like to enable tf_annotation app first of all be sure that nvidia-driver, nvidia-docker and docker-compose>=1.19.0 are installed properly (see instructions above) and `docker info | grep 'Runtimes'` output contains `nvidia`.

Run following command:
```bash
docker-compose -f docker-compose.yml -f docker-compose.nvidia.yml up -d --build
```

### Create superuser account

You can [register a user](http://localhost:8080/auth/register) but by default it will not have rights even to view list of tasks. Thus you should create a superuser. The superuser can use admin panel to assign correct groups to the user. Please use the command below:

```bash
docker exec -it cvat sh -c '/usr/bin/python3 ~/manage.py createsuperuser'
```

Type your login/password for the superuser [on the login page](http://localhost:8080/auth/login) and press **Login** button. Now you should be able to create a new annotation task. Please read documentation for more details.

### Stop all containers

The command below will stop and remove containers, networks, volumes, and images
created by `up`.

```bash
docker-compose down
```

### Advanced settings

If you want to access you instance of CVAT outside of your localhost you should specify [ALLOWED_HOSTS](https://docs.djangoproject.com/en/2.0/ref/settings/#allowed-hosts) environment variable. The best way to do that is to create [docker-compose.override.yml](https://docs.docker.com/compose/extends/) and put all your extra settings here.

```yml
version: "2.3"

services:
cvat:
environment:
ALLOWED_HOSTS: .example.com
ports:
- "80:8080"
```
### Annotation logs
It is possible to proxy annotation logs from client to another server over http. For examlpe you can use Logstash.
To do that set DJANGO_LOG_SERVER_URL environment variable in cvat section of docker-compose.yml
file (or add this variable to docker-compose.override.yml).
```yml
version: "2.3"

services:
cvat:
environment:
DJANGO_LOG_SERVER_URL: https://annotation.example.com:5000
```
Empty file added cvat/__init__.py
Empty file.
1 change: 1 addition & 0 deletions cvat/apps/authentication/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default_app_config = 'cvat.apps.authentication.apps.AuthenticationConfig'
3 changes: 3 additions & 0 deletions cvat/apps/authentication/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
18 changes: 18 additions & 0 deletions cvat/apps/authentication/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from django.apps import AppConfig
from django.db.models.signals import post_migrate, post_save
from .settings.authentication import DJANGO_AUTH_TYPE

class AuthenticationConfig(AppConfig):
name = 'cvat.apps.authentication'

def ready(self):
from . import signals
from django.contrib.auth.models import User

post_migrate.connect(signals.create_groups)

if DJANGO_AUTH_TYPE == 'SIMPLE':
post_save.connect(signals.create_user, sender=User, dispatch_uid="create_user")

import django_auth_ldap.backend
django_auth_ldap.backend.populate_user.connect(signals.update_ldap_groups)
32 changes: 32 additions & 0 deletions cvat/apps/authentication/decorators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.shortcuts import resolve_url, reverse
from django.http import JsonResponse
from urllib.parse import urlparse
from django.contrib.auth.views import redirect_to_login

from functools import wraps
from django.conf import settings

def login_required(function=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url=None, redirect_methods=['GET']):
def decorator(view_func):
@wraps(view_func)
def _wrapped_view(request, *args, **kwargs):
if request.user.is_authenticated:
return view_func(request, *args, **kwargs)
else:
if request.method not in redirect_methods:
return JsonResponse({'login_page_url': reverse('login')}, status=403)

path = request.build_absolute_uri()
resolved_login_url = resolve_url(login_url or settings.LOGIN_URL)
# If the login url is the same scheme and net location then just
# use the path as the "next" url.
login_scheme, login_netloc = urlparse(resolved_login_url)[:2]
current_scheme, current_netloc = urlparse(path)[:2]
if ((not login_scheme or login_scheme == current_scheme) and
(not login_netloc or login_netloc == current_netloc)):
path = request.get_full_path()

return redirect_to_login(path, resolved_login_url, redirect_field_name)
return _wrapped_view
return decorator(function) if function else decorator
55 changes: 55 additions & 0 deletions cvat/apps/authentication/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from django.contrib.auth.forms import (
UsernameField,
AuthenticationForm,
UserCreationForm,
)
from django.utils.translation import gettext, gettext_lazy as _
from django.contrib.auth.models import User

from django import forms

class AuthForm(AuthenticationForm):
username = UsernameField(
widget=forms.TextInput(attrs={'autofocus': True, 'placeholder': "Username"}),
)
password = forms.CharField(
label=_("Password"),
strip=False,
widget=forms.PasswordInput(attrs={'placeholder': "Password"}),
)

class NewUserForm(UserCreationForm):
username = UsernameField(
widget=forms.TextInput(attrs={'autofocus': True, 'placeholder': "Username (required)"}),
required=True,
)

first_name = UsernameField(
widget=forms.TextInput(attrs={'placeholder': "First name"}),
required=False,
)

last_name = UsernameField(
widget=forms.TextInput(attrs={'placeholder': "Last name"}),
required=False,
)

email = forms.EmailField(
widget=forms.EmailInput(attrs={'placeholder': "Email (required)"}),
required=True,
)

password1 = forms.CharField(
label=_("Password"),
strip=False,
widget=forms.PasswordInput(attrs={'placeholder': "Password (required)"}),
)
password2 = forms.CharField(
label=_("Password confirmation"),
widget=forms.PasswordInput(attrs={'placeholder': "Password confirmation (required)"}),
strip=False,
)

class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email', )
Empty file.
3 changes: 3 additions & 0 deletions cvat/apps/authentication/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
Empty file.
Loading

0 comments on commit eb9fba3

Please sign in to comment.