diff --git a/tools/caffe.cpp b/tools/caffe.cpp index 9bf4214ad93..7830280d570 100644 --- a/tools/caffe.cpp +++ b/tools/caffe.cpp @@ -160,6 +160,15 @@ void CopyLayers(caffe::Solver* solver, const std::string& model_list) { } } +// Load the weights from the specified caffemodel(s) into a test net. +void CopyTestLayers(Net* test_net, const std::string& model_list) { + std::vector model_names; + boost::split(model_names, model_list, boost::is_any_of(",") ); + for (int i = 0; i < model_names.size(); ++i) { + test_net->CopyTrainedLayersFrom(model_names[i]); + } +} + // Translate the signal effect the user specified on the command-line to the // corresponding enumeration. caffe::SolverAction::Enum GetRequestedAction( @@ -281,7 +290,7 @@ int test() { } // Instantiate the caffe net. Net caffe_net(FLAGS_model, caffe::TEST, FLAGS_level, &stages); - caffe_net.CopyTrainedLayersFrom(FLAGS_weights); + CopyTestLayers(&caffe_net, FLAGS_weights); LOG(INFO) << "Running for " << FLAGS_iterations << " iterations."; vector test_score_output_id;