forked from jbhuang0604/WSL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaskout.m
41 lines (38 loc) · 1.4 KB
/
maskout.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
% AUTORIGHTS
% ---------------------------------------------------------
% Copyright (c) 2016, Dong Li
%
% This file is part of the WSL code and is available
% under the terms of the MIT License provided in
% LICENSE. Please retain this notice and LICENSE if you use
% this file (or any portion of it) in your project.
% ---------------------------------------------------------
clear; close all; clc;
net_file = 'caffenet_cls_adapt_iter_10000.caffemodel';
crop_mode = 'warp';
crop_padding = 16;
VOCdevkit = './data/VOCdevkit2007';
imdb_train = imdb_from_voc(VOCdevkit, 'trainval', '2007');
cache_fc8_features(imdb_train, ...
'crop_mode', crop_mode, ...
'crop_padding', crop_padding, ...
'net_file', net_file, ...
'cache_name', 'voc_2007_trainval_fc8');
load('./imdb/cache/imdb_voc_2007_trainval.mat');
load('./imdb/cache/roidb_voc_2007_trainval.mat');
IND = cell(length(imdb.image_ids),1);
for i = 1:length(imdb.image_ids)
d = load(['./cache/voc_2007_trainval_fc8/' imdb.image_ids{i} '.mat']);
gtcls = unique(d.class(d.gt==1));
feat_in = d.feat_in(d.gt~=1,1:2:end-1);
feat_out = d.feat_out(d.gt~=1,1:2:end-1);
bbs = d.boxes(d.gt~=1,:);
dist = feat_in - feat_out;
for cls = gtcls(:)'
bbs_nms = nms([bbs,dist(:,cls)],0.3);
num_top = min(size(bbs_nms,1),50);
IND{i} = [IND{i};bbs_nms(1:num_top)];
end
end
save('results_maskout_regions.mat','IND');
exit;