Skip to content

Commit

Permalink
Merge pull request ShaoqingRen#9 from eendebakpt/master
Browse files Browse the repository at this point in the history
make unix compatible; fix for matlab without parallel toolbox
  • Loading branch information
ShaoqingRen committed Oct 16, 2014
2 parents 0c28b7c + d34455b commit 525a5dc
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
16 changes: 13 additions & 3 deletions experiments/spp_exp_train_and_test_voc.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

% -------------------- CONFIG --------------------
if ~exist('opts', 'var')
opts.net_file = fullfile(pwd, 'data\cnn_model\Zeiler_conv5\Zeiler_conv5');
opts.net_def_file = fullfile(pwd, 'data\cnn_model\Zeiler_conv5\Zeiler_spm_scale224_test_conv5.prototxt');
opts.spp_params_def = fullfile(pwd, 'data\cnn_model\Zeiler_conv5\spp_config');
opts.net_file = fullfile(pwd, 'data','cnn_model','Zeiler_conv5','Zeiler_conv5');
opts.net_def_file = fullfile(pwd, 'data','cnn_model','Zeiler_conv5','Zeiler_spm_scale224_test_conv5.prototxt');
opts.spp_params_def = fullfile(pwd, 'data','cnn_model','Zeiler_conv5','spp_config');

opts.layer = 7;
opts.cache_name = 'Zeiler_conv5_ft(5s_flip)_fc7';
Expand Down Expand Up @@ -44,7 +44,12 @@
fprintf('Logging output in %s\n', diary_file);

if conf.use_gpu
try
g = gpuDevice(opts.gpu_id);
catch
fprintf('no gpuDevice function\n');
end

end

profile clear
Expand All @@ -65,7 +70,12 @@
res_test = spp_test(spp_model, opts.imdb_test, opts.roidb_test, opts.feat_cache_test, '', true);

if conf.use_gpu
try
reset(g);
catch
fprintf('no gpuDevice function\n');
end

end

profile viewer
Expand Down
7 changes: 6 additions & 1 deletion spp_config.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@

% Experiments directory. The directory under which most outputs
% generated by running this code will go.
EXP_DIR = fullfile(pwd, '\cachedir');
EXP_DIR = fullfile(pwd, 'cachedir');

% Set to false if you do not want to use a GPU.
try
USE_GPU = logical(gpuDeviceCount());
catch
% gpuDeviceCount not available. assume GPU mode
USE_GPU=true;
end

% Load local overrides if rccn_config_local.m exists
% See spp_config_local.example.m for an example
Expand Down
20 changes: 18 additions & 2 deletions utils/spm_pool/spm_pool_caffe_mex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ using std::vector;

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
if (nrhs<5) {
mexPrintf("spm_pool_caffe_mex: needs at least 4 input arguments!\n");
mexPrintf("spm_pool_caffe_mex: compile date: %s %s\n", __DATE__ , __TIME__ );
return;
}
///// get input arguments
if (!mxIsCell(prhs[0]))
mexErrMsgTxt("feats must be in cell");
Expand All @@ -34,6 +39,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
vector<int> rsp_widths(feats_num), rsp_heights(feats_num);
vector<const float *> feats(feats_num);

//mexPrintf("spm_pool_caffe_mex: feats_num %d\n feats_num);
for (int i = 0; i < feats_num; ++i)
{
mxArray * mxFeats = mxGetCell(prhs[0], i);
Expand Down Expand Up @@ -124,7 +130,11 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
y0_norm = (y0_norm + y1_norm) / 2;
y1_norm = y0_norm;
}


if(best_feat>=rsp_heights.size() ) {
mexPrintf("spm_pool_caffe_mex: error: box %d: best_feat %d rsp_heights.size() %d\n", i, best_feat, rsp_heights.size() );
return;
}
box_norm[0] = std::min(rsp_heights[best_feat], std::max(1, y0_norm)); // top // must not change
box_norm[2] = std::min(rsp_heights[best_feat], std::max(1, y1_norm)); // bottom // must not change

Expand Down Expand Up @@ -227,4 +237,10 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
free(pooled_cache);
delete[] boxes_norm;

}
}

#ifdef MAINMEX
#include "mexstandalone.h"
#endif


0 comments on commit 525a5dc

Please sign in to comment.