Environment Setup

We will use Miniconda to manage libraries and facilitate environment setup.

Download Miniconda

Run conda --version in the terminal to check if your machine have conda. If not, go to Miniconda, and choose the installer appropriate for your machine.

For example, click 'Miniconda3 Linux 32-bit' under the Linux installers tab. This will download a shell script named "Miniconda3-latest-Linux-x86.sh". Then you can run sh Miniconda3-latest-Linux-x86.sh to install miniconda.

Setup environment

First copy and save the environment.yml file

environment.yml

name: MaskTrackRCNN
channels:
  - pytorch
  - conda-forge
  - defaults
dependencies:
  - _libgcc_mutex=0.1=main
  - blas=1.0=mkl
  - brotlipy=0.7.0=py37h8f50634_1000
  - bzip2=1.0.8=h516909a_2
  - ca-certificates=2020.6.24=0
  - cairo=1.14.12=he6fea26_5
  - certifi=2020.6.20=py37_0
  - cffi=1.14.0=py37he30daa8_1
  - chardet=3.0.4=py37hc8dfbb8_1006
  - conda=4.8.3=py37hc8dfbb8_1
  - conda-package-handling=1.6.0=py37h8f50634_2
  - cryptography=2.9.2=py37hb09aad4_0
  - cuda92=1.0=0
  - cudatoolkit-dev=9.2=py37_1
  - cython=0.29.20=py37he6710b0_0
  - ffmpeg=4.0.2=ha0c5888_2
  - fontconfig=2.13.1=he4413a7_1000
  - freeglut=3.0.0=hf484d3e_1005
  - freetype=2.10.2=h5ab3b9f_0
  - gettext=0.19.8.1=h5e8e0c9_1
  - glib=2.55.0=0
  - gmp=6.1.2=hf484d3e_1000
  - gnutls=3.5.19=h2a4e5f8_1
  - graphite2=1.3.13=he1b5a44_1001
  - harfbuzz=1.9.0=h08d66d9_0
  - hdf5=1.10.2=hc401514_3
  - icu=58.2=hf484d3e_1000
  - idna=2.10=pyh9f0ad1d_0
  - intel-openmp=2019.4=243
  - jasper=2.0.14=h07fcdf6_1
  - jpeg=9b=h024ee3a_2
  - ld_impl_linux-64=2.33.1=h53a641e_7
  - libedit=3.1.20191231=h7b6447c_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=9.1.0=hdf63c60_0
  - libgfortran=3.0.0=1
  - libgfortran-ng=7.3.0=hdf63c60_0
  - libglu=9.0.0=he1b5a44_1001
  - libiconv=1.15=h516909a_1006
  - libopencv=3.4.2=hb342d67_1
  - libpng=1.6.37=hbc83047_0
  - libstdcxx-ng=9.1.0=hdf63c60_0
  - libtiff=4.1.0=h2733197_1
  - libuuid=2.32.1=h14c3975_1000
  - libxcb=1.13=h14c3975_1002
  - libxml2=2.9.9=h13577e0_2
  - lz4-c=1.9.2=he6710b0_0
  - mkl=2019.4=243
  - mkl-service=2.3.0=py37he904b0f_0
  - mkl_fft=1.1.0=py37h23d657b_0
  - mkl_random=1.0.4=py37hd81dba3_0
  - ncurses=6.2=he6710b0_1
  - nettle=3.3=0
  - ninja=1.9.0=py37hfd86e86_0
  - numpy-base=1.17.0=py37hde5b4d6_0
  - olefile=0.46=py37_0
  - opencv=3.4.2=py37h6fd60c2_1
  - openh264=1.8.0=hdbcaa40_1000
  - openssl=1.1.1g=h7b6447c_0
  - pcre=8.44=he1b5a44_0
  - pillow=7.1.2=py37hb39fc2d_0
  - pip=20.1.1=py37_1
  - pixman=0.34.0=h14c3975_1003
  - pthread-stubs=0.4=h14c3975_1001
  - py-opencv=3.4.2=py37hb342d67_1
  - pycosat=0.6.3=py37h8f50634_1004
  - pycparser=2.20=py_0
  - pyopenssl=19.1.0=py_1
  - pysocks=1.7.1=py37hc8dfbb8_1
  - python=3.7.7=hcff3b4d_5
  - python_abi=3.7=1_cp37m
  - pytorch=0.4.1=py37_cuda9.2.148_cudnn7.1.4_1
  - readline=8.0=h7b6447c_0
  - requests=2.24.0=pyh9f0ad1d_0
  - ruamel_yaml=0.15.80=py37h8f50634_1001
  - setuptools=47.3.1=py37_0
  - six=1.15.0=py_0
  - sqlite=3.32.3=h62c20be_0
  - tk=8.6.10=hbc83047_0
  - torchvision=0.2.1=py_2
  - tqdm=4.47.0=pyh9f0ad1d_0
  - urllib3=1.25.9=py_0
  - wheel=0.34.2=py37_0
  - x264=1!152.20180806=h14c3975_0
  - xorg-fixesproto=5.0=h14c3975_1002
  - xorg-inputproto=2.3.2=h14c3975_1002
  - xorg-kbproto=1.0.7=h14c3975_1002
  - xorg-libice=1.0.10=h516909a_0
  - xorg-libsm=1.2.3=h84519dc_1000
  - xorg-libx11=1.6.9=h516909a_0
  - xorg-libxau=1.0.9=h14c3975_0
  - xorg-libxdmcp=1.1.3=h516909a_0
  - xorg-libxext=1.3.4=h516909a_0
  - xorg-libxfixes=5.0.3=h516909a_1004
  - xorg-libxi=1.7.10=h516909a_0
  - xorg-libxrender=0.9.10=h516909a_1002
  - xorg-renderproto=0.11.1=h14c3975_1002
  - xorg-xextproto=7.3.0=h14c3975_1002
  - xorg-xproto=7.0.31=h14c3975_1007
  - xz=5.2.5=h7b6447c_0
  - yaml=0.2.5=h516909a_0
  - zlib=1.2.11=h7b6447c_3
  - zstd=1.4.4=h0b5b093_3
  - pip:
    - addict==2.2.1
    - cycler==0.10.0
    - kiwisolver==1.2.0
    - matplotlib==3.2.2
    - mmcv==0.2.0
    - numpy==1.17.0
    - opencv-python==4.3.0.36
    - pyparsing==2.4.7
    - python-dateutil==2.8.1
    - pyyaml==5.3.1
    - terminaltables==3.1.0
    - yapf==0.30.0

