1. Environment construction
Create a conda virtual environment and activate it.
conda create -n mmtrack python=3.8 -y
conda activate mmtrack
Follow the official instructions to install PyTorch and torchvision
You can switch to other versions by specifying the version number.
#如果网不好,可以这样安装
pip3 install torch==1.8.2+cu102 torchvision==0.9.2+cu102 torchaudio===0.8.2 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install torch==1.11.0+cu115 torchvision==0.12.0+cu115 torchaudio==0.11.0 -f https://download.pytorch.org/whl/torch_stable.html -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
#验证是否安装成功
>>> import torchvision
>>> import torch
>>> import.__version__
File "<stdin>", line 1
import.__version__
^
SyntaxError: invalid syntax
>>> torch.__version__
'1.8.2+cu102'
Here we use PyTorch 1.10.0 and CUDA 11.1.
install using conda
conda install pytorch=1.11.0 torchvision cudatoolkit=11.3 -c pytorch
install using 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 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
install mmcv
We recommend that you install the prebuilt packages as shown below.
pip install 'mmcv>=2.0.0rc1' -f https://download.openmmlab.com/mmcv/dist/{
cu_version}/{
torch_version}/index.html
pip install 'mmcv>=2.0.0rc1' -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.8.0/index.html -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
mmcv only compiles on PyTorch 1.x.0, since compatibility is usually 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, which 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 with different PyTorch and CUDA versions. Or you can choose to compile mmcv from source by 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: If mmcv is installed, you need to run pip uninstall mmcv-lite first. Because if both mmcv-lite and mmcv are installed, ModuleNotFoundError will appear.
Install MMDetection
pip install 'mmdet>=3.0.0rc0' -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
Alternatively, you can also build MMDetection from source if 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" -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
Clone the MMTracking repository.
git clone -b 1.x https://github.com/open-mmlab/mmtracking.git
cd mmtracking
Install build requirements, then install MMTracking.
pip install -r requirements/build.txt
pip install -v -e . # or "python setup.py develop"
Install additional dependencies
For MOT assessment (required):
pip install git+https://github.com/JonathonLuiten/TrackEval.git
For VOT assessment (optional)
pip install git+https://github.com/votchallenge/toolkit.git
For LVIS assessment (optional):
pip install git+https://github.com/lvis-dataset/lvis-api.git
For TAO assessment (optional):
pip install git+https://github.com/TAO-Dataset/tao.git
notes:
a. According to the above instructions, MMTracking is installed in devmode, and any local changes to the code will take effect without reinstallation.
b. If you want to use opencv-python-headless instead of opencv-python, you can install it before installing MMCV.
Setup script from scratch
Assuming you have CUDA 10.1 installed, here is a complete script to setup MMTracking using 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)
Install library version
(mmtrack) lhy@thales-Super-Server:/media/lhy/mmtracking$ pip list
Package Version Editable project location
---------------------- ----------- -------------------------
addict 2.4.0
albumentations 1.3.0
astroid 2.11.7
asynctest 0.13.0
attributee 0.1.5
attrs 21.4.0
charset-normalizer 2.0.12
click 8.1.3
click-plugins 1.1.1
cligj 0.7.2
codecov 2.1.12
colorama 0.4.5
coverage 6.4.1
cycler 0.11.0
Cython 0.29.30
dotty-dict 1.3.0
Fiona 1.8.22
flake8 4.0.1
flatbuffers 2.0
fonttools 4.33.3
geojson 2.5.0
geopandas 0.12.1
idna 3.3
imagecorruptions 1.1.2
imageio 2.19.3
importlib-metadata 6.8.0
iniconfig 1.1.1
interrogate 1.5.0
isort 4.3.21
joblib 1.3.1
kiwisolver 1.4.3
kwarray 0.6.2
lap 0.4.0
lazy-object-proxy 1.7.1
Markdown 3.4.3
markdown-it-py 3.0.0
matplotlib 3.5.2
mccabe 0.6.1
mdurl 0.1.2
mmcls 1.0.0rc6
mmcv 2.0.0rc4
mmdet 3.0.0rc2
mmengine 0.7.1
mmtrack 1.0.0rc1 /media/lhy/mmtracking
model-index 0.1.11
modelindex 0.0.2
motmetrics 1.2.5
mpmath 1.2.1
munch 2.5.0
networkx 2.8.4
numpy 1.22.4
opencv-python 4.8.0.74
opencv-python-headless 4.6.0.66
ordered-set 4.1.0
packaging 23.1
pandas 1.3.5
Pillow 10.0.0
pip 23.1.2
platformdirs 3.8.1
pluggy 1.0.0
pretrainedmodels 0.7.4
py 1.11.0
pycocotools 2.0.2
pycodestyle 2.8.0
pyflakes 2.4.0
Pygments 2.15.1
pylint 2.14.5
pyparsing 3.1.0
pyproj 3.4.0
pyshp 2.3.1
pytest 7.1.2
python-dateutil 2.8.2
pytz 2022.1
PyWavelets 1.3.0
PyYAML 6.0
qudida 0.0.4
requests 2.28.0
rich 13.4.2
scikit-image 0.19.3
scikit-learn 1.3.0
scipy 1.7.3
seaborn 0.11.2
setuptools 65.5.0
setuptools-scm 6.4.2
Shapely 1.7.0
six 1.16.0
sympy 1.10.1
tabulate 0.8.9
termcolor 2.3.0
terminaltables 3.1.10
threadpoolctl 3.1.0
tifffile 2022.5.4
toml 0.10.2
tomli 2.0.1
tomlkit 0.11.1
torch 1.8.2+cu102
torchaudio 0.8.2
torchvision 0.9.2+cu102
tqdm 4.65.0
trackeval 1.0.dev1
typing_extensions 4.7.1
ubelt 1.1.1
urllib3 1.26.9
wheel 0.40.0
wrapt 1.14.1
xdoctest 1.0.0
xmltodict 0.13.0
yapf 0.40.1
zipp 3.16.1
confirm
To verify that MMTracking and the required environment are installed correctly, we can run one of the MOT, VIS, VID and SOT demo scripts:
Here's an example of a 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