ubuntu16.04 DaSiamRPN--OTB results

conda create -n siamrpn python=2.7
source activate siamrpn
conda install pytorch=0.4.1 torchvision=0.2.1 cuda92 -c pytorch
pip install opencv-python

git clone https://github.com/foolwood/DaSiamRPN.git
cd DaSiamRPN/code/data
sh get_otb_data.sh

cd DaSiamRPN/code/

wget http://www.robots.ox.ac.uk/~qwang/SiamRPNBIG.model
wget http://www.robots.ox.ac.uk/~qwang/SiamRPNOTB.model
wget http://www.robots.ox.ac.uk/~qwang/SiamRPNVOT.model

python demo.py
python  test_otb.py
python eval_otb.py OTB2015 "Siam*" 0 1

可以直接输入图片或视频进行检测:

1)代码里面images.txt,region.txt替换成初始化窗口就可以了,输出是一个和images同行数的output.txt。

images.txt每一行是一张图片的绝对路径

region.txt:只需要一行坐标即可,可以是多个点组成的多边形也可以是矩形框的左上角和右下角

demo

# --------------------------------------------------------
# DaSiamRPN
# Licensed under The MIT License
# Written by Qiang Wang (wangqiang2015 at ia.ac.cn)
# --------------------------------------------------------
#!/usr/bin/python

import glob, cv2, torch
import numpy as np
from os.path import realpath, dirname, join

from net import SiamRPNvot
from run_SiamRPN import SiamRPN_init, SiamRPN_track
from utils import get_axis_aligned_bbox, cxy_wh_2_rect

# load net
net = SiamRPNvot()
net.load_state_dict(torch.load(join(realpath(dirname(__file__)), 'SiamRPNVOT.model')))
net.eval().cuda()

# image and init box
image_files = sorted(glob.glob('./bag/*.jpg'))
init_rbox = [334.02,128.36,438.19,188.78,396.39,260.83,292.23,200.41]
[cx, cy, w, h] = get_axis_aligned_bbox(init_rbox)

# tracker init
target_pos, target_sz = np.array([cx, cy]), np.array([w, h])
im = cv2.imread(image_files[0])  # HxWxC
state = SiamRPN_init(im, target_pos, target_sz, net)

# tracking and visualization
toc = 0
for f, image_file in enumerate(image_files):
    im = cv2.imread(image_file)
    tic = cv2.getTickCount()
    state = SiamRPN_track(state, im)  # track
    toc += cv2.getTickCount()-tic
    res = cxy_wh_2_rect(state['target_pos'], state['target_sz'])
    res = [int(l) for l in res]
    cv2.rectangle(im, (res[0], res[1]), (res[0] + res[2], res[1] + res[3]), (0, 255, 255), 3)
    cv2.imshow('SiamRPN', im)
    cv2.waitKey(1)

print('Tracking Speed {:.1f}fps'.format((len(image_files)-1)/(toc/cv2.getTickFrequency())))

In the demo init_rbox = [334.02,128.36,438.19,188.78,396.39,260.83,292.23,200.41]

Four points to locate a box: top left(x,y), top right(x,y), bottom left(x,y), bottom right(x,y).

DaSiamRPN非常容易集成到任意项目中。

labels包含两个部分

一个部分是boundingbox,这个boundingbox是相对于crop来resize的。
另一个是分类,crop的boundingbox和anchor box 的IOU大于0.6的为正样本, IOU小于0.3的为负样本。

wangqiang1ban

大多数Siamese Trackers将跟踪制定为一次性学习问题,但是当遇到长期和严重的照明变化时,更新在线战略是必要的。

训练模型:

python train_siamrpn.py --dataroot=/home/***/projects/firefox-downloads/Siamese-RPN-pytorch-master/vot2013 --lr=0.001 --checkpoint_path=/home/***/projects/firefox-downloads/Siamese-RPN-pytorch-master/pretrainedModel/weights-0690000.pth.tar

 

DaSiamRPN 并不是从头开始训练的,也是在imagenet的预训练数据集上训练的。

你可能感兴趣的:(ubuntu16.04 DaSiamRPN--OTB results)