then run the following commands

conda env create -f environment.yml -y
conda activate MaskTrackRCNN
pip install git+https://github.com/youtubevos/cocoapi.git#"egg=pycocotools&subdirectory=PythonAPI"

This will setup a conda enviroment named "MaskTrackRCNN". You can enter this environment using conda activate MaskTrackRCNN, and exit it using conda deactivate.

Now enter the MaskTrackRCNN environment, and install one extra library

pip install mmcv==0.2.0

Then find the python library path through python. In this case the python_lib_path is "/home/liz220/miniconda2/lib/python2.7"

$ python
Python 2.7.18 |Anaconda, Inc.| (default, Apr 23 2020, 22:42:48) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> for p in sys.path:
...     print(p)
... 
/home/liz220/miniconda2/lib/python2.7/site-packages

Open the file [python_lib_path]/site-packages/mmcv/runner/checkpoint.py

Then update the mmcv's code in line 39. Change the RaiseError to a print statement.

  print('While copying the parameter named {}, '
        'whose dimensions in the model are {} and '
        'whose dimensions in the checkpoint are {}.'
        .format(name, own_state[name].size(),
                param.size()))

Compile Code

Download the MaskTrackRCNN code and cd to that folder. For the first time, you need to run the commands below. Don't forget to also activate the MaskTrackRCNN environment.

bash compile.sh
pip install .

This will compile the code in subforder mmdet and install them to python library path.

IMPORTANT: Every time after you make change to the files inside the mmdet folder, you need to run pip install -v -e . to compile it again.