Skip to content

Instantly share code, notes, and snippets.

View shabazpatel's full-sized avatar

Shabaz Patel shabazpatel

View GitHub Profile
### Steps:
1. Clone this github [project](!https://github.com/datmo/hello-world.git),
```
$ git clone https://github.com/datmo/hello-world.git
```
2. Move into the project and initialize it and setup the environment using datmo CLI,
```
$ cd hello-world
@shabazpatel
shabazpatel / service.py
Created June 14, 2018 01:38
Code for serverless deployments
[...]
def handler(event, context):
# take input pd data frame and return dictionary with classificaiton
input = json.loads(event['body'])['input']
output_response = {"statusCode": 200, "headers": {"Content-Type": "application/json"}}
try:
# Inference
y_pred = iris_model.predict(input)
y_pred = [round(value) for value in y_pred]
@shabazpatel
shabazpatel / datmo-deploy-2.yml
Created June 12, 2018 19:56
Config file for serverless deployments
service: datmo-sklearn-iris
frameworkVersion: ">=1.2.0 <2.0.0"
provider:
name: aws
runtime: python2.7
memorySize: 256
timeout: 15
stage: staging
@shabazpatel
shabazpatel / datmo-deploy-1.yml
Last active June 12, 2018 19:56
Config file for containerized deployments
version: "1"
deploy:
service_route: "/shabazp/imagnet-resnet/snapshot_id"
celery_services:
worker_path: "tasks.py"
methods:
- predict
worker_config:
worker_prefetch_multiplier: 20
environment: "./Dockerfile"
@shabazpatel
shabazpatel / iris_predict.py
Created June 12, 2018 02:02
Prediction using a sklearn based model trained on Iris data set
import pickle
import random
random.seed(3)
iris_model = None
Species_class_map = None
def load_iris_model():
# load the pre-trained Iris model (here we are using a model
# pre-trained on Iris Classification using sklearn
@shabazpatel
shabazpatel / imagenet_predict.py
Created June 12, 2018 01:57
Prediction using a resnet152 layered classifier trained over imagenet dataset
import os
import mxnet as mx
path='http://data.mxnet.io/models/imagenet-11k/'
if not os.path.exists('resnet-152-symbol.json'):
mx.test_utils.download(path+'resnet-152/resnet-152-symbol.json')
if not os.path.exists('resnet-152-0000.params'):
mx.test_utils.download(path+'resnet-152/resnet-152-0000.params')
if not os.path.exists('synset.txt'):
mx.test_utils.download(path+'synset.txt')
@shabazpatel
shabazpatel / Dockerfile.example
Last active April 6, 2018 00:38
Dockerfile used for iris model deployment
FROM cloudgear/ubuntu:14.04
MAINTAINER Datmo devs <dev@datmo.io>
RUN apt-get update; \
apt-get install -y \
python python-pip \
build-essential \
python-dev \
python-setuptools \