Siamese Network Data lmdb

62 views
Skip to first unread message

Lorena Sandru

unread,
May 18, 2017, 2:01:02 PM5/18/17
to Caffe Users
Hello,

I'm new to Caffe framework and I want to create a siamese network.
My dataset has multiple images with eyes: eye_left.jpg and eye_right.jpg and the train sample looks like:

15_left,1
15_right,2
16_left,4
16_right,4

15_left and 15_right are images from same person: left eye and right eye and every image has a label from 0 to 5.

My question is: how can I create the lmdb files to use siamese network? .. I don't know how to start.


Thank you!

Johann Haselberger

unread,
May 21, 2017, 10:46:37 AM5/21/17
to Caffe Users

Hi,

here you can can see a working implementation for grayscale images:
https://github.com/NVIDIA/DIGITS/blob/master/examples/siamese/README.md

Give it a try.

Message has been deleted

Lorena Sandru

unread,
May 24, 2017, 5:15:15 AM5/24/17
to Caffe Users
I created a txt file with this format:

15_left.jpg, 15_right.jpg, 1
16_left.jpg, 16_right.jpg, 1
15_left.jpg, 16_right.jpg, 0
..

pairs of images from the same person have label 1, pairs of images from different person have label 0.

How can a create the lmdb files after this change? What layers should I use?

Johann Haselberger

unread,
May 24, 2017, 9:44:21 AM5/24/17
to Caffe Users
You basically have to change two things to create the right lmdbs.

First parse each line of your created txt file. For example: 
for line in yourFile.readlines():
        line
= line.strip()
        line
= line.replace(',','') # remove unneeded commas
        lineElements
= line.split(' ')  # split line at spaces
 
       
# get relevant data
        imageLeftPath
= lineElements[0]
        imageRightPath
= lineElements[1]
        label
= lineElements[2]
        images
.append([imageLeftPath, imageRightPath, label])

For the rest it's quite the same as here:




Reply all
Reply to author
Forward
0 new messages