Product recommendations with image similarity
Enhance customer experience using image similarity.
The world of e-commerce is driven by consumer choice. Suggesting similar items to customers is a great way to ensure that customers make a purchase.
Image similarity, which we’ll use in this tutorial, is a way to quantify how similar two images are by creating representations of old images in a dataset, then mapping a new image to the old images to find the most similar ones.
- Target audience: Beginners
- Estimated time: Setup - 15 minutes | Building index - 50 minutes
- Tutorial type: Learn AI & platform
- Problem type: Image similarity
You will learn to
- Create an image similarity model.
- Deploy your model.
First, click New project to create a project. Name it, so you know what kind of project it is.
A project combines all of the steps in solving an AI problem on the Peltarion Platform.
After creating the project, you will be taken to the Datasets view, where you can import data.
Click Import free datasets.
Stanford online products dataset
Look for the Stanford Online Products - tutorial data dataset in the list. Click on the dataset.
The Stanford Online Products dataset is very large. It consists of 120,000 photos showing 12 different types of items sold online, in 224x224 resolution. Each image shows an object like a bicycle, coffee maker, lamp, toaster, etc.
Click Accept and import to import the dataset in your project.
Create new smaller subsets
All samples in the dataset are by default split into 10% validation, 10% test, and 80% training subsets. Usually, the default settings are used to train a deployed model for real-world use.
However, this dataset is so large, and it will take a long time to train a model with the whole dataset. You will therefore start by using only 8% of the dataset for training and 2% for validation.
Make sure you look at the advanced settings.
Look for the Subsets section and click New subset.
Name the subset Split 8/2.
Click the 2. Split subset tab and select Random.
Set the Size of the first subset to 8 and name it Training 8%.
Set the Size of the second subset to 2 and name it Validation 2%.
Click Save version and then Use in new experiment to open the Experiment wizard.
Build a model/create an experiment
Make sure that the Stanford Online Products dataset is selected.
The selected dataset Split should be 8/2, otherwise training the model will take a long time.
Inputs / target tab,
Select image as Input feature and super_class_id as Target feature.
Problem type tab,
Select Image similarity in the drop-down menu.
Click Create, and you’ll find the model in the Modeling canvas.
Run the experiment
The experiment is done and ready to be trained. All settings have been pre-populated by the platform.
Click Run and wait until the experiment has finished 1 epoch.
How does image similarity search work?
When using image similarity, you want to compare a new image with all the images you have in your dataset to find the most similar images in the dataset.
First you convert each image your dataset into a vector with a deep learning model.
This is what you just did when you clicked Run.
Save all images’ vectors into a large index.
This is what you’re about to do when you deploy your model.
To find similar images to a new image, you transform that image into a vector with the same deep learning model. Then you compare that vector with every vector in the index to pick the most similar ones.
Deploy your model
In the Evaluation view, click Create deployment (you can skip evaluation this time).
Name the deployment and select Similarity search.
Keep the default values and click Create. The platform will now build an index that includes all image-vectors. This may take some time.
Make the deployment public
Building an index will take some time, but when it’s done, toggle the switch to make your deployment public. This will allow you to share your results with friends and colleagues on, e.g., with the link, Twitter, LinkedIn.
Now click Enable make the deployment available outside the Peltarion Platform.
Your experiment is now ready to be called via the deployment API.
Open web app
We’ve made it super easy for you to test the deployment. Click on Open web app, and you will be directed to the Deployment web app.
You just need an image to test. Try to download this image of some kind of chair or take your own photo.
Add the photo and then click Get your result.
You’ve create an image similarity model on the Peltarion Platform
You’ve built and index with all you images and deployed the model live.
You’ve testesd the image
The Buy or not tutorial will show you how to predict if a customer will buy or not based on earlier customers buying patterns. You will use tabular data to solve this classification problem and get advice on how you’d also solve a regression problem.
Test image similarity deployment with Postman
For expert users:
If you’re an expert user, we’ve created an easy walk-through of how to use Postman to call your deployed model.