anhttran / 3dmm_cnn

Regressing Robust and Discriminative 3D Morphable Models with a very Deep Neural Network
Other
857 stars 254 forks source link

net input data type? #7

Closed sunjunlishi closed 7 years ago

sunjunlishi commented 7 years ago

input data is 0~1,or 0~255 or -1~1

iacopomasi commented 7 years ago

Hi @sunjunlishi , it is very hard to understand your question but I think I got your point. You should basically subtract from the input image the average image that we provided with the network. This should solve your problem input_image_cnn = input_image - average_img. After subtracting the avg_image you can check the numerical range of values, if you want.

I hope this helps, iacopo

anhttran commented 7 years ago

Dear @sunjunlishi, You should check and follow our demo code. Basically, the input data is scaled to [0,255] and subtracted by mean. Also, the channels are swapped:

"transformer = caffe.io.Transformer({'data': net.blobs['data'].data.shape}) transformer.set_transpose('data', (2,0,1)) transformer.set_channel_swap('data', (2,1,0)) transformer.set_raw_scale('data', 255.0) transformer.set_mean('data',mean)"

I hope this helps, Anh

sunjunlishi commented 7 years ago

my meaning is input data's range.your answer is ok.0~255.0 and subtract buy mean

sunjunlishi commented 7 years ago

thank you

sunjunlishi commented 7 years ago

transformer.set_transpose('data', (2,0,1)),how to do?

anhttran commented 7 years ago

It simply swaps your image dimensions, from H x W x C (H: height, W: width, C: the number of channels) to C x H x W.

sunjunlishi commented 7 years ago

testing in several imgs ,why my net output is same ? 1

sunjunlishi commented 7 years ago

so that all the 3d result is same 2

iacopomasi commented 7 years ago

Hi @sunjunlishi , could you please be a bit more specific in the issue that you are reporting? I am not sure if it is on our side, the code works well for other people and you get 3DMM-like prediction which correlates with the input image. First of all, we do not have under this project C++ code that you are showing in your window. Our code is python.

I suspect that you are getting every time the average face model from Basel Face Model, instead of the Net output; if I were you, I'd check more on that; of course, it is hard to tell from your info.

I hope this helps, Best.

sunjunlishi commented 7 years ago

the prepared image,i used yours.if only net predict ,it will work. i will in ubuntu python,if i do not succeess yet in windows c++

sunjunlishi commented 7 years ago

i think my input data wrong,so all net predict same

sunjunlishi commented 7 years ago

my WxHxC,yours CxWxH

sunjunlishi commented 7 years ago

windows not ok,ubuntu ok 2017-05-04 20-29-35 2017-05-04 20-32-19

sunjunlishi commented 7 years ago

my c++ result code: PNet_->Forward(); sharedptr<Blob> reg = PNet->blob_by_name("fc_ftnew"); int iCount = reg->count(); const float* reg_data = reg->cpu_data(); std::vector fR; for (int k = 0; k < iCount; ++k) { fR.push_back(reg_data[k]); }

Does it right?

sunjunlishi commented 7 years ago

ok,l resolve it.i change caffe,it ok

sunjunlishi commented 7 years ago

thank you