1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- function [net, mean_data] = caffe_load_network ( s_pathtodeployfile, s_pathtomodel, s_phase, s_meanfile, b_reshape_for_single_image_processing)
-
- net = caffe.Net(s_pathtodeployfile, s_pathtomodel, s_phase);
-
-
- i_currentNetInputSize = net.blobs('data').shape;
-
- if ( b_reshape_for_single_image_processing )
-
-
-
- net.blobs('data').reshape([i_currentNetInputSize(1) ...
- i_currentNetInputSize(2) ...
- i_currentNetInputSize(3) ...
- 1 ...
- ]);
- net.reshape();
- end
-
-
- load ( s_meanfile, 'mean_data' );
-
-
-
-
- i_sizeMean = size( mean_data );
- offset_row = floor ( int32( i_sizeMean(1)-i_currentNetInputSize(1) ) / 2 ) + 1;
- offset_col = floor ( int32( i_sizeMean(2)-i_currentNetInputSize(2) ) / 2 ) + 1;
- mean_data = mean_data( offset_row:offset_row+i_currentNetInputSize(1)-1, ...
- offset_col:offset_col+i_currentNetInputSize(2)-1, ...
- : ...
- );
- end
|