HTTPS SSH

VITALabAI project

Welcome to the PUBLIC git repo of the Videos & Images Theory and Analytics Laboratory (VITAL) of Sherbrooke University, headed by Professor Pierre-Marc Jodoin.

This repository is to keep a record of students projects, especially after they left the lab.

Each model created by a member of the lab is located inside the model directory with its own directory name like model/PedDetectCNN, model/DAC, and model/GTVideoCNN. The dataset directory contains the code required to load the data of any dataset used in our lab. The utils directory contains code that may be used by several models.

Everyone has to comply to both of these interfaces:

  • VITALabAiAbstract.py
  • VITALabAiDatasetAbstract.py

How to install it

Prerequisites

Before installing the VITAlab library, make sure python3 (3.4 and up) is properly installed

sudo apt-get update
sudo apt-get install python3

WARNING: before you start installing python packages, you need to setup a virtual environment. If you are not familiar with virtual environments, please visit this page. Also, this readme is for Linux users, sorry for Windows and Apple advocates!

virtualenv -p python3 ~/.YOUR_ENV_NAME
source ~/.YOUR_ENV_NAME/bin/activate

Make sure you have the latest version of pip

pip install --upgrade pip

and then install all the required python packages

pip install numpy scipy cython matplotlib scikit-learn scikit-image nibabel tensorflow-gpu pyyaml h5py pandas pygame tqdm keras

Then install cuda. For this, you need to download the cuda file from https://developer.nvidia.com/cuda-downloads. For Ubuntu, its a file which looks like cuda_LATEST_VERSION_NUMBER_linux.run. Once downloaded, do the following in a terminal :

sudo sh cuda_LATEST_VERSION_NUMBER_linux.run
follow the command-line instructions  

In order to take 100% advantage of your GPU, you might want to install cudnn. To do so, you first need to register here :

https://developer.nvidia.com/cudnn

and download the cudnn tgz file (something like cudnn-VERSION_NUMBER-linux-x64-v4.0-prod.tgz). Unzip the file and copy cudnn.h in /usr/local/cuda-VERSION_NUMBER/include (VERSION_NUMBER is typically something like 8.0 or more) and the library files in the lib64 directory in /usr/local/cuda-VERSION_NUMBER/lib64.

Now, to update your library path, add the following two lines to your .profile file in your home directory:

export CPATH=/usr/local/cuda/include:$CPATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

then run:

sudo ldconfig

and reboot your computer. Once your computer has been rebooted, you should be able to successfully import tensorflow and keras in ipython3

import tensorflow as tf
import keras as k

Installation of the VITALab library

The installation of our library is straightforward. Open a terminal and do:

cd PATH_TO_YOUR_DEVELOPMENT_VITALAB_PROJECT
git clone https://bitbucket.org/vitalab/vitalabai_public.git
cd vitalabai_public
python setup.py develop

These commands will clone the repository, and link this directory inside your python environment. The "develop" parameter implies that every change inside the repository will be available inside the python environment.

Test installation

Now that the package is installed, let's test it. Let's create a python file test.py or open a python3 or ipython3 command line and copy this.

from VITALabAI.VITALabAiAbstract import VITALabAiAbstract

This should work.

How to execute some code

Now that the VITALab package is installed and works, you can try each project independently.

Let's take for example the CNN model designed to classify the images of the CIFAR10 dataset model/cifar10/cifar10cnn.py:

class Cifar10Cnn(VITALabAiAbstract):
    def __init__(self, **kwargs):
        print(kwargs)

    # ... redefine all the interface functions needed ...

To test this model you can just execute main.py (located in the folder [...]/vitalabai_public/VITALabAI/) as follows :

python3 main.py model.cifar10.cifar10cnn.Cifar10Cnn -o batch_size=25, nb_epoch=300

As you see all the option parameters are given straight to the kwargs so you can give whatever you want to your class directly with the option argument.

YOU ARE NOW READY TO GO, ENJOY!