Git Product home page Git Product logo

aws-lambda-python-opencv's Introduction

Python OpenCV module for AWS Lambda

Simple Mustache Service demo
Simple Mustache Service is an AWS Lambda demo that uses this module

Description

This is a simple script that builds a deployment package including OpenCV compatible with the AWS Lambda Python runtime. The dynamic library is compiled with all extended instruction sets supported by Lambda CPU and binaries are stripped to save space. You simply need to add your code inside lambda_function.py and possibly your haar cascades files or additional Python modules. You can directly download a pre-built archive.

  • Build duration: ~20 min on T2.micro / ~15 min on C4.2xlarge
  • Package size without haar cascades included: 26MB
  • OpenCV 3.2 by default but may work with newer

Needs to be built on an Amazon Linux instance.

Module building

Option 1: with an existing instance

  • Download the repo wget https://github.com/aeddi/aws-lambda-python-opencv/archive/master.zip
  • Unzip the archive unzip master.zip
  • Launch the script cd aws-lambda-python-opencv-master && ./build.sh

Option 2: without an existing instance

In the EC2 console, launch a new instance with:

  • Amazon Linux AMI
  • Role with S3 write permission
  • Shutdown behavior: Terminate
  • Paste the script below in the user data text field
#!/bin/bash
yum update -y
yum install -y git cmake gcc-c++ gcc python-devel chrpath

cd /tmp
wget https://github.com/aeddi/aws-lambda-python-opencv/archive/master.zip
unzip master.zip
chmod 777 aws-lambda-python-opencv-master
cd aws-lambda-python-opencv-master
su -c './build.sh' ec2-user

aws s3 cp lambda-package.zip s3://<my-target-bucket>
shutdown -h now
  • Replace my-target-bucket by a bucket or your choice
  • Less than 30 min later the instance will be terminated and the archive will be available on your bucket

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.