forked from albanie/convnet-burden
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompute_burdens.m
161 lines (153 loc) · 8.32 KB
/
compute_burdens.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
function compute_burdens(varargin)
%COMPUTE_BURDENS Compute burden estimates for common architectures
% COMPUTE_BURDENS computes estimates of the memory and computational
% requirements of a set of common convolutional neural network architectures.
% COMPUTE_BURDENS(..'name', value) accepts the following
% options:
%
% `includeClassifiers` :: true
% Compute burden estimates for common image classification architectures.
%
% `includeObjDetectors` :: false
% Compute burden estimates for common object detection architectures.
%
% `includeSegmenters` :: false
% Compute burden estimates for a few semantic segmentation architectures.
%
% `includeKeypointDetectors` :: false
% Compute burden estimates for a few keypoint detection architectures.
%
% `logDir` :: fullfile(vl_rootnn, 'data/burden')
% Directory location to store logged analysis.
%
% `modelDir` :: fullfile(vl_rootnn, 'data/models-import')
% Directory containing models to be analysed.
%
% Copyright (C) 2017 Samuel Albanie
% Licensed under The MIT License [see LICENSE.md for details]
opts.includeClassifiers = true ;
opts.includeObjDetectors = false ;
opts.includeSegmenters = false ;
opts.includeKeypointDetectors = false ;
opts.logDir = fullfile(vl_rootnn, 'data/burden') ;
opts.modelDir = fullfile(vl_rootnn, 'data/models-import') ;
opts = vl_argparse(opts, varargin) ;
models = {} ; logName = 'log' ;
if opts.includeClassifiers
models = [ models { ...
{'imagenet-matconvnet-alex.mat', [227 227], {'I', 'MCN', 41.8, 19.2}}, ...
{'imagenet-caffe-ref.mat', [224 224], {'I', 'MCN', 42.6, 19.7}},...
{'squeezenet1_0-pt-mcn.mat', [224 224], {'I', 'PT', 41.90, 19.58}},...
{'squeezenet1_1-pt-mcn.mat', [224 224], {'I', 'PT', 41.81, 19.38}}...
{'imagenet-vgg-f.mat', [224 224], {'I', 'MCN', 41.4, 19.1}},...
{'imagenet-vgg-m.mat', [224 224], {'I', 'MCN', 36.9, 15.5}},...
{'imagenet-vgg-s.mat', [224 224], {'I', 'MCN', 37.0, 15.8}},...
{'imagenet-vgg-m-2048.mat', [224 224], {'I', 'MCN', 37.1, 15.8}},...
{'imagenet-vgg-m-1024.mat', [224 224], {'I', 'MCN', 37.8, 16.1}},...
{'imagenet-vgg-m-128.mat', [224 224], {'I', 'MCN', 40.8, 18.4}},...
{'vgg-vd-16-reduced.mat', [224 224], {'I', 'N/A', '', ''}},...
{'imagenet-vgg-verydeep-16.mat', [224 224], {'I', 'MCN', 28.5, 9.9}},...
{'imagenet-vgg-verydeep-19.mat', [224 224], {'I', 'MCN', 28.7, 9.9}},...
{'imagenet-googlenet-dag.mat', [224 224], {'I', 'MCN', 34.2, 12.9}},...
{'resnet18-pt-mcn.mat', [224 224], {'I', 'PT', 30.24, 10.92}},...
{'resnet34-pt-mcn.mat', [224 224], {'I', 'PT', 26.70, 8.58}},...
{'imagenet-resnet-50-dag.mat', [224 224], {'I', 'MCN', 24.6, 7.7}},...
{'imagenet-resnet-101-dag.mat', [224 224], {'I', 'MCN', 23.4, 7.0}},...
{'imagenet-resnet-152-dag.mat', [224 224], {'I', 'MCN', 23.0, 6.7}},...
{'resnext_50_32x4d-pt-mcn.mat', [224 224], {'I', 'L1', 22.6, 6.49}},...
{'resnext_101_32x4d-pt-mcn.mat', [224 224], {'I', 'L1', 21.55, 5.93}},...
{'resnext_101_64x4d-pt-mcn.mat', [224 224], {'I', 'PT', 20.81, 5.66}},...
{'inception_v3-pt-mcn.mat', [299 299], {'I', 'PT', 22.55, 6.44}, 1:0.5:3},... % breaks on small inputs
{'SE-ResNet-50-mcn.mat', [224 224], {'I', 'AU', 22.37, 6.36}},...
{'SE-ResNet-101-mcn.mat', [224 224], {'I', 'AU', 21.75, 5.72}},...
{'SE-ResNet-152-mcn.mat', [224 224], {'I', 'AU', 21.34, 5.54}},...
{'SE-ResNeXt-50-32x4d-mcn.mat', [224 224], {'I', 'AU', 20.97, 5.54}},...
{'SE-ResNeXt-101-32x4d-mcn.mat', [224 224], {'I', 'AU', 19.81, 4.96}},...
{'SENet-mcn.mat', [224 224], {'I', 'AU', 18.68, 4.47}},...
{'SE-BN-Inception-mcn.mat', [224 224], {'I', 'AU', 23.62, 7.04}, 1}... % breaks on most inputs
{'densenet121-pt-mcn.mat', [224 224], {'I', 'PT', 25.35, 7.83}, 1:0.5:3},...
{'densenet161-pt-mcn.mat', [224 224], {'I', 'PT', 22.35, 6.20}, 1:0.5:3},...
{'densenet169-pt-mcn.mat', [224 224], {'I', 'PT', 24.00, 7.00}, 1:0.5:3},...
{'densenet201-pt-mcn.mat', [224 224], {'I', 'PT', 22.80, 6.43}, 1:0.5:3},...
}] ;
models = [ models { ...
{'imagenet-matconvnet-alex.mat', [227 227], {'I', 'MCN', 41.8, 19.2}}, ...
{'imagenet-caffe-ref.mat', [224 224], {'I', 'MCN', 42.6, 19.7}},...
{'squeezenet1_0-pt-mcn.mat', [224 224], {'I', 'PT', 41.90, 19.58}},...
{'squeezenet1_1-pt-mcn.mat', [224 224], {'I', 'PT', 41.81, 19.38}}...
{'imagenet-vgg-f.mat', [224 224], {'I', 'MCN', 41.4, 19.1}},...
{'imagenet-vgg-m.mat', [224 224], {'I', 'MCN', 36.9, 15.5}},...
{'imagenet-vgg-s.mat', [224 224], {'I', 'MCN', 37.0, 15.8}},...
{'imagenet-vgg-m-2048.mat', [224 224], {'I', 'MCN', 37.1, 15.8}},...
{'imagenet-vgg-m-1024.mat', [224 224], {'I', 'MCN', 37.8, 16.1}},...
{'imagenet-vgg-m-128.mat', [224 224], {'I', 'MCN', 40.8, 18.4}},...
{'vgg-vd-16-reduced.mat', [224 224], {'I', 'N/A', '', ''}},...
{'imagenet-vgg-verydeep-16.mat', [224 224], {'I', 'MCN', 28.5, 9.9}},...
{'imagenet-vgg-verydeep-19.mat', [224 224], {'I', 'MCN', 28.7, 9.9}},...
{'imagenet-googlenet-dag.mat', [224 224], {'I', 'MCN', 34.2, 12.9}},...
{'resnet18-pt-mcn.mat', [224 224], {'I', 'PT', 30.24, 10.92}},...
{'resnet34-pt-mcn.mat', [224 224], {'I', 'PT', 26.70, 8.58}},...
{'imagenet-resnet-50-dag.mat', [224 224], {'I', 'MCN', 24.6, 7.7}},...
{'imagenet-resnet-101-dag.mat', [224 224], {'I', 'MCN', 23.4, 7.0}},...
{'imagenet-resnet-152-dag.mat', [224 224], {'I', 'MCN', 23.0, 6.7}},...
{'resnext_50_32x4d-pt-mcn.mat', [224 224], {'I', 'L1', 22.6, 6.49}},...
{'resnext_101_32x4d-pt-mcn.mat', [224 224], {'I', 'L1', 21.55, 5.93}},...
{'resnext_101_64x4d-pt-mcn.mat', [224 224], {'I', 'PT', 20.81, 5.66}},...
{'inception_v3-pt-mcn.mat', [299 299], {'I', 'PT', 22.55, 6.44}, 1:0.5:3},... % breaks on small inputs
{'SE-ResNet-50-mcn.mat', [224 224], {'I', 'AU', 22.37, 6.36}},...
{'SE-ResNet-101-mcn.mat', [224 224], {'I', 'AU', 21.75, 5.72}},...
{'SE-ResNet-152-mcn.mat', [224 224], {'I', 'AU', 21.34, 5.54}},...
{'SE-ResNeXt-50-32x4d-mcn.mat', [224 224], {'I', 'AU', 20.97, 5.54}},...
{'SE-ResNeXt-101-32x4d-mcn.mat', [224 224], {'I', 'AU', 19.81, 4.96}},...
{'SENet-mcn.mat', [224 224], {'I', 'AU', 18.68, 4.47}},...
{'SE-BN-Inception-mcn.mat', [224 224], {'I', 'AU', 23.62, 7.04}, 1}... % breaks on most inputs
{'densenet121-pt-mcn.mat', [224 224], {'I', 'PT', 25.35, 7.83}, 1:0.5:3},...
{'densenet161-pt-mcn.mat', [224 224], {'I', 'PT', 22.35, 6.20}, 1:0.5:3},...
{'densenet169-pt-mcn.mat', [224 224], {'I', 'PT', 24.00, 7.00}, 1:0.5:3},...
{'densenet201-pt-mcn.mat', [224 224], {'I', 'PT', 22.80, 6.43}, 1:0.5:3},...
} ] ;
logName = [ logName '-cls'] ;
models = [{...
{'mcn-mobilenet.mat', [224 224], {'I', 'AU', 29.4, '-'}, 1:0.5:3}, ...
}] ;
% fix later
% {'mcn-mobilenet-v2.mat', [224 224], {'I', 'AU', 29.4, '-'}, 1:0.5:3} ...
end
if opts.includeObjDetectors
models = [ models { ...
{'ssd-pascal-mobilenet-ft.mat', [300 300]}, ...
{'rfcn-res50-pascal', [600 850]}, ...
{'rfcn-res101-pascal', [600 850]}, ...
{'ssd-mcn-pascal-vggvd-300.mat', [300 300]}, ...
{'ssd-mcn-pascal-vggvd-512.mat', [512 512]}, ...
{'faster-rcnn-vggvd-pascal', [600 850]}, ...
} ] ;
logName = [logName '-det'] ;
end
if opts.includeSegmenters
models = [ models { ...
{'pascal-fcn32s-dag.mat', [384 384]}, ...
{'pascal-fcn16s-dag.mat', [384 384]}, ...
{'pascal-fcn8s-dag.mat', [384 384]}, ...
{'deeplab-vggvd-v2.mat', [513 513]}, ...
{'deeplab-res101-v2.mat', [513 513]}, ...
} ] ;
logName = [logName '-seg'] ;
end
if opts.includeKeypointDetectors
models = [ models { ...
{'multipose-mpi.mat', [368 368]}, ...
{'multipose-coco.mat', [368 368]}, ...
} ] ;
logName = [logName '-key'] ;
end
if ~exist(opts.logDir, 'dir'), mkdir(opts.logDir) ; end
logFile = fullfile(opts.logDir, [logName '.txt']) ;
diary(logFile) ; diary on ;
for ii = 1:numel(models)
mm = models{ii} ;
if numel(mm) == 4, sc = {'scales', mm{4}} ; else, sc = {} ; end
modelPath = fullfile(opts.modelDir, mm{1}) ;
burden('modelPath', modelPath, 'imsz', mm{2}, 'scores', mm{3}, sc{:}) ;
end
diary off ;