Skip to content

Commit

Permalink
cache dir parsing bug fixed; progress won't be shown during feature e…
Browse files Browse the repository at this point in the history
…xtraction at this momemnt
  • Loading branch information
suhangpro committed Feb 25, 2015
1 parent 22c1cf7 commit ce1301b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
17 changes: 9 additions & 8 deletions imdb_compute_cnn_features.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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

Expand All @@ -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}))';
Expand Down
3 changes: 2 additions & 1 deletion utils/parsave.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
function parsave(filename, structX)
vl_xmkdir(fileparts(filename));
save(filename,'-struct','structX');
end
end

0 comments on commit ce1301b

Please sign in to comment.