Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multi weights file in test mode #4916

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion tools/caffe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ void CopyLayers(caffe::Solver<float>* solver, const std::string& model_list) {
}
}

// Load the weights from the specified caffemodel(s) into a test net.
void CopyTestLayers(Net<float>* test_net, const std::string& model_list) {
std::vector<std::string> 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(
Expand Down Expand Up @@ -281,7 +290,7 @@ int test() {
}
// Instantiate the caffe net.
Net<float> 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<int> test_score_output_id;
Expand Down