0
votes

I need to write python script that prepare data to feed it to a caffe solver. My input is images(X) and vector of ints(Y) (I have multioutput regression problem not single Y for each X) and I try to modify Lenet to my task.

Here I found that hdf5 can be a good option - it can be used from python, but drawbacks is that we can't do data augmentation on-the-fly and input images must be float32/float64.

Also here I found an example, but in example there is only 1D data, so I'm curious what shape images should have?

Also here I found info about EUCLIDEAN_LOSS and HINGE_LOSS layers. What layer type should I use for multioutput regression?

1
please ask a single question at each post: one for data, and maybe a new one for what loss to use. - Shai
BTW using enum (e.g., EUCLIDEAN_LOSS, HINGE_LOSS) for layer type indicates old caffe version. Newer versions work with strings: type: "EuclideanLoss", or type: "HIngeLoss". Make sure your caffe branch is up to date. - Shai
How python-ic are you? you can write a type: "Python" layer as an input layer to do the augmentations you want on the fly. - Shai

1 Answers

1
votes

Caffe expects its input images to be 4-D B-by-C-by-H-by-W:

  • B is the "batch size", the number of images you process simultaneously
  • C is the number of channels, usually 3 for BGR (most nets conforms to opencv BGR format, rather than RGB. go figure...)
  • H and W are the height and width of the image, respectively.

Therefore, you need a python script that read images (you can use caffe.io.load_image) then transpose, resize, rescale and finally stack them into B-by-C-by-H-by-W numpy arrays of type float32.
You can do the augmentations in python and save all the data into hdf5 files.