Create and Deploy a REST API Extracting Predominant Colors from Images | by Nicolo Cosimo Albanese | Sep, 2023

Using unsupervised machine learning, FastAPI and Docker

Image by author.
  1. Problem statement
  2. Extract colors from images
  3. Project structure
  4. Code
  5. Deploy the Docker container
  6. Let’s try it!
  7. API documentation
  8. Conclusions
  9. License disclaimer

Let us imagine a control room of a manufacturing facility, where the fabricated products need to be sorted automatically. For instance, based on their color, goods may be redirected to different branches of a roller conveyor for further processing or packaging.

Otherwise, we can also imagine an online retailer trying to enhance the user experience by adding a search-by-color functionality. Customers may more easily find a clothing item from a particular color, thus simplifying their access to products of interest.

Or, just like the author, you can picture yourself as an IT consultant implementing a simple, fast and reusable tool to generate color palettes for presentations, charts and apps from input images.

These are just few examples of how extracting the main colors from a picture may either improve operational efficiency or boost customer experience.

In this blog post, we use Python to implement the extraction of predominant colors from a given picture. Then, we use FastAPI and Docker to package and deploy the solution as a service.

The purpose of this post is to share an end-to-end illustration about the deployment of a lightweight and self-consistent service leveraging Machine Learning techniques to carry out a business purpose. Such a service may be easily integrated in a microservice architecture.

A digital image is essentially a 2-dimensional grid of individual components known as pixels. Pixels are the smallest unit of display in the image, and carry information about its color. A…

Source link

Be the first to comment

Leave a Reply

Your email address will not be published.