Skip to content
Sample Python API using flask, uses PyTorch to cluster image vectors
Branch: master
Clone or download
Latest commit 5a944d4 May 31, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
csv update drug names May 31, 2018
.gitignore update drug names May 31, 2018
ImageMatch.apk android APK Apr 3, 2018
README.md Update README.md Apr 7, 2018
Requirements.txt reading vectors from csv. going to work towards reading test image at… Apr 1, 2018
cat.jpg removed uploading part Apr 1, 2018
cycle.jpg few more images added Apr 1, 2018
img_to_vec.py init commit Apr 1, 2018
rename.sh modulated csv files Apr 1, 2018
sample_python_script.py
trump.png few more images added Apr 1, 2018

README.md

k-means-clustering-api

Sample Python API using flask, uses PyTorch to cluster image vectors. Originally forked from here

Flask Logo PyTorch Logo Heroku Logo

How to use

Just make a PUT request here with base64 encoded image data using text/plain.

For python, refer sample python script.py

In Javascript/AJAX

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://beard-app.herokuapp.com/image_clustering",
  "method": "PUT",
  "headers": {
    "Content-Type": "text/plain"
  },
  "data": "/9j/4A....NpI//Z"   // This is base64 encoded image data

}

$.ajax(settings).done(function (response) {
  console.log(response);
});

Also, try the sample ImageMatch.apk android file

Sample Result

Sample Image

Image of a cat

[
  [
    0.8155140106062471, 
    "https://www.googleapis.com/download/storage/v1/b/python-clustering-api.appspot.com/o/images%2FFace%2F124.jpg?generation=1522585329188523&alt=media"
  ], 
  [
    0.8145577585207011, 
    "https://www.googleapis.com/download/storage/v1/b/python-clustering-api.appspot.com/o/images%2FFace%2F242.jpg?generation=1522585299229997&alt=media"
  ], 
  [
    0.7914929138145477, 
    "https://www.googleapis.com/download/storage/v1/b/python-clustering-api.appspot.com/o/images%2FFace%2F212.jpg?generation=1522584727478100&alt=media"
  ], 
  [
    0.7806927914191767, 
    "https://www.googleapis.com/download/storage/v1/b/python-clustering-api.appspot.com/o/images%2FFace%2F099.jpg?generation=1522585251917855&alt=media"
  ], 
  [
    0.6948463995381056, 
    "https://www.googleapis.com/download/storage/v1/b/python-clustering-api.appspot.com/o/images%2FFace%2F119.jpg?generation=1522584693369035&alt=media"
  ]
]
You can’t perform that action at this time.