-
Notifications
You must be signed in to change notification settings - Fork 122
/
Copy pathloadNet.m
39 lines (31 loc) · 1.06 KB
/
loadNet.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
function net= loadNet(netID, layerName)
if nargin<2, layerName= '_relja_none_'; end
switch netID
case 'vd16'
netname= 'imagenet-vgg-verydeep-16.mat';
case 'vd19'
netname= 'imagenet-vgg-verydeep-19.mat';
case 'caffe'
netname= 'imagenet-caffe-ref.mat';
case 'places'
netname= 'places-caffe.mat';
otherwise
error( 'Unknown network ID', netID );
end
paths= localPaths();
net= load( fullfile(paths.pretrainedCNNs, netname));
net= vl_simplenn_tidy(net); % matconvnet beta17 or newer is needed
if isfield(net.meta, 'classes')
net.meta= rmfield(net.meta, 'classes');
end
if ~strcmp(layerName, '_relja_none_')
net= relja_cropToLayer(net, layerName);
layerNameStr= ['_', layerName];
else
layerNameStr= '';
end
net= relja_swapLayersForEfficiency(net);
net.meta.netID= netID;
net.meta.sessionID= sprintf('%s_offtheshelf%s', netID, layerNameStr);
net.meta.epoch= 0;
end