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

How to prepare an image for the MATLAB wrapper #198

Closed
AlexBinder opened this issue Mar 11, 2014 · 2 comments
Closed

How to prepare an image for the MATLAB wrapper #198

AlexBinder opened this issue Mar 11, 2014 · 2 comments

Comments

@AlexBinder
Copy link

Hi,

I want to do a forward for an image for a pretrained network in C++ (as a first step for some research on checking the conservation of certain physically motivated quantities within a neural net).
I have checked the matlab and python wrappers.
I understand that the input is a float array with width-major addressing in the type of
arr[channel_index * imageheight * imagewidth + height_index * imagewidth + width_index ](correct me if I am wrong)

My questions are:

  1. what image value scaling is required for the input array for the model models/caffe_reference_imagenet_model ?
    [0,1] or [0 255] (data_layer.cpp contains an uint8 conversion ... thats a hint for 255) or ??

  2. does the data set mean get substracted internally during a forward for testing phase
    or do I have to substract it myself for testing phase (I dont care about training phase here)?

  3. I see the mean gets substracted in the data_layer class,
    models/imagenet.prototxt does initialize a data_layer ?
    Even if it is initialized it looks like the mean from the data layer will not be used in the matlab wrapper for substraction, right or wrong?

Best, Alex

@kloudkl
Copy link
Contributor

kloudkl commented Mar 11, 2014

The data is converted into uint8 and then scaled with the predefined scaling ratio. The ratio is 0.00390625 (1/255) in some example prototxts to scale [0 255] to [0 1].

The mean is automatically subtracted using mean blob if the meanfile field of data layer is defined in proto. You can also do it by yourself and do not define the meanfile field.

All your questions are actually answered by the source codes. For example, the answer to the third one is in the data_layer.cpp which you head read.

  // check if we want to have mean
  if (this->layer_param_.has_meanfile()) {

@shelhamer
Copy link
Member

For further details of MATLAB wrapper usage, refer to the matcaffe demo.

With our active development the code is currently its own best documentation, although we are working to have wrapper documentation soon once some recent improvements are in #199 #132. Help with this is appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants