Click an Image and Display Similar Results

Hello Everyone :slight_smile:

Hi, so i have been building a Django project in python for the last two months and have got everything ready from user registration to file upload. Now my LAST part left is the following.

A User clicks an image on site which then drops down and shows similar results of that image.

How can i achieve that ? I want to fetch the results from the Database back-end of python (Will use the async Fetch function for that ) and the add Event listener for clicking an Image.

Will Really Need Your Help. Thanks :slight_smile: Will TensorFlow.js be suitable? I am a newbie at this.

So far I know the Following:

i have got the concept, that is extract the features and then compare histograms and display similar results.

is there an example in java script. i tried finding it. just could not get it any where :frowning:

mostly i found is image resizing

Will it be better to do it in the back end or use JavaScript ? Sorry for Noob Question

1 Like

You’re in the right direction regarding the features.

My first try would be to extract the image feature vector and use it (instead of the text embeddings) shown in this tutorial: Semantic Search with Approximate Nearest Neighbors and Text Embeddings Β |Β  TensorFlow Hub


hi thanks you so much for the reply. I will check that link out,

Hey do you have any experience with opencv?

SO far i have got the edges of the two images using canny method, but now what next should i do to compare my images ?

Here is the code, Can you Please Help Out:

import cv2 
import os
import numpy as np
import matplotlib.pyplot as plt
img1 = cv2.imread("1-Flip-flops.jpg",0)
img2 = cv2.imread("29-Leather mules.jpg",0)
edges1 = cv2.Canny(img1, threshold1=30, threshold2=100)
edges2 = cv2.Canny(img2, threshold1=30, threshold2=100)
plt.imshow(edges1, cmap = "gray")
plt.imshow(edges2, cmap = "gray")
1 Like

Try to give pass to

It is not clear what is your specific context so this tutorial is about image retrieval with landmarks and it could be a good baseline.

See also on the same TFHub model:


Hi thanks for the recommended article, the nearest neighbor i have to find for similar images.

Can you also check my opencv code above ? I am trying to match or find similar images of shoeswear that I scrapped from Shoe retailers online. I have detected the edges but now what?

Sorry if wrong forum,

1 Like

You need to follow and understand some basic examples e.g. with MNIST and then reproduce it for your dataset.

For a complete basic example see: