Monday, May 25, 2015

Convert train_val.prototxt to deploy.prototxt

  1. Remove input datalayer and insert a description of input data dimension
  2. Remove “loss” and “accuracy” layer and insert “prob” layer at the end
Here is a google groups link.

If you have preprocessing layers, things get a bit more tricky.
For example, in train_val.prototxt, which includes the “data” layer, I insert a layer to calculate the mean over the channels of input data,

layer {
name: “mean”
type: “Convolution”
bottom: “data” top: “data” param {
lr_mult: 0
decay_mult: 0
}
…}

between “data” layer and “conv1″ layer (with bottom:”data” / top:”conv1″).

In deploy.prototxt, the “mean” layer has to be retained, yet its container needs to be changed! i.e.

layer {
name: “mean”
type: “Convolution”
bottom: “data”top: “mean param {
lr_mult: 0
decay_mult: 0
}
…}

and the “conv1″ layer needs to be changed accordingly, ( bottom:”mean”/ top:”conv1″ ).
It’s fine to use train_val.prototxt with “mean” layer using “data” container in the training phase, and use deploy.prototxt with “mean” layer using “mean” container in the testing phase in python. The learned caffemodel can be loaded correctly.

No comments:

Post a Comment