Extract the mean data
| 3081 | |
| 3082 | // Extract the mean data |
| 3083 | void ExtractCaffeMeanData(const caffe::BlobProto* blob, XGraph* graph) |
| 3084 | { |
| 3085 | // Extract the mean data itself |
| 3086 | graph->meanData.reserve(blob->data_size()); |
| 3087 | copy(blob->data().begin(), blob->data().end(), std::back_inserter(graph->meanData)); |
| 3088 | |
| 3089 | // Extract the mean shape |
| 3090 | // Caffe compute_mean() still uses deprecated API. So be ready for both |
| 3091 | caffe::BlobShape shape = blob->shape(); |
| 3092 | if(shape.dim_size() > 0) |
| 3093 | { |
| 3094 | graph->meanShape.reserve(shape.dim_size()); |
| 3095 | copy(shape.dim().begin(), shape.dim().end(), std::back_inserter(graph->meanShape)); |
| 3096 | } |
| 3097 | else |
| 3098 | { |
| 3099 | // Use vector.reserve only if you do push_back() else use vector.resize() only |
| 3100 | graph->meanShape.resize(4); |
| 3101 | graph->meanShape.at(0) = 1; |
| 3102 | graph->meanShape.at(1) = blob->has_channels() ? blob->channels() : 1; |
| 3103 | graph->meanShape.at(2) = blob->has_height() ? blob->height() : 1; |
| 3104 | graph->meanShape.at(3) = blob->has_width() ? blob->width() : graph->meanData.size(); |
| 3105 | } |
| 3106 | } |
| 3107 | |
| 3108 | #define CHECK_PRECISION(condn, variable, true_value, default_value) \ |
| 3109 | if(condn) \ |
no test coverage detected