Commit 2bf1ea6d authored by Ross Girshick's avatar Ross Girshick
Browse files

fix workflow of the pool5 feature explorer

parent 51511d0c
function [res_test, res_train] = rcnn_exp_train_and_test() function [res_test, res_train] = rcnn_exp_train_and_test()
% Runs an experiment that trains an R-CNN model and tests it.
% -------------------- CONFIG -------------------- % -------------------- CONFIG --------------------
net_file = './data/caffe_nets/finetune_voc_2007_trainval_iter_70k'; net_file = './data/caffe_nets/finetune_voc_2007_trainval_iter_70k';
......
...@@ -4,7 +4,7 @@ if exist('selective_search/SelectiveSearchCodeIJCV') ...@@ -4,7 +4,7 @@ if exist('selective_search/SelectiveSearchCodeIJCV')
addpath('selective_search/SelectiveSearchCodeIJCV/Dependencies'); addpath('selective_search/SelectiveSearchCodeIJCV/Dependencies');
else else
fprintf('Warning: you will need the selective search IJCV code.\n'); 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; pause;
system('./selective_search/fetch_selective_search.sh'); system('./selective_search/fetch_selective_search.sh');
addpath('selective_search/SelectiveSearchCodeIJCV'); addpath('selective_search/SelectiveSearchCodeIJCV');
...@@ -19,8 +19,9 @@ addpath('bbox_regression'); ...@@ -19,8 +19,9 @@ addpath('bbox_regression');
if exist('external/caffe/matlab/caffe') if exist('external/caffe/matlab/caffe')
addpath('external/caffe/matlab/caffe'); addpath('external/caffe/matlab/caffe');
else else
warning('Please install caffe in ./external/caffe'); warning('Please install Caffe in ./external/caffe');
end end
addpath('experiments'); addpath('experiments');
addpath('imdb'); addpath('imdb');
addpath('vis/pool5-explorer');
fprintf('R-CNN startup done\n'); fprintf('R-CNN startup done\n');
...@@ -11,11 +11,7 @@ function pool5_explorer(imdb, cache_name) ...@@ -11,11 +11,7 @@ function pool5_explorer(imdb, cache_name)
conf = rcnn_config('sub_dir', imdb.name); conf = rcnn_config('sub_dir', imdb.name);
index_file = sprintf('%s/pool5_explorer_index_%s', ... index = pool5_explorer_build_index(imdb, cache_name);
conf.cache_dir, cache_name);
% load pre-computed index into variable 'index'
load(index_file);
figures = [1 2]; figures = [1 2];
vf_sz = [8 12]; vf_sz = [8 12];
......
function pool5_explorer_build_index(imdb, cache_name) function index = pool5_explorer_build_index(imdb, cache_name)
% AUTORIGHTS % AUTORIGHTS
% --------------------------------------------------------- % ---------------------------------------------------------
% Copyright (c) 2014, Ross Girshick % Copyright (c) 2014, Ross Girshick
...@@ -23,24 +23,31 @@ conf = rcnn_config('sub_dir', imdb.name); ...@@ -23,24 +23,31 @@ conf = rcnn_config('sub_dir', imdb.name);
save_file = sprintf('%s/pool5_explorer_index_%s', ... save_file = sprintf('%s/pool5_explorer_index_%s', ...
conf.cache_dir, cache_name); 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 ids = imdb.image_ids;
sel_features = 1:(6*6*256);
index.imdb_name = imdb.name; % select features
index.images = ids; sel_features = 1:(6*6*256);
features = cell(length(sel_features), 1);
for i = 1:length(features) index.imdb_name = imdb.name;
index.images = ids;
features = cell(length(sel_features), 1);
for i = 1:length(features)
features{i}.image_inds = []; features{i}.image_inds = [];
features{i}.scores = []; features{i}.scores = [];
features{i}.boxes = zeros(0, 4); features{i}.boxes = zeros(0, 4);
end end
for i = 1:length(ids) for i = 1:length(ids)
tic_toc_print('%d/%d', i, length(ids)); tic_toc_print('%d/%d', i, length(ids));
th = tic(); th = tic();
d = rcnn_load_cached_pool5_features(cache_name, ... d = rcnn_load_cached_pool5_features(cache_name, ...
...@@ -89,7 +96,8 @@ for i = 1:length(ids) ...@@ -89,7 +96,8 @@ for i = 1:length(ids)
save(save_file, 'index'); save(save_file, 'index');
fprintf('checkpoint %d\n', i); fprintf('checkpoint %d\n', i);
end end
end end
index.features = features; index.features = features;
save(save_file, 'index'); save(save_file, 'index');
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment