-
Notifications
You must be signed in to change notification settings - Fork 237
/
spp_demo.m
51 lines (42 loc) · 1.17 KB
/
spp_demo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function spp_demo()
clear mex;
spp_model_file = '.\data\spp_model\VOC2007\spp_model.mat';
if ~exist(spp_model_file, 'file')
error('%s not exist ! \n', spp_model_file);
end
try
load(spp_model_file);
catch err
fprintf('load spp_model_file : %s\n', err.message);
end
caffe_net_file = fullfile(pwd, 'data\cnn_model\Zeiler_conv5\Zeiler_conv5');
caffe_net_def_file = fullfile(pwd, 'data\cnn_model\Zeiler_conv5\Zeiler_spm_scale224_test_conv5.prototxt');
use_gpu = true;
gpu_id = 1;
if use_gpu
gpuDevice(gpu_id);
end
caffe('init', caffe_net_def_file, caffe_net_file);
caffe('set_phase_test');
if use_gpu
spp_model.cnn.layers = spp_layers_in_gpu(spp_model.cnn.layers);
caffe('set_mode_gpu');
else
caffe('set_mode_cpu');
end
spm_im_size = [480 576 688 874 1200];
% spm_im_size = [ 688 ];
im = imread('.\datasets\VOCdevkit2007\VOC2007\JPEGImages\000015.jpg');
dets = spp_detect(im, spp_model, spm_im_size, use_gpu);
classes = spp_model.classes;
boxes = cell(length(classes), 1);
thres = -0.5;
for i = 1:length(boxes)
I = dets{i}(:, 5) >= thres;
boxes{i} = dets{i}(I, :);
end
showboxes_new(im, boxes, classes);
caffe('release');
if use_gpu
gpuDevice([]);
end