Skip to content

Commit d4863fa

Browse files
committed
trying to get around the bumpy hanging
1 parent 544c7b2 commit d4863fa

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ In the EC2 console, launch a new instance with:
6161
yum update -y
6262
yum install -y git cmake gcc-c++ gcc python-devel chrpath
6363

64+
pip install --upgrade pip
65+
6466
cd /tmp
6567
wget https://github.com/dudash/aws-lambda-python-opencv/archive/master.zip
6668
unzip master.zip

build.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/bin/bash
22

3-
# Setting up build env
3+
echo "+++build.sh+++ Setting up build env"
44
sudo yum update -y
55
sudo yum install -y git cmake gcc-c++ gcc python-devel chrpath
66
mkdir -p lambda-package/cv2 lambda-package/dlib build/numpy build/dlib
77

8-
# download and make patchelf - this will let us quickly update dlib.so's LD_LIBRARY path
8+
echo "+++build.sh+++ download and make patchelf - this will let us quickly update LD_LIBRARY paths"
99
mkdir -p build/patchelf
1010
(
1111
cd build/patchelf
@@ -14,7 +14,7 @@ tar xvfj patchelf-0.9.tar.bz2
1414
cd patchelf-0.9 && ./configure && make && sudo make install
1515
)
1616

17-
# Build numpy
17+
echo "+++build.sh+++ Build numpy"
1818
sudo yum -y install blas
1919
sudo yum -y install lapack
2020
sudo yum -y install atlas-sse3-devel
@@ -32,7 +32,7 @@ cp /usr/lib64/libgfortran.so.3 lambda-package/lib/.
3232
cp /usr/lib64/libquadmath.so.0 lambda-package/lib/.
3333
#find "lambda-package/numpy/" -name "**.so" | xargs strip
3434

35-
# Build OpenCV 3.2
35+
echo "+++build.sh+++ Build OpenCV 3.2"
3636
(
3737
NUMPY=$PWD/lambda-package/numpy/core/include
3838
cd build
@@ -57,13 +57,14 @@ cp /usr/lib64/libquadmath.so.0 lambda-package/lib/.
5757
.
5858
make -j`cat /proc/cpuinfo | grep MHz | wc -l`
5959
)
60+
echo "+++build.sh+++ done with opencv build, packaging it"
6061
cp build/opencv/lib/cv2.so lambda-package/cv2/__init__.so
6162
cp -L build/opencv/lib/*.so.3.2 lambda-package/cv2
6263
strip --strip-all lambda-package/cv2/*
6364
chrpath -r '$ORIGIN' lambda-package/cv2/__init__.so
6465
touch lambda-package/cv2/__init__.py
6566

66-
# build dlib and add an init module file for python
67+
echo "+++build.sh+++ Build dlib and add an init module file for python"
6768
sudo yum install -y blas-devel boost-devel lapack-devel
6869
(
6970
cd build
@@ -74,17 +75,21 @@ sudo yum install -y blas-devel boost-devel lapack-devel
7475
cmake -D USE_SSE4_INSTRUCTIONS:BOOL=ON ../../tools/python
7576
cmake --build . --config Release --target install
7677
)
78+
echo "+++build.sh+++ done with dlib build, packaging it"
7779
cp build/dlib/python_examples/dlib.so lambda-package/dlib/__init__.so
7880
cp /usr/lib64/libboost_python-mt.so.1.53.0 lambda-package/dlib/
7981
touch lambda-package/dlib/__init__.py
8082
patchelf --set-rpath '$ORIGIN' lambda-package/dlib/__init__.so
8183

84+
echo "+++build.sh+++ wgetting shape_predictor data"
8285
# This shape_predictor for dlib is useful for face recognition
8386
wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
8487
bzip2 -d shape_predictor_68_face_landmarks.dat.bz2
8588
mv shape_predictor_68_face_landmarks.dat lambda-package/shape_predictor_68_face_landmarks.dat
8689

87-
# Copy python function and zip
90+
echo "+++build.sh+++ Copying everything and zipping"
8891
cp lambda_function.py lambda-package/lambda_function.py
8992
cd lambda-package
9093
zip -r ../lambda-package.zip *
94+
95+
echo "+++build.sh+++ DONE"

lambda_function.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ def lambda_handler(event, context):
2424
print "OpenCV version=", cv2.__version__
2525
print "np version=", np.__version__
2626
print "context=", context
27+
print "event=", event
28+
29+
#image_key = event.Records[0].s3.object.key;
30+
#print image_key
31+
2732
return "yay, it works!"
2833

2934
if __name__ == "__main__":

0 commit comments

Comments
 (0)