machine-learningcomputer-visioncaffehdf5pycaffe

caffe net get next batch from hdf5 layer


I'm using Caffe's Python interface to test my trained network:

model_def = "./test.prototxt"
model_weights = "./seg_10000.caffemodel" # contains trained weights

net = caffe.Net(model_def, model_weights, caffe.TEST)    
output = net.forward()

This works for only the first image. My "test.prototxt" file loads data from the hdf5 format and contains 20 images:

layer { top: "data" top: "label" name: "loaddata" type: "HDF5Data" hdf5_data_param { source: "/home/mmc/data.txt" batch_size: 1 } include { phase: TEST } }

The data.txt file points to a .h5 file that contains 20 images i.e. 20x3x100x100.

However, when I print the shape of the "data" blob, I only see one image.

net.blobs["data"].data.shape comes out to be 1x3x100x100

Could the batch_size parameter be messing with it? Or is there a different way to initialize the network?

Thank you


Solution

  • The data layer you defined uses batch_size: 1 this means your net processes one image at a time regardless of the number of images in the test set. If you want it to read all 20 images at once, you need to define the batch_size of the data layer to be 20.