- Linux | macOS | Windows
- Python 3.6+
- PyTorch 1.6+
- CUDA 9.2+ (If you build PyTorch from source, CUDA 9.0 is also compatible)
- GCC 5+
- MMCV
- MMEngine
- MMDetection
The compatible MMTracking, MMEngine, MMCV, and MMDetection versions are as below. Please install the correct version to avoid installation issues.
MMTracking version | MMEngine version | MMCV version | MMDetection version |
---|---|---|---|
1.x | mmengine>=0.1.0 | mmcv>=2.0.0rc1,<2.0.0 | mmdet>=3.0.0rc0,<3.0.0 |
1.0.0rc1 | mmengine>=0.1.0 | mmcv>=2.0.0rc1,<2.0.0 | mmdet>=3.0.0rc0,<3.0.0 |
-
Create a conda virtual environment and activate it.
conda create -n open-mmlab python=3.9 -y conda activate open-mmlab
-
Install PyTorch and torchvision following the official instructions. Here we use PyTorch 1.10.0 and CUDA 11.1. You may also switch to other version by specifying the version number.
Install with conda
conda install pytorch=1.11.0 torchvision cudatoolkit=11.3 -c pytorch
Install with pip
pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 --extra-index-url https://download.pytorch.org/whl/cu113
-
Install MMEngine
pip install mmengine
-
Install mmcv, we recommend you to install the pre-build package as below.
pip install 'mmcv>=2.0.0rc1' -f https://download.openmmlab.com/mmcv/dist/{cu_version}/{torch_version}/index.html
mmcv is only compiled on PyTorch 1.x.0 because the compatibility usually holds between 1.x.0 and 1.x.1. If your PyTorch version is 1.x.1, you can install mmcv compiled with PyTorch 1.x.0 and it usually works well.
# We can ignore the micro version of PyTorch pip install 'mmcv>=2.0.0rc1' -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.11.0/index.html
See here for different versions of MMCV compatible to different PyTorch and CUDA versions. Optionally you can choose to compile mmcv from source by the following command
git clone -b 2.x https://github.com/open-mmlab/mmcv.git cd mmcv MMCV_WITH_OPS=1 pip install -e . # package mmcv, which contains cuda ops, will be installed after this step # pip install -e . # package mmcv, which contains no cuda ops, will be installed after this step cd ..
Important: You need to run pip uninstall mmcv-lite first if you have mmcv installed. Because if mmcv-lite and mmcv are both installed, there will be ModuleNotFoundError.
-
Install MMDetection
pip install 'mmdet>=3.0.0rc0'
Optionally, you can also build MMDetection from source in case you want to modify the code:
git clone -b 3.x https://github.com/open-mmlab/mmdetection.git cd mmdetection pip install -r requirements/build.txt pip install -v -e . # or "python setup.py develop"
-
Clone the MMTracking repository.
git clone -b 1.x https://github.com/open-mmlab/mmtracking.git cd mmtracking
-
Install build requirements and then install MMTracking.
pip install -r requirements/build.txt pip install -v -e . # or "python setup.py develop"
-
Install extra dependencies
-
For MOT evaluation (required):
pip install git+https://github.com/JonathonLuiten/TrackEval.git
-
For VOT evaluation (optional)
pip install git+https://github.com/votchallenge/toolkit.git
-
For LVIS evaluation (optional):
pip install git+https://github.com/lvis-dataset/lvis-api.git
-
For TAO evaluation (optional):
pip install git+https://github.com/TAO-Dataset/tao.git
Note:
a. Following the above instructions, MMTracking is installed on dev
mode
, any local modifications made to the code will take effect without the need to reinstall it.
b. If you would like to use opencv-python-headless
instead of opencv-python
,
you can install it before installing MMCV.
Assuming that you already have CUDA 10.1 installed, here is a full script for setting up MMTracking with conda.
conda create -n open-mmlab python=3.9 -y
conda activate open-mmlab
conda install pytorch=1.11.0 torchvision cudatoolkit=11.3 -c pytorch
pip install mmengine
# install the latest mmcv
pip install 'mmcv>=2.0.0rc1' -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.11.0/index.html
# install mmdetection
pip install 'mmdet>=3.0.0rc0'
# install mmtracking
git clone -b 1.x https://github.com/open-mmlab/mmtracking.git
cd mmtracking
pip install -r requirements/build.txt
pip install -v -e .
pip install git+https://github.com/JonathonLuiten/TrackEval.git
pip install git+https://github.com/votchallenge/toolkit.git (optional)
pip install git+https://github.com/lvis-dataset/lvis-api.git (optional)
pip install git+https://github.com/TAO-Dataset/tao.git (optional)
The train and test scripts already modify the PYTHONPATH
to ensure the script use the MMTracking in the current directory.
To use the default MMTracking installed in the environment rather than that you are working with, you can remove the following line in those scripts
PYTHONPATH="$(dirname $0)/..":$PYTHONPATH
To verify whether MMTracking and the required environment are installed correctly, we can run one of MOT, VIS, VID and SOT demo scripts:
Here is an example for MOT demo:
python demo/demo_mot_vis.py \
configs/mot/deepsort/deepsort_faster-rcnn-r50-fpn_8xb2-4e_mot17halftrain_test-mot17halfval.py \
--input demo/demo.mp4 \
--output mot.mp4
If you want to run more other demos, you can refer to inference guides