Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zahra Rajabi
rcnn
Commits
2bf1ea6d
Commit
2bf1ea6d
authored
Mar 15, 2014
by
Ross Girshick
Browse files
fix workflow of the pool5 feature explorer
parent
51511d0c
Changes
4
Hide whitespace changes
Inline
Side-by-side
experiments/rcnn_exp_train_and_test.m
View file @
2bf1ea6d
function
[
res_test
,
res_train
]
=
rcnn_exp_train_and_test
()
% Runs an experiment that trains an R-CNN model and tests it.
% -------------------- CONFIG --------------------
net_file
=
'./data/caffe_nets/finetune_voc_2007_trainval_iter_70k'
;
...
...
startup.m
View file @
2bf1ea6d
...
...
@@ -4,7 +4,7 @@ if exist('selective_search/SelectiveSearchCodeIJCV')
addpath('selective_search/SelectiveSearchCodeIJCV/Dependencies');
else
fprintf('Warning: you will need the selective search IJCV code.\n');
fprintf('Press any key to download it (runs ./selective_search/fetch_selective_search.sh)');
fprintf('Press any key to download it (runs ./selective_search/fetch_selective_search.sh)
>
');
pause;
system('./selective_search/fetch_selective_search.sh');
addpath('selective_search/SelectiveSearchCodeIJCV');
...
...
@@ -19,8 +19,9 @@ addpath('bbox_regression');
if exist('external/caffe/matlab/caffe')
addpath('external/caffe/matlab/caffe');
else
warning('Please install
c
affe in ./external/caffe');
warning('Please install
C
affe in ./external/caffe');
end
addpath('experiments');
addpath('imdb');
addpath('vis/pool5-explorer');
fprintf('R-CNN startup done\n');
vis/pool5-explorer/pool5_explorer.m
View file @
2bf1ea6d
...
...
@@ -11,11 +11,7 @@ function pool5_explorer(imdb, cache_name)
conf
=
rcnn_config
(
'sub_dir'
,
imdb
.
name
);
index_file
=
sprintf
(
'%s/pool5_explorer_index_%s'
,
...
conf
.
cache_dir
,
cache_name
);
% load pre-computed index into variable 'index'
load
(
index_file
);
index
=
pool5_explorer_build_index
(
imdb
,
cache_name
);
figures
=
[
1
2
];
vf_sz
=
[
8
12
];
...
...
vis/pool5-explorer/pool5_explorer_build_index.m
View file @
2bf1ea6d
function
pool5_explorer_build_index
(
imdb
,
cache_name
)
function
index
=
pool5_explorer_build_index
(
imdb
,
cache_name
)
% AUTORIGHTS
% ---------------------------------------------------------
% Copyright (c) 2014, Ross Girshick
...
...
@@ -23,73 +23,81 @@ conf = rcnn_config('sub_dir', imdb.name);
save_file
=
sprintf
(
'%s/pool5_explorer_index_%s'
,
...
conf
.
cache_dir
,
cache_name
);
TOP_K
=
1000
;
try
% Load already computed index
fprintf
(
'trying to load: %s\n'
,
save_file
);
load
(
save_file
);
catch
warning
(
'Building the explorer index. This will take a long time.'
);
ids
=
imdb
.
image_ids
;
TOP_K
=
1000
;
% select features
sel_features
=
1
:(
6
*
6
*
256
);
ids
=
imdb
.
image_ids
;
index
.
imdb_name
=
imdb
.
name
;
index
.
images
=
ids
;
features
=
cell
(
length
(
sel_features
),
1
);
% select features
sel_features
=
1
:(
6
*
6
*
256
);
for
i
=
1
:
length
(
features
)
features
{
i
}
.
image_inds
=
[];
features
{
i
}
.
scores
=
[];
features
{
i
}
.
boxes
=
zeros
(
0
,
4
);
end
for
i
=
1
:
length
(
ids
)
tic_toc_print
(
'%d/%d'
,
i
,
length
(
ids
));
th
=
tic
();
d
=
rcnn_load_cached_pool5_features
(
cache_name
,
...
imdb
.
name
,
ids
{
i
});
index
.
imdb_name
=
imdb
.
name
;
index
.
images
=
ids
;
features
=
cell
(
length
(
sel_features
),
1
);
feat
=
d
.
feat
;
for
i
=
1
:
length
(
features
)
features
{
i
}
.
image_inds
=
[];
features
{
i
}
.
scores
=
[];
features
{
i
}
.
boxes
=
zeros
(
0
,
4
);
end
parfor
f
=
sel_features
threshold
=
min
(
features
{
f
}
.
scores
);
if
isempty
(
threshold
)
threshold
=
-
inf
;
end
sel_0
=
find
(
feat
(:,
f
)
>
threshold
);
if
isempty
(
sel_0
)
continue
;
for
i
=
1
:
length
(
ids
)
tic_toc_print
(
'%d/%d'
,
i
,
length
(
ids
));
th
=
tic
();
d
=
rcnn_load_cached_pool5_features
(
cache_name
,
...
imdb
.
name
,
ids
{
i
});
feat
=
d
.
feat
;
parfor
f
=
sel_features
threshold
=
min
(
features
{
f
}
.
scores
);
if
isempty
(
threshold
)
threshold
=
-
inf
;
end
sel_0
=
find
(
feat
(:,
f
)
>
threshold
);
if
isempty
(
sel_0
)
continue
;
end
bs
=
[
d
.
boxes
(
sel_0
,:)
feat
(
sel_0
,
f
)];
sel
=
nms
(
bs
,
0.1
);
sel
=
sel_0
(
sel
);
sz
=
length
(
sel
);
new_image_inds
=
i
*
ones
(
sz
,
1
);
new_scores
=
feat
(
sel
,
f
);
new_boxes
=
d
.
boxes
(
sel
,:);
features
{
f
}
.
image_inds
=
cat
(
1
,
features
{
f
}
.
image_inds
,
...
new_image_inds
);
features
{
f
}
.
scores
=
cat
(
1
,
features
{
f
}
.
scores
,
...
new_scores
);
features
{
f
}
.
boxes
=
cat
(
1
,
features
{
f
}
.
boxes
,
...
new_boxes
);
[
~
,
ord
]
=
sort
(
features
{
f
}
.
scores
,
'descend'
);
if
length
(
ord
)
>
TOP_K
ord
=
ord
(
1
:
TOP_K
);
end
features
{
f
}
.
image_inds
=
features
{
f
}
.
image_inds
(
ord
);
features
{
f
}
.
scores
=
features
{
f
}
.
scores
(
ord
);
features
{
f
}
.
boxes
=
features
{
f
}
.
boxes
(
ord
,
:);
end
bs
=
[
d
.
boxes
(
sel_0
,:)
feat
(
sel_0
,
f
)];
sel
=
nms
(
bs
,
0.1
);
sel
=
sel_0
(
sel
);
sz
=
length
(
sel
);
new_image_inds
=
i
*
ones
(
sz
,
1
);
new_scores
=
feat
(
sel
,
f
);
new_boxes
=
d
.
boxes
(
sel
,:);
features
{
f
}
.
image_inds
=
cat
(
1
,
features
{
f
}
.
image_inds
,
...
new_image_inds
);
features
{
f
}
.
scores
=
cat
(
1
,
features
{
f
}
.
scores
,
...
new_scores
);
features
{
f
}
.
boxes
=
cat
(
1
,
features
{
f
}
.
boxes
,
...
new_boxes
);
[
~
,
ord
]
=
sort
(
features
{
f
}
.
scores
,
'descend'
);
if
length
(
ord
)
>
TOP_K
ord
=
ord
(
1
:
TOP_K
);
fprintf
(
' %.3fs\n'
,
toc
(
th
));
if
mod
(
i
,
50
)
==
0
index
.
features
=
features
;
save
(
save_file
,
'index'
);
fprintf
(
'checkpoint %d\n'
,
i
);
end
features
{
f
}
.
image_inds
=
features
{
f
}
.
image_inds
(
ord
);
features
{
f
}
.
scores
=
features
{
f
}
.
scores
(
ord
);
features
{
f
}
.
boxes
=
features
{
f
}
.
boxes
(
ord
,
:);
end
fprintf
(
' %.3fs\n'
,
toc
(
th
));
if
mod
(
i
,
50
)
==
0
index
.
features
=
features
;
save
(
save_file
,
'index'
);
fprintf
(
'checkpoint %d\n'
,
i
);
end
index
.
features
=
features
;
save
(
save_file
,
'index'
);
end
index
.
features
=
features
;
save
(
save_file
,
'index'
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment