This project aims to build a fashion similarity model using TensorFlow MNIST Datasets and Siamese Network with custom model and contrastive loss. The model can compare two images of clothing items and determine how similar they are.
The dataset used for this project is the Fashion MNIST dataset, which contains 70,000 grayscale images of 10 different types of clothing items, such as t-shirts, trousers, dresses, etc. Each image has a size of 28x28 pixels and a label from 0 to 9.
The model used for this project is a Siamese Network, which consists of two identical sub-networks that share the same weights and parameters. The sub-networks are custom models that have four convolutional layers and two dense layers. The output of the sub-networks is a 128-dimensional feature vector that represents the image. The base network architecture will looked like this.
The model takes two images as input and passes them through the sub-networks. Then, it computes the Euclidean distance between the feature vectors and applies a sigmoid function to get a similarity score between 0 and 1. The closer the score is to 1, the more similar the images are.
The model is trained using contrastive loss, which is a function that measures how well the model can distinguish similar and dissimilar pairs of images. The loss function encourages the model to minimize the distance between similar pairs and maximize the distance between dissimilar pairs.
To use this project, you need to have Python 3.6 or higher and TensorFlow 2.0 or higher installed on your machine.
The model achieved an accuracy of 90% on the test set, which means that it correctly classified 90% of the pairs of images as similar or dissimilar. The less distance are more similar with each other Here are some examples of the model’s predictions: