akarshzingade / image-similarity-deep-ranking

369 stars 103 forks source link

Weights and demo #1

Closed vrublevskiyvitaliy closed 6 years ago

vrublevskiyvitaliy commented 6 years ago

Could you post/load weights deepranking_adam_100_epoch.h5 with your deepranking.h5?

Also can you explain how to run some kind of a demo, when we have 2 images and want to get their similarity score?

vrublevskiyvitaliy commented 6 years ago

Also can you explain how we train it, because I found only 2 images input https://github.com/akarshzingade/image-similarity-deep-ranking/blob/master/deepRanking.py#L58 https://github.com/akarshzingade/image-similarity-deep-ranking/blob/master/deepRanking.py#L64 but as I understood for training we need to pass 3 images.

Sorry if this questions are a little dummy, cause I'm new in cnn and siamese convolutional network.

akarshzingade commented 6 years ago

Hi Vitaliy. I hope the below statements address your questions:

1) The "deepranking_adam_100_epoch.h5" model file is same as "deepranking.h5". I had renamed it while uploading the file.

2) So sorry that I haven't illustrated how to get the similarity score. I shall add a demo soon. Anyway, to get the similarity score- You will have to pass the images to the model to get the 4096 dimension embedding for each image. Then you will have to calculate the euclidean distance between different images to their similarity scores.

3) You are right that we need to pass 3 images to a normal Deep Ranking network. But, my implementation uses a custom image generator function that sequentially passes the triplets to the network. It is explained here.

Please let me know if you have any further questions. :)

alteest commented 6 years ago

Still no demo( As I understand if we want to find similarity in database with 10000 pictures, we should calculate similarity score between source image and all 10000 images?

akarshzingade commented 6 years ago

Hey @alteest @vrublevskiyvitaliy . Sorry for the delay. I have added the deepranking_get_distance.py script that will help you find the similarity between the images.

You will have to compute the distance between the source image and all the images in the dataset. But, there are ways to optimise this search. One way is to: 1) Cluster all the dataset image embeddings and store the cluster means. 2) Compare the source image embeddings with the cluster means. 3) Select the closest cluster. 4) Compare the source image embeddings with the dataset images belonging to the selected cluster. You can also create hierarchical clusters to further optimise it.