Packaging a PostgreSQL/ PyTorch based image recommender system with Flask, importing data and running it on the Heroku cloud application platform.

Image for post
Image for post
Selected image of a logo and automatically detected logos of other technologies employed for the image recommender application (Source: M. D. Korzec; Flask logo license; Python logo PSF trandemark usage policy; html logo cc by 3.0)

During the last weeks I have implemented an item-to-item image recommender system that uses PyTorch’s pretrained Resnet18 convolutional neural network to generate comparability through feature vectors, a database to manage the images and top-k lists and a user interface.

The developed solution and steps for the deployment on Heroku are presented in this article and the code is available on GitHub.

I have set and fulfilled the following requirements for this project

1. The web app is accessible on the internet.

2. The application has a gallery of images with pagination, loading only the relevant data for the page.

3. The data for the gallery and the recommendations is fetched from a database.


An assessment of the importance of recommender systems

Image for post
Image for post
(Source: Combined Unsplash sources @jankolar and @franki by the author)

Most users are aware of the existence of individualized recommendations on large internet platforms, e.g. by using Amazon and noting the You might also like features. However, the importance and dominance of this technology within big data platforms is maybe more crucial than many might think:

70% of the 30 largest internet companies use recommender systems within their core business.

During the preparation for a talk on the Netflix architecture I learned that nearly all the features on the streaming platform are individualized. It aroused my interest in this topic in general. Netflix tries to recommend the most relevant movies, series, advertisements, and overall page to the users. From a set of dozens of images from one movie it even selects one that is most likely clicked. …


Basics of the internet of things

Image for post
Image for post
Connecting things (Source Unsplash, extended and adjusted by M. D. Korzec)

To connect hardware devices with the internet seems often like a good and at first sight like a simple idea. Everyone wants to digitalize. You can monitor what your devices are doing — great. You can gain insights over your product and/or the customers, and you can react on the service or business level if needed — perfect.

However, around 3 out of 4 IoT projects fail according to a recent report.

When every company has become agile, which is supposed to reduce the number of failing software projects, why is the number so high? …


Implementation of a website for similar image recommendations based on convolutional neural networks in PyTorch

Image for post
Image for post
Image gallery and recommendations to a selected image (source: M. D. Korzec)

After creating a Python-based machine learning application you might want to get it running on a website.

In this article it is explained how this can be realized with the microframework Flask for an image-based recommender system.

We implement an image gallery on a website, the images can be selected, and similar images are displayed. Such a solution could be employed for example in online shops.

The similarities are obtained by comparing feature vectors derived with a pretrained Resnet18 network as explained in a previous article. The results from this work are Pandas dataframes (essentially tables) with the names of most similar images and similarity values between zero (not similar) and one (most similar) for each image. …


Image for post
Image for post
Photo by Wesley Tingey on Unsplash

When it comes to product owning there is no manual that guides you through the creation of successful software. You need to stay curious and eager to learn as you work with people that have their own quirks, expectations, and experiences while working on products that are unique.

As product owner you have to deliver good business results, analyze and develop the business case, display leadership, specify and communicate valuable user stories. You have a vast amount of responsibilities and there are many pitfalls on this challenging path.

Let me share 7 tips that I learned over 7 years as product owner in the automotive industry within several multi-enterprise B2B projects. …


Full transfer learning implementation with Resnet18

Image for post
Image for post
Found similar images using Resnet18 features (Source: M. D. Korzec)

In my last article we introduced the simple logic to create recommendations for similar images within large sets based on the image content by employing transfer learning.

Now let us create a prototypical implementation in Python using the pretrained Resnet18 convolutional neural network in PyTorch. It will take the content of an image folder and create top-k lists with k most similar images to the input.

The basic implementation for a simple recommender that uses the Resnet18 net for a fixed set of images will be derived in the following steps

0. Theory rewind: Image recommender logic

1. Rescale data

2. Use the pretrained Resnet18 network as feature vector…


Using features from pretrained convolutional neural networks to generate comparability

Similar images found within the test set, palaces, forest images and Cathedral in Berlin during the light festival
Similar images found within the test set, palaces, forest images and Cathedral in Berlin during the light festival
Automatically selected similar images (Source: M. D. Korzec)

Let us solve the problem of having an unsorted, huge set of images out of which we want to find a subset of similar images. The solution results in an image-based item-item recommender system that can be used for example in online-shops. To this aim, we will use transfer learning, utilizing pre-trained convolutional neural networks.

About

Maciej D. Korzec

Data Science Enthusiast, Product Management Devotee and Mathematician at Heart

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store