Created
October 15, 2019 16:14
-
-
Save aymericdelab/482c789f011ed219d8ebdc6db7ef4322 to your computer and use it in GitHub Desktop.
deploy your model on sagemaker and check if it works
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"predictor = estimator.deploy(initial_instance_count=1, \n", | |
" instance_type='ml.p2.xlarge',\n", | |
" endpoint_name='founder-classifier-endpoint')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import cv2\n", | |
"import numpy as np\n", | |
"\n", | |
"#lets test if the endpoint works by throwing it some image\n", | |
"location='./data/bing/Jeff Bezos/faces_28x28/Jeff_Bezos_100.jpg'\n", | |
"image=cv2.imread(location, cv2.IMREAD_GRAYSCALE)\n", | |
"image=np.array(image, dtype='float64').reshape([-1,28,28,1])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"predictor.predict({'x': image})" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 45, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"sagemaker.Session().delete_endpoint(predictor.endpoint)" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "conda_tensorflow_p36", | |
"language": "python", | |
"name": "conda_tensorflow_p36" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment