This document contains detailed instructions for installing the necessary dependencies for PyTracking on Windows. The instructions have been tested on a Windows 10 system with Visual Studio 2015. Notice that Windows installation is much more complex. Installation on Linux (Ubuntu) is highly recommended.
- Conda 64 installation with Python 3.7. If not already installed, install from https://www.anaconda.com/distribution/.
- Nvidia GPU.
- Visual Studio 2015 or newer.
- Pre install CUDA 10.0 (not necessarily v10) with VS support.
conda create --name pytracking python=3.7
conda activate pytracking
Install PyTorch with cuda10.
conda install pytorch torchvision cudatoolkit=10.0 -c pytorch
Note:
- It is possible to use any PyTorch supported version of CUDA (not necessarily v10), but better be the same version with your preinstalled CUDA (if you have one)
- For more details about PyTorch installation, see https://pytorch.org/get-started/previous-versions/.
conda install matplotlib pandas
pip install opencv-python visdom tb-nightly
If you want to use COCO dataset for training, install the coco python toolkit. You additionally need to install cython to compile the coco toolkit.
conda install cython
pip install pycocotools
This is thecomplicated part. There are two options:
DiMP and ATOM trackers need Precise ROI pooling module (https://github.com/vacancy/PreciseRoIPooling). You can download the pre-build binary file (build on Windows 10) and install it. Or you could build your own package by following Build Precise ROI pooling with Visual Studio (Optional).
-
The package is built with VS2015, so in some cases (such as you don't have VS2015) you will need to install Visual C++ Redistributable for Visual Studio 2015 from Microsoft.
-
Add
Anaconda3\envs\pytracking\Lib\site-packages\torch\lib
to users path (Right click this PC --> Properties --> Advanced System settings --> Environment Variables --> User variables --> Path). -
Copy the
prroi_pool.pyd
file to the conda environment python path (such asAnaconda3\envs\pytracking\Lib\site-packages\
). This will take action after restart the shell. -
Add this code to
pytracking\ltr\external\PreciseRoIPooling\pytorch\prroi_pool\functional.py
:... def _import_prroi_pooling(): global _prroi_pooling #load the prroi_pool module import imp file, path, description = imp.find_module('prroi_pool') with file: _prroi_pooling = imp.load_module('prroi_pool', file, path, description) ...
which should then look like:
import torch import torch.autograd as ag __all__ = ['prroi_pool2d'] _prroi_pooling = None def _import_prroi_pooling(): global _prroi_pooling #load the prroi_pool module import imp file, path, description = imp.find_module('prroi_pool') with file: _prroi_pooling = imp.load_module('prroi_pool', file, path, description) if _prroi_pooling is None: try: from os.path import join as pjoin, dirname from torch.utils.cpp_extension import load as load_extension root_dir = pjoin(dirname(__file__), 'src') _prroi_pooling = load_extension( '_prroi_pooling', [pjoin(root_dir, 'prroi_pooling_gpu.cpp'), pjoin(root_dir, 'prroi_pooling_gpu_impl.cu')], verbose=True ) except ImportError: raise ImportError('Can not compile Precise RoI Pooling library.') return _prroi_pooling ...
-
If the pre-build package don't work on your platform, you can build your own package as described in the next section.
To compile the Precise ROI pooling module (https://github.com/vacancy/PreciseRoIPooling) on Windows, you need Visual Studio with CUDA installed.
-
First make a DLL project by the following step.
- Download the Precise ROI pooling module with
git clone https://github.com/vacancy/PreciseRoIPooling
. - Download pybind11
git clone https://github.com/pybind/pybind11
- Open Visual Studio and start a new C++
Empty project
. - Add
PreciseRoIPooling\src\prroi_pooling_gpu_impl.cu
andPreciseRoIPooling\pytorch\prroi_pool\src\prroi_pooling_gpu.c
to theSource File
and change the nameprroi_pooling_gpu.c
toprroi_pooling_gpu.cpp
. - Add
PreciseRoIPooling\src\prroi_pooling_gpu_impl.cuh
andPreciseRoIPooling\pytorch\prroi_pool\src\prroi_pooling_gpu.h
to theHeader File
. - Right click the project --> Property. Change Configuration to
Release
andx64
. Then Configuration Properties --> General --> change Configuration Type to.dll
and Target Extension to.pyd
.
- Download the Precise ROI pooling module with
-
Set the VC++ Directories.
-
Find the following dirs and add them to VC++ Directories --> Include Directories.
Anaconda3\envs\pytracking\Lib\site-packages\torch\include\torch\csrc\api\include Anaconda3\envs\pytracking\Lib\site-packages\torch\include\THC Anaconda3\envs\pytracking\Lib\site-packages\torch\include\TH Anaconda3\envs\pytracking\Lib\site-packages\torch\include Anaconda3\envs\pytracking\include CUDA\v10.0\include pybind11\pybind11\include
-
Find the following dirs and add them to VC++ Directories --> Lib Directories.
Anaconda3\envs\pytracking\Lib\site-packages\torch\lib Anaconda3\envs\pytracking\libs
-
-
Set the Linker.
-
Find and add them to Linker --> General -->Additional Library Directories.
CUDA\v10.0\lib\x64 Anaconda3\envs\pytracking\libs Anaconda3\envs\pytracking\Lib\site-packages\torch\lib
-
Add them to Linker --> Input -->Additional Dependencies
python37.lib python3.lib cudart.lib c10.lib torch.lib torch_python.lib _C.lib c10_cuda.lib
-
-
Set the CUDA dependence.
- Right click the project --> Build dependencies --> Build Customizations --> click CUDA
- Right click the
*.cu
and*.cuh
files --> Property. And change the type fromC/C++
toCUDA C/C++
-
Set the package name and build.
Change
prroi_pooling_gpu.cpp
file inline 109
from
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
to
PYBIND11_MODULE(prroi_pool, m) {
then build the package with
Release
andx64
. You will get a*.pyd
file. Rename it asprroi_pool.pyd
. -
Last but not least, follow the step in Install pre-build Precise ROI pooling package.
In case of issues, we refer to https://github.com/vacancy/PreciseRoIPooling.
In order to use jpeg4py for loading the images instead of OpenCV's imread(), install jpeg4py in the following way,
pip install jpeg4py
In case of issues, we refer to https://github.com/ajkxyz/jpeg4py.
Create the default environment setting files.
# Environment settings for pytracking. Saved at pytracking/evaluation/local.py
python -c "from pytracking.evaluation.environment import create_default_local_file; create_default_local_file()"
# Environment settings for ltr. Saved at ltr/admin/local.py
python -c "from ltr.admin.environment import create_default_local_file; create_default_local_file()"
You can modify these files to set the paths to datasets, results paths etc.
You can download the pre-trained networks from the google drive folder. The networks shoud be saved in the directory set by "network_path" in "pytracking/evaluation/local.py". By default, it is set to pytracking/networks. You should download them manually and copy to the correct directory.
# directory of the default network for DiMP-50 and DiMP-18
pytracking/networks/dimp50.pth
pytracking/networks/dimp18.pth
# directory of the default network for ATOM
pytracking/networks/atom_default.pth
# directory of the default network for ECO
pytracking/networks/resnet18_vggmconv1.pth