From ce1301b7e66f3f6c8948a90fc01735d2a2035e4b Mon Sep 17 00:00:00 2001 From: Hang Su Date: Wed, 25 Feb 2015 12:30:18 -0500 Subject: [PATCH] cache dir parsing bug fixed; progress won't be shown during feature extraction at this momemnt --- imdb_compute_cnn_features.m | 17 +++++++++-------- utils/parsave.m | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/imdb_compute_cnn_features.m b/imdb_compute_cnn_features.m index 7c7b1cf..628ecc3 100644 --- a/imdb_compute_cnn_features.m +++ b/imdb_compute_cnn_features.m @@ -166,8 +166,8 @@ end parfor (i=1:nImgs, poolSize) % for i=1:nImgs, % if no parallel computing toolbox - [imCat, imName, ~] = fileparts(imdb.images.name{i}); - if exist(fullfile(cacheDir, [imCat '_' imName '.mat']),'file'), + [imPathStr, imName, ~] = fileparts(imdb.images.name{i}); + if exist(fullfile(cacheDir, imPathStr, [imName '.mat']),'file'), continue; end im = opts.readOp(fullfile(imdb.imageDir,imdb.images.name{i}),nChannels); @@ -178,11 +178,12 @@ feat = get_cnn_activations( im, net, subWins, layers, ... 'gpuMode', opts.gpuMode); - parsave(fullfile(cacheDir,[imCat '_' imName '.mat']),feat); + parsave(fullfile(cacheDir,imPathStr,[imName '.mat']),feat); - cacheFiles = dir(fullfile(cacheDir,'*.mat')); - fprintf('[%4d/%4d] %s\n',length(cacheFiles),nImgs,... - fullfile(imdb.imageDir,imdb.images.name{i})); + % cacheFiles = dir(fullfile(cacheDir,'*.mat')); + % fprintf('[%4d/%4d] %s\n',length(cacheFiles),nImgs,... + % fullfile(imdb.imageDir,imdb.images.name{i})); + fprintf(' %s\n', fullfile(imdb.imageDir,imdb.images.name{i})); end @@ -207,8 +208,8 @@ for i=1:nImgs, if mod(i,10)==0, fprintf('.'); end if mod(i,500)==0, fprintf(' %4d/%4d\n', i,nImgs); end - [imCat, imName, ~] = fileparts(imdb.images.name{i}); - feat = load(fullfile(cacheDir,[imCat '_' imName '.mat'])); + [imPathStr, imName, ~] = fileparts(imdb.images.name{i}); + feat = load(fullfile(cacheDir,imPathStr,[imName '.mat'])); for fi = 1:numel(layers.name), featCell{fi}.x((i-1)*nSubWins+(1:nSubWins),:) = ... squeeze(feat.(layers.name{fi}))'; diff --git a/utils/parsave.m b/utils/parsave.m index fd2e499..363f0da 100644 --- a/utils/parsave.m +++ b/utils/parsave.m @@ -1,3 +1,4 @@ function parsave(filename, structX) + vl_xmkdir(fileparts(filename)); save(filename,'-struct','structX'); -end \ No newline at end of file +end