SiameseFC: Luca Bertinetto, Jack Valmadre, Jo?o F. Henriques, Andrea Vedaldi, Philip H.S. Torr. "Fully-Convolutional Siamese Networks for Object Tracking." ECCV workshop (2016).
吳毅老師的【OTB benchmark】瑟慈,只能在windows下運行持钉,mac和linux無緣咯斗埂。
我已經(jīng)盡我所能寫的盡量詳細了殉簸。
相關(guān)下載
將孿生網(wǎng)絡(luò)用于跟蹤顽耳,2016年發(fā)表在ECCV上的文章隙姿。
項目主頁在這里涩拙。論文下載在這里飘蚯。
GitHub源碼下載
OTB benchmark下載鏈接,所需要的測試序列也從這個網(wǎng)站上下載艳吠。
下載算法源碼
- 從Github上將整個算法克隆下來麦备,按照github上這部分對源碼進行修改。安裝需要的環(huán)境昭娩。
Tracking only
注意到需要的環(huán)境了嘛A莞荨!栏渺!
- GPU
- CUDA drivers
- cuDNN
- Matlab
- MatCovNet(v1.0-beta20)
要注意版本匹配的問題: - 通過在matlab中輸入gpuDevice()的輸出呛梆,可以了解自己GPU的情況,下載對應(yīng)的cuda版本磕诊。
- cuda版本對應(yīng)了matlab版本:
我的配置是matlab R2016a + Visual Studio 2013 + cuda7.5 + cuDnn v5.1.這個版本是完全對應(yīng)正確的填物,可以工作。
cuda-matlab版本對應(yīng)
matlab官方文件也指出可以使用更新版本的cuda霎终,需要自己配置滞磺。
-
將下載好的源碼文件夾改名為SiamFC,放到【benchmark v_1.0】-->【trackers】
SiamFC放置位置 -
下載matconvnet v_1.0-beta20后莱褒,解壓為matconvnet放到SiamFC击困,下載的模型【2016-8-17.net.mat】放到【SiamFC】-->【net
s】下。
模型位置
MATLAB編譯
matlab中輸入命令順序在下面:
>>> cd SiamFC
>>> adddpath matlab
>>> mex -setup C++
>>> vl_compilenn('enableGpu',true)
matlab里面會有這樣的顯示:
我在運行第四步命令之后出現(xiàn)下面的警告:
不過沒有關(guān)系保礼,編譯繼續(xù)沛励,而且最后還會成功的!只要版本對了炮障。我的GPU很弱目派,GEFORCE 710M 筆記本。所以得用低版本的cuda胁赢。
運行SiamFC需要做的修改
一企蹭、 按照github上作者的要求改之后,再做下面的修改。
將【SiamFC】-->【tracking】下的run_tracker.m文件復(fù)制到【SiamFC】下谅摄,并重命名為SiamFC.m徒河。
修改后SiamFC.m中的內(nèi)容:
function results = run_SiamFC(seq, res_path, bSaveImage)
% RUN_TRACKER is the external function of the tracker - does initialization and calls tracker.m
addpath(genpath('./tracking/'));
startup;
%% Parameters that should have no effect on the result.
params.video = seq.path;
params.visualization = false;
params.gpus = 1;
%% Parameters that should be recorded.
% params.foo = 'blah';
if bSaveImage
imwrite(frame2im(getframe(gcf)),[res_path num2str(frame) '.jpg']);
end
%% Call the main tracking function
bboxes = tracker(params);
seq.res = bboxes;
results.res = bboxes;
result.type = 'rect';
end
上面文件的文件最后四行是為了讓benchmark找到tracker的結(jié)果。
第二個修改文件送漠,tracking文件夾下的tracker.m的第55行
[imgFiles, targetPosition, targetSize] = load_video_info( p.video);
第三個需要修改的文件:load_video_info.m
% -------------------------------------------------------------------------------------------------
function [imgs, pos, target_sz] = load_video_info(video_path)
%LOAD_VOT_VIDEO_INFO
% Loads all the relevant information for the video in the given path:
% the list of image files (cell array of strings), initial position
% (1x2), target size (1x2), the ground truth information for precision
% calculations (Nx4, for N frames), and the path where the images are
% located. The ordering of coordinates and sizes is always [y, x].
%
% Joao F. Henriques, 2014
% http://www.isr.uc.pt/~henriques/
% -------------------------------------------------------------------------------------------------
%full path to the video's files
% panchen
% if base_path(end) ~= '/' && base_path(end) ~= '\',
% base_path(end+1) = '/';
% end
% video_path = [base_path video];
%load ground truth from text file
ground_truth = csvread([video_path 'groundtruth_rect.txt']);
region = ground_truth(1, :);
[cx, cy, w, h] = get_axis_aligned_BB(region);
pos = [cy cx]; % centre of the bounding box
target_sz = [h w];
%load all jpg files in the folder
img_files = dir([video_path '*.jpg']);
assert(~isempty(img_files), 'No image files to load.')
img_files = sort({img_files.name});
%eliminate frame 0 if it exists, since frames should only start at 1
img_files(strcmp('00000000.jpg', img_files)) = [];
img_files = strcat(video_path, img_files);
% read all frames at once
imgs = vl_imreadjpeg(img_files,'numThreads', 12);
end
需要將下載好的數(shù)據(jù)中的groundtruth_rect.txt文件放到/img文件夾下面顽照。
這個視頻序列比較特別,CarScale視頻序列的groundtruth_rect文件需要注意闽寡,SiamFC讀不出來代兵,需要將文件里的tab轉(zhuǎn)換為‘,’。
數(shù)據(jù)準備爷狈,benckmark中的修改
utils文件夾下面有兩個文件需要修改植影,關(guān)于使用的tracker和測試序列。
- configSeqs.m
- configTrackers.m
一涎永、configSeqs.m
設(shè)置測試序列的訪問路徑思币,絕對路徑。
function seqs=configSeqs
seqIVT={struct('name','Skater','path','C:\benchmark\Skater\img\','startFrame',1,'endFrame',160,'nz',4,'ext','jpg','init_rect', [0,0,0,0]),...
struct('name','Jump','path','C:\benchmark\Jump\img\','startFrame',1,'endFrame',122,'nz',4,'ext','jpg','init_rect', [0,0,0,0])};
seqs = seqIVT;
注意 startFrame和 endFrame都要作相應(yīng)修改羡微。
二谷饿、configTrackers.m
function trackers=configTrackers
trackers1={struct('name','SiamFC','namePaper','SiamFC')};
trackers = trackers1
到這里應(yīng)該就差不多了,我就可以成功運行了】教裕現(xiàn)在記錄下來覺得好像沒改什么東西各墨,但是真的很辛苦的指孤,都是一點點debug启涯,看變量數(shù)據(jù)結(jié)構(gòu),一步步的運行才知道了問題出在哪里恃轩,真的是各種問題结洼!一定要好好記錄一下,如果能再對需要的人有幫助就好啦叉跛。