pycaffe: How to input multiple source data for deploy?

1,414 views
Skip to first unread message

evera...@gmail.com

unread,
Jun 23, 2015, 6:29:53 AM6/23/15
to caffe...@googlegroups.com
Hi  all,


In the train phase,  I define multiple data layer to receive multiple input from different data source.
but How to define in the deploy for multiple input?

Please help me! I really appreciate your help!


Everal

evera...@gmail.com

unread,
Jun 24, 2015, 7:09:31 AM6/24/15
to caffe...@googlegroups.com
up, Did anyone know how to do it

在 2015年6月23日星期二 UTC+8下午6:29:53,evera...@gmail.com写道:

Axel Angel

unread,
Jun 24, 2015, 9:43:21 AM6/24/15
to caffe...@googlegroups.com
Well it's easy, you just define multiple input, like this:

input: "pair_data"
input_dim: 1
input_dim: 2
input_dim: 28
input_dim: 28
input: "sim"
input_dim: 1
input_dim: 1
input_dim: 1
input_dim: 1

evera...@gmail.com

unread,
Jun 24, 2015, 10:18:41 AM6/24/15
to caffe...@googlegroups.com
Hi Axel,

Thx for you help. 

but how can I use the python interface to input the multiple data source.


caffe.io.load_image(IMAGE_FILE)
this function only one parameter, how can I input two image file?

thank you!

Everal
在 2015年6月24日星期三 UTC+8下午9:43:21,Axel Angel写道:

evera...@gmail.com

unread,
Jun 24, 2015, 10:33:04 AM6/24/15
to caffe...@googlegroups.com
Hi Axel,

Thinking you advice twice

I think the input through python interface maybe a dictionary, such as: dic = {"pair_data":"image_file1", "sim":"image_file2"}

if i need to modify the source code to support this method?


Everal

在 2015年6月24日星期三 UTC+8下午9:43:21,Axel Angel写道:
Well it's easy, you just define multiple input, like this:

evera...@gmail.com

unread,
Jun 26, 2015, 9:05:10 AM6/26/15
to caffe...@googlegroups.com
Please, Does anyone solve  this question.


在 2015年6月23日星期二 UTC+8下午6:29:53,evera...@gmail.com写道:
Hi  all,

Axel Angel

unread,
Jun 26, 2015, 1:14:05 PM6/26/15
to caffe...@googlegroups.com
When you use your network with forward, just provide all the inputs like named arguments:

forward_all(pair_data=mypair, sim=mysim)

evera...@gmail.com

unread,
Jun 27, 2015, 9:56:20 AM6/27/15
to caffe...@googlegroups.com
Hi Axel,


I can't understand you said clearly, When input is only one image, I use the function 
net = caffe.Classifier(.....)
prediction = net.predict([input_image])
to get the answer, when I need two input image, I don't know how to match the predict([input_image]) function.

I see the source code about classifier.py, I find the out = self.forward_all(**{self.inputs[0]: caffe_in}).

Trouble you to give more guidence, please.

Thank you!!



Everal


在 2015年6月27日星期六 UTC+8上午1:14:05,Axel Angel写道:

evera...@gmail.com

unread,
Jun 27, 2015, 11:24:46 PM6/27/15
to caffe...@googlegroups.com
Hi Axel,


I solve this problem.

Thanks for you guidance very much.


Everal  

在 2015年6月27日星期六 UTC+8上午1:14:05,Axel Angel写道:
When you use your network with forward, just provide all the inputs like named arguments:

陈凯

unread,
Jul 8, 2015, 9:20:36 PM7/8/15
to caffe...@googlegroups.com
Hi everal,

I met the same problem.
can you tell about some details about your solution?
Thank you very much

Lionel

在 2015年6月28日星期日 UTC+8上午11:24:46,evera...@gmail.com写道:

evera...@gmail.com

unread,
Jul 8, 2015, 10:14:31 PM7/8/15
to caffe...@googlegroups.com
Hi Lionel,

Refer to the caffe/python/caffe/classifier.py, I find it only support one input in the __init__, so I don't modify the classifier.py to support two input.

you can have a try.


Everal

在 2015年7月9日星期四 UTC+8上午9:20:36,Lionel写道:

Lionel

unread,
Jul 8, 2015, 10:29:55 PM7/8/15
to caffe...@googlegroups.com
Hi Everal,

Thank you for your reply.

But what confused me is that if the "classifier.py" does not support two input, how can we use two images as input in the python script to get their common classification result?

Thanks.

Lionel

在 2015年7月9日星期四 UTC+8上午10:14:31,evera...@gmail.com写道:

evera...@gmail.com

unread,
Jul 9, 2015, 5:43:42 AM7/9/15
to caffe...@googlegroups.com
Hi Lionel,


sorry, I modify the classifier.py to support the two input. I say wrong before.

you can read the __init__ in the classifier.py, and you will find it only support one input, you can modify it to support two input.

you can refer the classifier.py to write a classifier2.py for supporting two input.


Everal

在 2015年7月9日星期四 UTC+8上午10:29:55,Lionel写道:

Lionel

unread,
Jul 9, 2015, 10:02:59 PM7/9/15
to caffe...@googlegroups.com
Hi Everal,

Thank you very much.

I will try it.

Lionel



在 2015年7月9日星期四 UTC+8下午5:43:42,evera...@gmail.com写道:

Андрей Винокуров

unread,
Jul 7, 2016, 8:14:31 AM7/7/16
to Caffe Users
Hello, Everal!
Could you give a part of code, where you use double input?

dusa

unread,
Apr 1, 2017, 9:41:33 AM4/1/17
to Caffe Users
Hi all,

I am having the same exact problem! Could any of you give hints about what changes are needed in classifier.py for the modification to support multiple image data inputs?

I have trained my model and all, and I am stuck at testing:


I am trying to test my network on new data, below is the part where I define data in my deploy.prototxt file

input: "data"
input_dim: 80 
input_dim: 3
input_dim: 227
input_dim: 227
input: "modaldata"
input_dim: 80 
input_dim: 3
input_dim: 227
input_dim: 227
input: "clip_markers"
input_dim: 80 
input_dim: 1
input_dim: 1
input_dim: 1

data is the RGB file and modaldata is a modal image of the same file (such as depth).

Using a python script I transform both of the image data, there is no error during transforming "data" however I get an error while transforming the "modaldata" at this line:

modalcaffe_in[ix] = transformer_modal.preprocess('modaldata',inputs)

And the error I get is:

..../python/caffe/io.py", line 136, in preprocess
  self.__check_input(in_)
 File "/.../python/caffe/io.py", line 115, in __check_input
  in_, self.inputs))

Exception: modaldata is not one of the net inputs: {'data': (80, 3, 227, 227)}
Reply all
Reply to author
Forward
0 new messages