anukash / Keras_siamese_contrastive

I have implemented the Model saving and loading part of: https://keras.io/examples/vision/siamese_contrastive/
1 stars 2 forks source link

how to load custom dataset? #1

Closed smith-co closed 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 takes the keras.datasets.mnist.load_data().

anukash commented 2 years ago

Kindly have a look at below implementation I have used custom dataset with concept of Anchor, Positive and Negative images, Basic concept here is we are trying minimize the distance between Positive and Anchor image at the same time maximizing the distance between Negative & Anchor Link : https://github.com/anukash/Face_recognition_siamese_network

Note: Similar case implementation you can see at Keras example named as Triplet loss. Link : https://keras.io/examples/vision/siamese_network

smith-co commented 2 years ago

@anukash I would be interested to apply contrastive learning approach and not triplet based technique. That is why I was trying to use this example.

I would follow the pre_process(file_path) example from https://github.com/anukash/Face_recognition_siamese_network.

But would the rest of the code i.e. model would work as is?

anukash commented 2 years ago

Yes I guess, Change will come at loss function part and L1_dist layer, Rest of code might not work you have to change the codes accordingly one thing you can try is to take the data preparation path from one repo and model making and calling path from other, I hope that work.