References:
http://stackoverflow.com/questions/33588262/tesseract-ocr-on-aws-lambda-via-virtualenv
### 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 |
[...] | |
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] |
service: datmo-sklearn-iris | |
frameworkVersion: ">=1.2.0 <2.0.0" | |
provider: | |
name: aws | |
runtime: python2.7 | |
memorySize: 256 | |
timeout: 15 | |
stage: staging |
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" |
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 |
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') |
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 \ |