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的预训练数据集上训练的。

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 9
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值