# Click an Image and Display Similar Results

**URL:** <https://discuss.ai.google.dev/t/click-an-image-and-display-similar-results/24996>\
**Category:** General Discussion\
**Tags:** tfjs, help\_request\
**Created:** [June 6, 2021, 10:07am UTC](https://discuss.ai.google.dev/t/click-an-image-and-display-similar-results/24996 "2021-06-06T10:07:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![firaki12345](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/firaki12345/32/7365_2.png) [@firaki12345](https://discuss.ai.google.dev/u/firaki12345)\
**Post date:** [June 6, 2021, 10:07am UTC](https://discuss.ai.google.dev/t/click-an-image-and-display-similar-results/24996/1 "2021-06-06T10:07:43Z")

</div>

Hello Everyone 🙂

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 🙂 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 ☹

mostly i found is image resizing

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

---

<div class="post-metadata">

**Author:** ![lgusm](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/lgusm/32/6230_2.png) [@lgusm](https://discuss.ai.google.dev/u/lgusm)\
**Post date:** [June 7, 2021, 2:51pm UTC](https://discuss.ai.google.dev/t/click-an-image-and-display-similar-results/24996/2 "2021-06-07T14:51:16Z")

</div>

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: [अनुमानित निकटतम पड़ोसियों और टेक्स्ट एंबेडिंग के साथ सिमेंटिक खोज &nbsp;|&nbsp; TensorFlow Hub](https://www.tensorflow.org/hub/tutorials/tf2_semantic_approximate_nearest_neighbors)

---

<div class="post-metadata">

**Author:** ![firaki12345](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/firaki12345/32/7365_2.png) [@firaki12345](https://discuss.ai.google.dev/u/firaki12345)\
**Post date:** [June 8, 2021, 3:34pm UTC](https://discuss.ai.google.dev/t/click-an-image-and-display-similar-results/24996/3 "2021-06-08T15:34:29Z")

</div>

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)
 
print(edges1)
 
plt.imshow(edges1, cmap = "gray")
plt.show()
 
plt.imshow(edges2, cmap = "gray")
plt.show()

```

---

<div class="post-metadata">

**Author:** ![Bhack](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/bhack/32/6388_2.png) [@Bhack](https://discuss.ai.google.dev/u/Bhack)\
**Post date:** [June 8, 2021, 3:49pm UTC](https://discuss.ai.google.dev/t/click-an-image-and-display-similar-results/24996/4 "2021-06-08T15:49:18Z")

</div>

Try to give pass to

> **[How to match images using DELF and TensorFlow Hub](https://www.tensorflow.org/hub/tutorials/tf_hub_delf_module)**

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:

> **[Easy Landmark Image Retrieval with TensorFlow Hub DELF Module | DLology](https://www.dlology.com/blog/easy-landmark-image-recognition-with-tensorflow-hub-delf-module/)**
>
> Have you ever wonder how Google image search works behind the scene? I will show you how to build a mini version of a landmark image recognition pipeline that leverages TensorFlow Hub's DELF(DEep Local Feature) module with minimal configuration.

---

<div class="post-metadata">

**Author:** ![firaki12345](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/firaki12345/32/7365_2.png) [@firaki12345](https://discuss.ai.google.dev/u/firaki12345)\
**Post date:** [June 9, 2021, 3:15am UTC](https://discuss.ai.google.dev/t/click-an-image-and-display-similar-results/24996/5 "2021-06-09T03:15:24Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![Bhack](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/bhack/32/6388_2.png) [@Bhack](https://discuss.ai.google.dev/u/Bhack)\
**Post date:** [June 9, 2021, 9:47am UTC](https://discuss.ai.google.dev/t/click-an-image-and-display-similar-results/24996/6 "2021-06-09T09:47:17Z")

</div>

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:

> **[Autoencoders for Content-based Image Retrieval with Keras and TensorFlow -...](https://pyimagesearch.com/2020/03/30/autoencoders-for-content-based-image-retrieval-with-keras-and-tensorflow/)**
>
> Learn how to use convolutional autoencoders to create a Content-based Image Retrieval system (i.e., image search engine) using Keras and TensorFlow.
