Or, I just trained a machine learning model - now what?
This post goes over a quick and dirty way to deploy a trained machine learning model to production.
Read this if: You've successfully trained a ML model using an ML framework such as tensorflow or Caffe that you would like to put up as a demo, preferably sooner rather than later, and you prefer lighter solutions rather than spinning up an entire tech stack.
Reading time: 10-15 mins
TL;DR check out the repo
Check your tensorflow installation
Run online classification from stdin
Run online classification on localhost
Put classifiers behind a hardcoded proxy
Put classifiers behind a proxy with service discovery
Call classifiers using a pseudo-DNS
ML in production
When we first entered the machine learning space here at Hive, we already had millions of ground truth labeled images, allowing us to train a state-of-the-art deep convolutional image classification model from scratch (i.e. randomized weights) in under a week, specialized for our use case. The more typical ML use case, though, is usually on the order of hundreds of images, for which I would recommend fine-tuning an existing model. For instance, https://www.tensorflow.org/tutorials/image_retraining has a great tutorial on how to fine-tune an Imagenet model (trained on 1.2M images, 1000 classes) to classify a sample dataset of flowers (3647 images, 5 classes).
For a quick tl;dr of the linked Tensorflow tutorial, after installing bazel and tensorflow, you would need to run the following code, which takes around 30 mins to build and 5 minutes to train: