-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
116 changed files
with
315 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Define global args | ||
# ARG FUNCTION_DIR="/tmp/" | ||
# ARG FUNCTION_DIR=${LAMBDA_TASK_ROOT} | ||
ARG FUNCTION_DIR="/home/app/" | ||
ARG RUNTIME_VERSION="3.8" | ||
ARG DISTRO_VERSION="3.12" | ||
|
||
# Stage 1 - bundle base image + runtime | ||
# Grab a fresh copy of the image and install GCC | ||
FROM python:${RUNTIME_VERSION} AS python-alpine | ||
# Install GCC (Alpine uses musl but we compile and link dependencies with GCC) | ||
#RUN apk add --no-cache \ | ||
# libstdc++ | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y cmake ca-certificates libgl1-mesa-glx | ||
RUN python${RUNTIME_VERSION} -m pip install --upgrade pip | ||
|
||
# Stage 2 - build function and dependencies | ||
FROM python-alpine AS build-image | ||
# Install aws-lambda-cpp build dependencies | ||
#RUN apk add --no-cache \ | ||
# build-base \ | ||
# libtool \ | ||
# autoconf \ | ||
# automake \ | ||
# libexecinfo-dev \ | ||
# make \ | ||
# cmake \ | ||
# libcurl | ||
# Include global args in this stage of the build | ||
ARG FUNCTION_DIR | ||
ARG RUNTIME_VERSION | ||
# Create function directory | ||
RUN mkdir -p ${FUNCTION_DIR} | ||
|
||
# Optional – Install the function's dependencies | ||
# RUN python${RUNTIME_VERSION} -m pip install -r requirements.txt --target ${FUNCTION_DIR} | ||
# Install Lambda Runtime Interface Client for Python | ||
RUN python${RUNTIME_VERSION} -m pip install awslambdaric --target ${FUNCTION_DIR} | ||
|
||
# Stage 3 - final runtime image | ||
# Grab a fresh copy of the Python image | ||
FROM python-alpine | ||
# Include global arg in this stage of the build | ||
ARG FUNCTION_DIR | ||
# Set working directory to function root directory | ||
WORKDIR ${FUNCTION_DIR} | ||
# Copy in the built dependencies | ||
COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR} | ||
# (Optional) Add Lambda Runtime Interface Emulator and use a script in the ENTRYPOINT for simpler local runs | ||
ADD https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie /usr/bin/aws-lambda-rie | ||
RUN chmod 755 /usr/bin/aws-lambda-rie | ||
|
||
# Install ffmpeg | ||
RUN apt-get install -y ffmpeg | ||
|
||
# Copy handler function | ||
COPY requirements.txt ${FUNCTION_DIR} | ||
RUN python${RUNTIME_VERSION} -m pip install -r requirements.txt --target ${FUNCTION_DIR} | ||
COPY entry.sh / | ||
|
||
# Copy function code | ||
COPY handler.py ${FUNCTION_DIR} | ||
RUN chmod 777 /entry.sh | ||
|
||
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) | ||
# CMD [ "handler.handler" ] | ||
ENTRYPOINT [ "/entry.sh" ] | ||
CMD [ "handler.face_recognition_handler" ] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
if [ -z "${AWS_LAMBDA_RUNTIME_API}" ]; then | ||
exec /usr/bin/aws-lambda-rie /usr/local/bin/python -m awslambdaric $1 | ||
else | ||
exec /usr/local/bin/python -m awslambdaric $1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from boto3 import client as boto3_client | ||
import face_recognition | ||
import pickle | ||
|
||
input_bucket = "546proj2" | ||
output_bucket = "546proj2output" | ||
|
||
# Function to read the 'encoding' file | ||
def open_encoding(filename): | ||
file = open(filename, "rb") | ||
data = pickle.load(file) | ||
file.close() | ||
return data | ||
|
||
def face_recognition_handler(event, context): | ||
print("Hello") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
test_5.mp4:computer_science,sophomore | ||
test_13.mp4:computer_science,sophomore | ||
test_21.mp4:computer_science,sophomore | ||
test_29.mp4:computer_science,sophomore | ||
test_37.mp4:computer_science,sophomore | ||
test_45.mp4:computer_science,sophomore | ||
test_53.mp4:computer_science,sophomore | ||
test_61.mp4:computer_science,sophomore | ||
test_69.mp4:computer_science,sophomore | ||
test_77.mp4:computer_science,sophomore | ||
test_85.mp4:computer_science,sophomore | ||
test_93.mp4:computer_science,sophomore | ||
test_8.mp4:electrical_engineering,senior | ||
test_16.mp4:electrical_engineering,senior | ||
test_24.mp4:electrical_engineering,senior | ||
test_32.mp4:electrical_engineering,senior | ||
test_40.mp4:electrical_engineering,senior | ||
test_48.mp4:electrical_engineering,senior | ||
test_56.mp4:electrical_engineering,senior | ||
test_64.mp4:electrical_engineering,senior | ||
test_72.mp4:electrical_engineering,senior | ||
test_80.mp4:electrical_engineering,senior | ||
test_88.mp4:electrical_engineering,senior | ||
test_96.mp4:electrical_engineering,senior | ||
test_0.mp4:physics,junior | ||
test_9.mp4:physics,junior | ||
test_17.mp4:physics,junior | ||
test_25.mp4:physics,junior | ||
test_33.mp4:physics,junior | ||
test_41.mp4:physics,junior | ||
test_49.mp4:physics,junior | ||
test_57.mp4:physics,junior | ||
test_65.mp4:physics,junior | ||
test_73.mp4:physics,junior | ||
test_81.mp4:physics,junior | ||
test_89.mp4:physics,junior | ||
test_97.mp4:physics,junior | ||
test_7.mp4:math,senior | ||
test_15.mp4:math,senior | ||
test_23.mp4:math,senior | ||
test_31.mp4:math,senior | ||
test_39.mp4:math,senior | ||
test_47.mp4:math,senior | ||
test_55.mp4:math,senior | ||
test_63.mp4:math,senior | ||
test_71.mp4:math,senior | ||
test_79.mp4:math,senior | ||
test_87.mp4:math,senior | ||
test_95.mp4:math,senior | ||
test_1.mp4:history,sophomore | ||
test_10.mp4:history,sophomore | ||
test_18.mp4:history,sophomore | ||
test_26.mp4:history,sophomore | ||
test_34.mp4:history,sophomore | ||
test_42.mp4:history,sophomore | ||
test_50.mp4:history,sophomore | ||
test_58.mp4:history,sophomore | ||
test_66.mp4:history,sophomore | ||
test_74.mp4:history,sophomore | ||
test_82.mp4:history,sophomore | ||
test_90.mp4:history,sophomore | ||
test_98.mp4:history,sophomore | ||
test_4.mp4:computer_science,senior | ||
test_12.mp4:computer_science,senior | ||
test_20.mp4:computer_science,senior | ||
test_28.mp4:computer_science,senior | ||
test_36.mp4:computer_science,senior | ||
test_44.mp4:computer_science,senior | ||
test_52.mp4:computer_science,senior | ||
test_60.mp4:computer_science,senior | ||
test_68.mp4:computer_science,senior | ||
test_76.mp4:computer_science,senior | ||
test_84.mp4:computer_science,senior | ||
test_92.mp4:computer_science,senior | ||
test_6.mp4:history,junior | ||
test_14.mp4:history,junior | ||
test_22.mp4:history,junior | ||
test_30.mp4:history,junior | ||
test_38.mp4:history,junior | ||
test_46.mp4:history,junior | ||
test_54.mp4:history,junior | ||
test_62.mp4:history,junior | ||
test_70.mp4:history,junior | ||
test_78.mp4:history,junior | ||
test_86.mp4:history,junior | ||
test_94.mp4:history,junior | ||
test_2.mp4:lawyer,freshman | ||
test_11.mp4:lawyer,freshman | ||
test_19.mp4:lawyer,freshman | ||
test_27.mp4:lawyer,freshman | ||
test_35.mp4:lawyer,freshman | ||
test_43.mp4:lawyer,freshman | ||
test_51.mp4:lawyer,freshman | ||
test_59.mp4:lawyer,freshman | ||
test_67.mp4:lawyer,freshman | ||
test_75.mp4:lawyer,freshman | ||
test_83.mp4:lawyer,freshman | ||
test_91.mp4:lawyer,freshman | ||
test_99.mp4:lawyer,freshman | ||
test_100.mp4:lawyer,freshman |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
boto3 | ||
dlib | ||
numpy | ||
face_recognition | ||
opencv-python | ||
ffmpeg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
[ | ||
{ | ||
"id": 1, | ||
"name": "mr_bean", | ||
"major": "lawyer", | ||
"year": "freshmen" | ||
}, | ||
{ | ||
"id": 2, | ||
"name": "president_biden", | ||
"major": "history", | ||
"year": "sophomore" | ||
}, | ||
{ | ||
"id": 3, | ||
"name": "vin_diesel", | ||
"major": "computer_science", | ||
"year": "sophomore" | ||
}, | ||
{ | ||
"id": 4, | ||
"name": "floki", | ||
"major": "history", | ||
"year": "junior" | ||
}, | ||
{ | ||
"id": 5, | ||
"name": "president_trump", | ||
"major": "physics", | ||
"year": "junior" | ||
}, | ||
{ | ||
"id": 6, | ||
"name": "morgan_freeman", | ||
"major": "math", | ||
"year": "senior" | ||
}, | ||
{ | ||
"id": 7, | ||
"name": "president_obama", | ||
"major": "electrical_engineering", | ||
"year": "senior" | ||
}, | ||
{ | ||
"id": 8, | ||
"name": "johnny_dep", | ||
"major": "computer_science", | ||
"year": "senior" | ||
} | ||
] |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from boto3 import client as boto3_client | ||
import os | ||
|
||
input_bucket = "546proj2" | ||
output_bucket = "546proj2output" | ||
test_cases = "test_cases/" | ||
|
||
def clear_input_bucket(): | ||
global input_bucket | ||
s3 = boto3_client('s3') | ||
list_obj = s3.list_objects_v2(Bucket=input_bucket) | ||
try: | ||
for item in list_obj["Contents"]: | ||
key = item["Key"] | ||
s3.delete_object(Bucket=input_bucket, Key=key) | ||
except: | ||
print("Nothing to clear in input bucket") | ||
|
||
def clear_output_bucket(): | ||
global output_bucket | ||
s3 = boto3_client('s3') | ||
list_obj = s3.list_objects_v2(Bucket=output_bucket) | ||
try: | ||
for item in list_obj["Contents"]: | ||
key = item["Key"] | ||
s3.delete_object(Bucket=output_bucket, Key=key) | ||
except: | ||
print("Nothing to clear in output bucket") | ||
|
||
def upload_to_input_bucket_s3(path, name): | ||
global input_bucket | ||
s3 = boto3_client('s3') | ||
s3.upload_file(path + name, input_bucket, name) | ||
|
||
|
||
def upload_files(test_case): | ||
global input_bucket | ||
global output_bucket | ||
global test_cases | ||
|
||
|
||
# Directory of test case | ||
test_dir = test_cases + test_case + "/" | ||
|
||
# Iterate over each video | ||
# Upload to S3 input bucket | ||
for filename in os.listdir(test_dir): | ||
if filename.endswith(".mp4") or filename.endswith(".MP4"): | ||
print("Uploading to input bucket.. name: " + str(filename)) | ||
upload_to_input_bucket_s3(test_dir, filename) | ||
|
||
|
||
def workload_generator(): | ||
|
||
print("Running Test Case 1") | ||
upload_files("test_case_1") | ||
|
||
print("Running Test Case 2") | ||
upload_files("test_case_2") | ||
|
||
|
||
# clear_input_bucket() | ||
clear_output_bucket() | ||
workload_generator() | ||
|
||
|
||
|