MikeTheWatchGuy / color-extractor-service

Extract a color palette from an image.

Home Page:https://colors.rmotr.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Color Palette extraction (as a service)

Live Demo

This is a simple project to demonstrate the usage of unsupervised Machine Learning methods (clustering with scikit-learn KMeans) to extract colors from images.

How it works

Theres a Jupyter Notebook with a step by step explanation in this same repo: demo/Extract colors from images.ipynb

Usage

There's a simple API endpoint to use it as a service: /api/extract. It accepts two different types of requests:

Providing a URL

A JSON POST request with two parameters:

  • url (mandatory): The URL of the picture to extract colors from
  • clusters (optional): The number of clusters to use (default=6)
Example:
$ curl -X POST -d '{"url": "https://images.unsplash.com/photo-1536506591919-966afe6f7c09?fit=crop&w=750&q=80"}' -H "Content-Type: application/json" https://colors.rmotr.com/api/extract

Providing a File

A multipart/form-data request with two form values:

  • file (mandatory): The image file to extract colors from
  • clusters (optional): The number of clusters to use (default=6)
Example
$ curl -X POST -F "file=@demo/sample-image-1.jpg" -F "clusters=7" http://localhost:5000/api/extract

Authors

Frontend magic by:

Image Credits

Sample images from unsplash:

About

Extract a color palette from an image.

https://colors.rmotr.com/


Languages

Language:JavaScript 26.4%Language:Python 25.7%Language:CSS 25.0%Language:HTML 22.9%