How to pass a pair of images into the network during testing a siamese neural network?

52 views
Skip to first unread message

uzai...@gmail.com

unread,
Apr 16, 2017, 7:29:31 PM4/16/17
to Caffe Users
Hi all,

I trained a siamese network on my own data. I followed the siamese netwrk tutorial and successfully modified the prototxt files to create a network and split the data into two text files, each txt file containing images for each branch of the siamese net.

I used the "ImageData" data layer for loading images directly from the txt files on both the channels of the siamese network. 

However I want to check the precision and recall of my network and since there are no inbuilt layers for doing so, I need to write a script in python where I can compute the precision and recall values using the predictions i get from the network. How do I pass a pair of inputs into the net?

I see that there are a few examples online but they only deal with a single image. This line in the examples assigns input image to the blob. 

net.blobs['data'].data[...] = im_input 


How can I pass two images , one for each channel of the siamese network into the network?

THanks.

Przemek D

unread,
Apr 19, 2017, 4:56:07 AM4/19/17
to Caffe Users
Caffe blobs' data field is a normal numpy array, typically 4-dimensional. Dimensions are in the following order: image index, channel, height, width. Therefore, assignment
net.blobs['data'].data[0][...] = ...
assigns a single (first) image in a batch (right side has to be 3D however), and
net.blobs['data'].data[0][n][...] = ...
assigns to n-th channel of first image in a batch.
Reply all
Reply to author
Forward
0 new messages