-
Notifications
You must be signed in to change notification settings - Fork 72
/
deep_pyramid_cache_wrapper.m
44 lines (41 loc) · 1.29 KB
/
deep_pyramid_cache_wrapper.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function pyra = deep_pyramid_cache_wrapper(im, cnn_model, cache_opts)
% pyra = deep_pyramid_cache_wrapper(im, cnn_model, cache_opts)
%
% Load a feature pyramid from a cache on disk, optionally saving if
% there's a cache miss.
%
% cache_opts.cache_file
% .debug
% .write_on_miss
% .exists
% AUTORIGHTS
% ---------------------------------------------------------
% Copyright (c) 2014, Ross Girshick
%
% This file is part of the DeepPyramid code and is available
% under the terms of the Simplified BSD License provided in
% LICENSE. Please retain this notice and LICENSE if you use
% this file (or any portion of it) in your project.
% ---------------------------------------------------------
debug = isfield(cache_opts, 'debug') && cache_opts.debug;
write_on_miss = isfield(cache_opts, 'write_on_miss') && ...
cache_opts.write_on_miss;
cache_file = cache_opts.cache_file;
if exist(cache_file, 'file')
ld = load(cache_file);
pyra = ld.pyra;
if debug
warning('Loaded cache file %s.', cache_file);
end
else
if debug
warning('Cache file %s not found.', cache_file);
end
if write_on_miss
pyra = deep_pyramid(im, cnn_model);
save(cache_opts.cache_file, 'pyra');
if debug
warning('Cache file % saved.', cache_file);
end
end
end