Skip to content

Instantly share code, notes, and snippets.

View ankitshekhawat's full-sized avatar

Ankit Shekhawat ankitshekhawat

  • Bangalore, India
View GitHub Profile
@ankitshekhawat
ankitshekhawat / product.js
Created January 13, 2017 16:41 — forked from cybercase/product.js
Python-like itertools.product function in javascript
function product() {
var args = Array.prototype.slice.call(arguments); // makes array from arguments
return args.reduce(function tl (accumulator, value) {
var tmp = [];
accumulator.forEach(function (a0) {
value.forEach(function (a1) {
tmp.push(a0.concat(a1));
});
});
return tmp;
@ankitshekhawat
ankitshekhawat / export_tf_models.py
Created January 10, 2017 05:50
Export models and weights are trained in Keras to be used in TensorFlow Serving library
from keras import backend as K
import tensorflow as tf
from tensorflow.contrib.session_bundle import exporter
sess = K.get_session()
export_path ="."
export_version = 1
saver = tf.train.Saver(sharded=True)
### Code if you want to only export .meta files
@ankitshekhawat
ankitshekhawat / swatching.py
Last active January 9, 2023 19:59
A quick python code to detect color of an item from ecommerce website using just kmeans without OpenCV. Nowhere close to accurate but good for a quick hack. Can be improved with Sobel edge detection and skin detection.
import numpy as np
from PIL import Image, ImageDraw
import colorsys, random
from pylab import plot,show
from numpy import vstack,array
from numpy.random import rand
from scipy.cluster.vq import kmeans,vq
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import matplotlib.image as mpimg