s-mrb / siamese-mnist

https://keras.io/examples/vision/siamese_contrastive/
1 stars 0 forks source link

how to load custom dataset? #1

Open smith-co opened 2 years ago

smith-co commented 2 years ago

I am trying to adapt this example with a new dataset.

I have a directory where I have kept anchor, positive, and negative examples, i.e.

anchor/
1.jpg
2.jpg
3.jpg
....
positive/
1.jpg
2.jpg
3.jpg
....
negative/
1.jpg
2.jpg
3.jpg
....

How could I feed this dataset into this model? The given code snippet reads directly from keras.datasets.mnist.load_data().

s-mrb commented 2 years ago

How could I feed this dataset into this model?

@smith-co this is Duplet Network and there is no anchor in Duplet Network. Perhaps a primer on Constrastive Losses might be helpful, read this and see this and compare it to this.

TL;DR

In short Contrastive Loss is a generic loss function which just contrasts the positive and negative labeled images, this contrast can be done via two variants (Duplet Loss and Triplet Loss). Duplet Loss is Contrastive Loss which make use of a pair of input images from Duplet Network (Two Networks each with its own input), Triplet Loss is Contrastive Loss which make use of input images from Triplet Network (Three Networks).

You want to adapt this to your needs, I won't be doing ur homework but here r hints:

You should be ok from here.

Morever if you want to load custom dataset, Please have a look here. Everything should be clear.