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
FROM ubuntu:16.04 | |
RUN apt-get update && \ | |
apt-get -y install build-essential libopencv-dev libopenblas-dev libjemalloc-dev libgfortran3 \ | |
python-dev python3-dev python3-pip wget curl | |
COPY mnist_cnn.py /opt/program/train | |
RUN chmod +x /opt/program/train | |
RUN mkdir /root/.keras |
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
# Interaction model | |
{ | |
"name": "TranslateIntent", | |
"slots": [ | |
{ | |
"name": "Language", | |
"type": "AMAZON.Language" | |
} | |
], | |
"samples": [ |
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
# TranslateApi.py | |
def translateText(translate, text, source, target): | |
response = translate.translate_text(Text=text, SourceLanguageCode=source, TargetLanguageCode=target) | |
return response['TranslatedText'] | |
# server.py | |
elif message.payload.startswith("translate"): | |
src_language_code = ComprehendApi.detectLanguage(comprehend, text) | |
dest_language = message.payload.split(' ')[1] | |
dest_language_code = language_info[dest_language]['code'] |
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
# Interaction model | |
{ | |
"name": "ReadIntent", | |
"slots": [], | |
"samples": [ | |
"what's written here", | |
"what is this text", | |
"Read this text", | |
"Can you read this", | |
"Read this" |
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
# RekognitionApi.py | |
def detectText(rekognition, imageFilename, imageBucket=defaultBucket): | |
response = rekognition.detect_text( | |
Image={'S3Object': {'Bucket':imageBucket, 'Name':imageFilename}}) | |
text = '' | |
for t in response['TextDetections']: | |
if t['Type'] == 'LINE': | |
text = text+t['DetectedText']+' ' | |
return text | |
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
# Interaction model | |
{ | |
"name": "LanguageIntent", | |
"slots": [], | |
"samples": [ | |
"what language this is", | |
"Tell me which language this is", | |
"What's this language", | |
"Which language is this" | |
] |
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
# ComprehendApi.py | |
def detectLanguage(client,text): | |
resp = client.detect_dominant_language(Text=text) | |
return resp['Languages'][0]['LanguageCode'] | |
# server.py | |
language_name = {'en':'English', 'fr':'French', 'de':'German', 'es':'Spanish'} | |
... | |
if message.payload.startswith("language"): | |
language_code = ComprehendApi.detectLanguage(comprehend, text) |
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
# RekokgnitionApi.py | |
def detectCelebrities(rekognition, imageFilename, imageBucket=defaultBucket): | |
resp = rekognition.recognize_celebrities( | |
Image = {"S3Object" : {'Bucket' : imageBucket, 'Name' : imageFilename}}) | |
return resp['CelebrityFaces'] | |
# RekokgnitionUtils.py | |
def generateMessages(faceCounter, celebs, labels): | |
if (faceCounter == 0): | |
faceMessage = "No face has been detected, sorry." |
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
$ serverless deploy | |
<output removed> | |
Service Information | |
service: sagemakerscheduler | |
stage: dev | |
region: us-east-1 | |
stack: sagemakerscheduler-dev | |
api keys: | |
None | |
endpoints: |
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
import boto3, os, datetime | |
def main(event, context): | |
training_job_name = os.environ['training_job_name'] | |
sm = boto3.client('sagemaker') | |
job = sm.describe_training_job(TrainingJobName=training_job_name) | |
training_job_prefix = os.environ['training_job_prefix'] |