Computer Vision • Deep Learning • Information Retrieval • Recommender System •
An AI-Based Image Content Retrieval System
From unsupervised to supervised approaches
Maria Loureiro on Mar 7, 2021
?>
Similarity measurement is the basis for any information retrieval, management, or data mining system. Both in industry and in the scientific community, similarity detection has been shown to be extremely useful when applied to different use cases.
Over time, the information available on the internet has been growing in an exponential way, making it harder to analyze and consume without the help of information retrieval systems or filtering tools, with its core elements corresponding to the analysis of similarity between different text segments. Finding and filtering relevant information according to personal preferences is a time-consuming task in the daily effort to stay well-informed.
Moreover, similarity detection applied to images also has a great number of possible applications, in several fields. In biometric systems, particularly in signature and face recognition systems, image similarity detection is extremely relevant in cases of forgery detection and visual identification, respectively (1). In the shopping industry, it can also be of great importance to the detection of counterfeit products, by determining the similarity between a query image and a database of valid images (2), product recognition on store shelves (3) and content-based image retrieval (CBIR), enabling image-based queries in online stores (4).
Development of a CBIR System using a Clothing Dataset
Taking into consideration the growing demand for CBIR systems in online shopping and the evident growth of this way of e-commerce retail (5), during my internship in NILG.AI, I developed a demo of a CBIR system with a clothing dataset: the Apparel Images Dataset (6).
The chosen dataset is composed of 11 385 amateur photographs of clothing items (6), with a total of 6 different colors and 5 types of items. A total of 11 384 pairs of images, both positive and negative, were created from this dataset to then calculate image similarity. For these pairs, two distinct tasks were defined: clothing type and color. For each of these tasks, 5692 pairs were created, where half of them were positive and the other half negative. In other words, for the pairs with the task being clothing color, for example, half of the pairs were composed of clothes with similar color – positive pairs – and the other half with distinct colors – negative pairs.
As an example, two pairs – one positive and another negative – assigned with the task of clothing type are presented below.
To detect the similarity between two images, different techniques can be applied, from classical similarity measurements, using distance metrics, to trained machine learning models. Regardless of the chosen approach, the feature vector of each image – extracted from pre-trained deep learning models – can be used as data to compute the similarity.
For the extraction of the feature vector of each image, a pre-trained model was used: the VGG16 convolutional neural network, where the last layer was removed to obtain the feature vector (7).
Regarding similarity computation, Euclidean Distance is a simple but powerful measurement technique that can be applied to two feature vectors extracted from a pair of images. Another alternative is the Cosine Distance, that computes the difference in direction, irrespective of the length of each feature vector, where the distance is given by the angle between the two vectors (8). Both metrics were chosen to integrate the work developed.
Regarding machine learning models, there are also several possible options that can be used in this type of similarity measurement. Logistic Regression and Random Forest are two widely used models, having a great variety of applications, and both were selected as similarity detection techniques, using the extracted feature vector for training the model. For Logistic Regression in particular, feature normalization was also included in the pipeline since it benefited the classification results.
The four approaches were evaluated with respect to Pearson and Spearman coefficients between the similarity value given by each technique and the target classification of each pair of images. The results can be seen in the table below.
Method
Pearson
Spearman
Cosine Similarity
0.387
0.358
Inverse Euclidean Distance
0.298
0.276
Logistic Regression
0.721
0.719
Random Forest
0.696
0.705
Although better results were clearly achieved by machine learning models in comparison to similarity metrics, as expected, all tested approaches were included in the final demo.
For the front-end of the demo, Streamlit – an open-source python library – was used, which helped to easily create an interactive application for the system developed. Moreover, the application was deployed using Docker, to create a reproducible environment and facilitate its use in different machines.
The developed application, like previously mentioned, retrieves the most similar images in the dataset, when compared to the image in analysis. The latter can be chosen by the user and uploaded on the website or can be randomly selected by the algorithm, within the images available in the dataset. Moreover, the application also enables the user to choose one of the previously mentioned approaches to compute the similarity detection.
Some examples of the developed system are presented below.
Application Initial Page
Example with the use of Euclidean Distance as the similarity measure and test with a random image from the dataset:
Example with the use of a pre-trained Logistic Regression model as the similarity measure and test with an image uploaded which is not included in the dataset:
Final Remarks
As previously mentioned, there is a great number of use cases regarding image similarity detection, showing its growth potential over the next few years. The live demo here explained, and developed for a content-based image retrieval system, is just a small example of the possibilities in this area. Hope that this post inspires you to develop new projects by yourself or with the help of the NILG.AI team!
Special offers, latest news and quality content in your inbox.
Signup single post
Recommended Articles
Article
Descubra o significado do «Ai First»: Guia estratégico para 2026
22 de junho de 2026 in
Guia: Explicação
Descubra o verdadeiro significado da abordagem «AI First» para a sua empresa. Obtenha um roteiro estratégico para 2026, exemplos práticos e evite erros comuns.
IA para o Crescimento Empresarial: O Seu Guia Prático de Estratégia
17 de junho de 2026 in
Guia: Explicação
Descubra como a IA para o crescimento empresarial pode aumentar a eficiência, melhorar a tomada de decisões e criar laços mais fortes com os clientes. Obtenha agora estratégias práticas.
Automatização de faturas: otimize o seu departamento de contas a pagar em 2026
15 de junho de 2026 in
Guia: Explicação
Otimize o processo de contabilidade de fornecedores através da automatização das faturas. Conheça as tecnologias e as melhores práticas e avalie o valor real para a sua organização.
Utilizamos cookies no nosso website para lhe proporcionar a experiência mais relevante, lembrando as suas preferências e visitas repetidas. Ao clicar em “Aceitar Tudo”, concorda com a utilização de TODOS os cookies. No entanto, pode visitar as "Definições de Cookies" para fornecer um consentimento controlado.
Este website utiliza cookies para melhorar a sua experiência enquanto navega no website. Desses, os cookies categorizados como necessários são armazenados no seu navegador, pois são essenciais para o funcionamento das funcionalidades básicas do website. Também utilizamos cookies de terceiros que nos ajudam a analisar e compreender como utiliza este website. Estes cookies serão armazenados no seu navegador apenas com o seu consentimento. Tem também a opção de recusar estes cookies. No entanto, a recusa de alguns destes cookies pode afetar a sua experiência de navegação.
Os cookies necessários são absolutamente essenciais para que o website funcione corretamente. Estes cookies garantem funcionalidades básicas e recursos de segurança do website, de forma anónima.
Cookie
Duration
Description
cookielawinfo-checkbox-analiticas
11 meses
Este cookie é definido pelo plugin de Consentimento de Cookies do RGPD. O cookie é usado para armazenar o consentimento do utilizador para os cookies na categoria "Análise".
---
O seu texto é uma etiqueta ou nome de campo, provavelmente de um sistema de gestão de cookies ou de um formulário web, e não uma frase completa que necessite de tradução contextual.
No entanto, se o objectivo for manter a clareza e a funcionalidade para um utilizador de língua portuguesa, sugiro a seguinte tradução e explicação:
**"Checkbox Funcional"**
**Explicação:**
* **Checkbox:** Refere-se ao elemento gráfico de marcação (uma caixa que pode ser seleccionada ou desmarcada).
* **Funcional:** Indica que esta caixa de seleção está relacionada com funcionalidades essenciais do website, como o login, a gestão do carrinho de compras ou outras características que tornam o site utilizável.
Se esta etiqueta pertencer a um contexto onde se refere especificamente a cookies, a tradução poderia ser ajustada para ter mais clareza:
**"Aceitação de Cookies Funcionais"**
ou
**"Cookies Essenciais (Funcionais)"**
Esta última opção é comum em avisos de cookies para indicar que estes são estritamente necessários para o funcionamento do site.
---
11 meses
O cookie é definido pelo consentimento de cookies GDPR para registar o consentimento do utilizador para os cookies na categoria "Funcional".
cookielawinfo-checkbox-necessary
11 meses
Este cookie é definido pelo plugin GDPR Cookie Consent. O cookie é usado para armazenar o consentimento do utilizador para os cookies na categoria "Necessário".
cookielawinfo-checkbox-outros
11 meses
Este cookie é definido pelo plugin GDPR Cookie Consent. O cookie é usado para armazenar o consentimento do utilizador para os cookies na categoria "Outros".
checkbox-performance-cookielawinfo
11 meses
Este cookie é definido pelo plugin GDPR Cookie Consent. O cookie é usado para armazenar o consentimento do utilizador para os cookies na categoria "Desempenho".
política_de_cookies_visualizada
11 meses
O cookie é definido pelo plugin GDPR Cookie Consent e é utilizado para armazenar se o utilizador consentiu ou não com a utilização de cookies. Não armazena quaisquer dados pessoais.
Os cookies funcionais ajudam a realizar certas funcionalidades como partilhar o conteúdo do website em plataformas de redes sociais, recolher feedback e outras funcionalidades de terceiros.
Os cookies de desempenho são usados para compreender e analisar os principais índices de desempenho do website, o que ajuda a proporcionar uma melhor experiência ao utilizador para os visitantes.
Os cookies analíticos são usados para entender como os visitantes interagem com o website. Estes cookies ajudam a fornecer informações sobre métricas como o número de visitantes, taxa de rejeição, fonte de tráfego, etc.
Os cookies de publicidade são usados para fornecer aos visitantes anúncios relevantes e campanhas de marketing. Estes cookies rastreiam os visitantes em diferentes websites e recolhem informações para fornecer anúncios personalizados.