Rafay Zia Mir
Rafay Zia Mir

Reputation: 2116

How to set mean pixels for feedforward? caffe

I want to finetune VGG19 and it is working good. While training I am subtracting the mean pixels as

name: "VGG_ILSVRC_19_layer"
layer {
  name: "data"
  type: "Data"
  include {
    phase: TRAIN
  }
 transform_param {
    mean_value: 104
    mean_value: 117
    mean_value: 123
    mirror: false
 }
 data_param {
    source: "examples/VGG_finetune/train_lmdb"
    batch_size: 8
    backend: LMDB
  }
  top: "data"
  top: "label"
}

Now I need to feedforward through my finetuned network. If I look at this they are not specifying mean pixel value in deploy file.

Question:
How can I provide my network mean pixel value while feedforwarding?
My code for feedforward(loading network) is

net = caffe.Classifier(model_prototxt, model_trained,
                           mean=[104,117,123],
                           channel_swap=(2,1,0),
                           raw_scale=255,
                           image_dims=(224, 224))

Now I am not sure whether mean=(104,117,123) work or not because when I viewed source code of classifier then I came to know through comments in code that it only takes ndarray otherwise it give error.
How can I subtract mean pixels from input image?

Upvotes: 0

Views: 657

Answers (1)

Shai
Shai

Reputation: 114826

you can specify your mean as ndarray simply by

net = caffe.Classifier(model_prototxt, model_trained,
                       mean=NP.array( [104, 117, 123], dtype='f4'),
                       channel_swap=(2,1,0),
                       raw_scale=255,
                       image_dims=(224, 224))

Upvotes: 3

Related Questions