Siam R-CNN是一个two-stage的再检测跟踪器;
采用第一帧和历史帧的信息来应对长期跟踪面临的目标遮挡挑战;
挖掘hard examples来对抗相似目标的干扰。
注:本文在windows 10系统上完成配置,tensorflow版本为1.15.0。
1、论文下载地址:
Siam R-CNN: Paul Voigtlaender, Jonathon Luiten, Philip H.S. Torr, Bastian Leibe.
"Siam R-CNN: Visual Tracking by Re-Detection." CVPR (2020). [paper] [code]
2、代码下载地址:
https://github.com/VisualComputingInstitute/SiamR-CNN
3、添加依赖库
1)下载依赖库:
git clone https://github.com/pvoigtlaender/got10k-toolkit.git
git clone https://github.com/tensorpack/tensorpack.git
2)进入tensorpack路径执行如下指令
cd tensorpack
git checkout d24a9230d50b1dea1712a4c2765a11876f1e193c
cd ..
3) 把1)2)下载的got10k-toolkit/got10k、tensorpack/tensorpack和tensorpack/examples文件夹拷贝到工程目录下
4、pip安装依赖库
pip install cython
pip install tensorflow-gpu==1.15
pip install wget shapely msgpack msgpack_numpy tabulate xmltodict pycocotools opencv-python tqdm zmq annoy
5、预训练模型下载
建立train_log/hard_mining3路径,并下载预训练模型到此路径下
mkdir train_log
cd train_log
wget --no-check-certificate -r -nH --cut-dirs=2 --no-parent --reject="index.html*" https://omnomnom.vision.rwth-aachen.de/data/siamrcnn/hard_mining3/
cd ..
预训练模型手动下载地址:
Index of /data/siamrcnn/hard_mining3/
预训练模型百度云下载地址:
链接:https://pan.baidu.com/s/1p08Rnx4SKnkg7D0CX-DzLA
提取码:r11u
附windows10系统下完整版wget安装包。
链接:https://pan.baidu.com/s/1StS9EjLQdCNBiFDk9pOYSQ
提取码:n9t1
然后通过如下指令安装即可:
D:\Softwares\GnuWin32\bin\wget --no-check-certificate -r -nH --cut-dirs=2 --no-parent --reject="index.html*" https://omnomnom.vision.rwth-aachen.de/data/siamrcnn/hard_mining3/
6、评估(以OTB2015为例)
1)在tracking/do_tracking.py中设置数据集路径,
2)运行python tracking/do_tracking.py --main main_otb
跟踪结果文件存放在路径:tracking_data/results/
一些可能的错误:
错误1:
NotImplementedError: Cannot convert a symbolic Tensor (cascade_rcnn_stage1/multilevel_roi_align/roi_level2/roi_align/strided_slice:0) to a numpy array.
解决方法:
打开工程路径下的model_box.py
将:
@under_name_scope()
def roi_align(featuremap, boxes, resolution):
"""
Args:
featuremap: 1xCxHxW
boxes: Nx4 floatbox
resolution: output spatial resolution
Returns:
NxCx res x res
"""
# sample 4 locations per roi bin
ret = crop_and_resize(
featuremap, boxes,
tf.zeros([tf.shape(boxes)[0]], dtype=tf.int32),
resolution * 2)
ret = tf.nn.avg_pool(ret, [1, 1, 2, 2], [1, 1, 2, 2], padding='SAME', data_format='NCHW')
return ret
改为:
@under_name_scope()
def roi_align(featuremap, boxes, resolution):
"""
Args:
featuremap: 1xCxHxW
boxes: Nx4 floatbox
resolution: output spatial resolution
Returns:
NxCx res x res
"""
# sample 4 locations per roi bin
tfshape = tf.shape(boxes)[0]
ret = crop_and_resize(
featuremap, boxes,
tf.zeros(shape=tfshape, dtype=tf.int32),
resolution * 2)
ret = tf.nn.avg_pool(ret, [1, 1, 2, 2], [1, 1, 2, 2], padding='SAME', data_format='NCHW')
return ret
错误2:
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject
解决方法:
pip install --upgrade numpy
错误3:
File "D:\Softwares\Anaconda3\envs\TPDtracker\lib\site-packages\shapely\geos.py", line 154, in <module>
_lgeos = CDLL(os.path.join(sys.prefix, 'Library', 'bin', 'geos_c.dll'))
File "D:\Softwares\Anaconda3\envs\TPDtracker\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] 找不到指定的模块。
解决方法:
一些其他错误: