Skip to content

Commit 28872ca

Browse files
committed
tweaks
1 parent bd80b18 commit 28872ca

File tree

5 files changed

+222
-32
lines changed

5 files changed

+222
-32
lines changed

.editorconfig

Lines changed: 0 additions & 10 deletions
This file was deleted.

.gitignore

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
masked
2+
scary_masks
3+
*.swp
4+
env
5+
_*
6+
shape_predictor*
7+
group.jpg
8+
leonpass.jpg
9+
.DS_Store
10+
shape_predictor_68_face_landmarks.dat
11+
*.dat
12+
13+
14+
env/
15+
*.pyc
16+
*.json
17+
*.mp4
18+
*.html
19+
*.pdf
20+
data/
21+
eyefield/
22+
eyefield2/
23+
eyes/
24+
images/
25+
people/
26+
27+
reated by https://www.gitignore.io/api/osx,python,opencv,virtualenv
28+
29+
### OpenCV ###
30+
#OpenCV for Mac and Linux
31+
#build and release folders
32+
*/CMakeFiles
33+
*/CMakeCache.txt
34+
*/Makefile
35+
*/cmake_install.cmake
36+
.DS_Store
37+
38+
### OSX ###
39+
*.DS_Store
40+
.AppleDouble
41+
.LSOverride
42+
43+
# Icon must end with two \r
44+
Icon
45+
46+
# Thumbnails
47+
._*
48+
49+
# Files that might appear in the root of a volume
50+
.DocumentRevisions-V100
51+
.fseventsd
52+
.Spotlight-V100
53+
.TemporaryItems
54+
.Trashes
55+
.VolumeIcon.icns
56+
.com.apple.timemachine.donotpresent
57+
58+
# Directories potentially created on remote AFP share
59+
.AppleDB
60+
.AppleDesktop
61+
Network Trash Folder
62+
Temporary Items
63+
.apdisk
64+
65+
### Python ###
66+
# Byte-compiled / optimized / DLL files
67+
__pycache__/
68+
*.py[cod]
69+
*$py.class
70+
71+
# C extensions
72+
*.so
73+
74+
# Distribution / packaging
75+
.Python
76+
env/
77+
build/
78+
develop-eggs/
79+
dist/
80+
downloads/
81+
eggs/
82+
.eggs/
83+
lib/
84+
lib64/
85+
parts/
86+
sdist/
87+
var/
88+
wheels/
89+
*.egg-info/
90+
.installed.cfg
91+
*.egg
92+
93+
# PyInstaller
94+
# Usually these files are written by a python script from a template
95+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
96+
*.manifest
97+
*.spec
98+
99+
# Installer logs
100+
pip-log.txt
101+
pip-delete-this-directory.txt
102+
103+
# Unit test / coverage reports
104+
htmlcov/
105+
.tox/
106+
.coverage
107+
.coverage.*
108+
.cache
109+
nosetests.xml
110+
coverage.xml
111+
*,cover
112+
.hypothesis/
113+
114+
# Translations
115+
*.mo
116+
*.pot
117+
118+
# Django stuff:
119+
*.log
120+
local_settings.py
121+
122+
# Flask stuff:
123+
instance/
124+
.webassets-cache
125+
126+
# Scrapy stuff:
127+
.scrapy
128+
129+
# Sphinx documentation
130+
docs/_build/
131+
132+
# PyBuilder
133+
target/
134+
135+
# Jupyter Notebook
136+
.ipynb_checkpoints
137+
138+
# pyenv
139+
.python-version
140+
141+
# celery beat schedule file
142+
celerybeat-schedule
143+
144+
# SageMath parsed files
145+
*.sage.py
146+
147+
# dotenv
148+
.env
149+
150+
# virtualenv
151+
.venv
152+
venv/
153+
ENV/
154+
155+
# Spyder project settings
156+
.spyderproject
157+
.spyproject
158+
159+
# Rope project settings
160+
.ropeproject
161+
162+
# mkdocs documentation
163+
/site
164+
165+
### VirtualEnv ###
166+
# Virtualenv
167+
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
168+
[Bb]in
169+
[Ii]nclude
170+
[Ll]ib
171+
[Ll]ib64
172+
[Ll]ocal
173+
[Ss]cripts
174+
pyvenv.cfg
175+
pip-selfcheck.json
176+
177+
# End of https://www.gitignore.io/api/osx,python,opencv,virtualenv
178+
179+
180+
# Created by https://www.gitignore.io/api/vim
181+
#
182+
# ### Vim ###
183+
# # swap
184+
# [._]*.s[a-v][a-z]
185+
# [._]*.sw[a-p]
186+
# [._]s[a-v][a-z]
187+
# [._]sw[a-p]
188+
# # session
189+
# Session.vim
190+
# # temporary
191+
# .netrwhist
192+
# *~
193+
# # auto-generated tag files
194+
# tags
195+
#
196+
# # End of https://www.gitignore.io/api/vim

README.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
1-
# Python OpenCV module for AWS Lambda
2-
3-
<p align="center">
4-
<img src="http://i.imgur.com/70rGBsz.gif" alt="Simple Mustache Service demo"/><br>
5-
<i><b>Simple Mustache Service</b> is an AWS Lambda demo that uses this module</i>
6-
</p>
1+
# Python OpenCV+DLIB module for AWS Lambda
72

83
## Description
9-
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](https://github.com/aeddi/aws-lambda-python-opencv/releases/download/Prebuilt/aws-lambda-python-opencv-prebuilt.zip).
10-
11-
- Build duration: ~20 min on T2.micro / ~15 min on C4.2xlarge
12-
- Package size without haar cascades included: 26MB
13-
- OpenCV 3.2 by default but may work with newer
4+
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.
145

156
**Needs to be built on an Amazon Linux instance.**
167

178
## Module building
189
### Option 1: with an existing instance
19-
- Download the repo `wget https://github.com/aeddi/aws-lambda-python-opencv/archive/master.zip`
10+
- Download the repo `wget https://github.com/dudash/aws-lambda-python-opencv/archive/master.zip`
2011
- Unzip the archive `unzip master.zip`
2112
- Launch the script `cd aws-lambda-python-opencv-master && ./build.sh`
2213

@@ -32,7 +23,7 @@ yum update -y
3223
yum install -y git cmake gcc-c++ gcc python-devel chrpath
3324

3425
cd /tmp
35-
wget https://github.com/aeddi/aws-lambda-python-opencv/archive/master.zip
26+
wget https://github.com/dudash/aws-lambda-python-opencv/archive/master.zip
3627
unzip master.zip
3728
chmod 777 aws-lambda-python-opencv-master
3829
cd aws-lambda-python-opencv-master
@@ -41,5 +32,5 @@ su -c './build.sh' ec2-user
4132
aws s3 cp lambda-package.zip s3://<my-target-bucket>
4233
shutdown -h now
4334
```
44-
- Replace *my-target-bucket* by a bucket or your choice
35+
- Replace *my-target-bucket* by a bucket where you want to store this lambda function
4536
- Less than 30 min later the instance will be terminated and the archive will be available on your bucket

lambda_function.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import cv2
2+
import dlib
3+
import numpy as np
4+
import os
5+
import boto3
6+
7+
print os.environ
8+
9+
# Setup AWS access and S3 buckets
10+
S3OUTBUCKET = os.environ.get('S3OUTBUCKET')
11+
S3INBUCKET = os.environ.get('S3INBUCKET')
12+
s3 = boto3.resource('s3')
13+
for bucket in s3.buckets.all():
14+
print(bucket.name)
15+
16+
def lambda_handler(event, context):
17+
print "OpenCV installed version:", cv2.__version__
18+
return "It works!"
19+
20+
if __name__ == "__main__":
21+
lambda_handler(42, 42)

template.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)