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 create --name pytracking python=3.7
conda activate pytracking
Install PyTorch with cuda10.(RTX3090 推荐cuda 11.1, 否则会报错)
conda install pytorch torchvision cudatoolkit=10.0 -c pytorch
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 the complicated 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 as Anaconda3\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
...
To compile the Precise ROI pooling module (https://github.com/vacancy/PreciseRoIPooling) on Windows, you need Visual Studio with CUDA installed.
git clone https://github.com/vacancy/PreciseRoIPooling
.
2. Download pybind11
git clone https://github.com/pybind/pybind11
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
Anaconda3\envs\pytracking\Lib\site-packages\torch\lib
Anaconda3\envs\pytracking\libs
CUDA\v10.0\lib\x64 Anaconda3\envs\pytracking\libs
Anaconda3\envs\pytracking\Lib\site-packages\torch\lib Add them to
Linker --> Input -->Additional Dependenciespython37.lib python3.lib cudart.lib c10.lib torch.lib torch_python.lib
_C.lib c10_cuda.lib
Change prroi_pooling_gpu.cpp file in line 109
from
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
to
PYBIND11_MODULE(prroi_pool, m) {
then build the package with Release and x64. You will get a *.pyd file. Rename it as prroi_pool.pyd.
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