pvhee / deeplearning_experiments

Deep Learning training repository
0 stars 0 forks source link

Industrialise code by having it run on-demand on Google Cloud #3

Open pvhee opened 7 years ago

pvhee commented 7 years ago

Good reads

pvhee commented 7 years ago

Also consider AWS, see https://aws.amazon.com/about-aws/whats-new/2017/10/aws-deep-learning-ami-now-supports-pytorch-keras-2-and-latest-deep-learning-frameworks/

--> we can probably use Sagemaker https://aws.amazon.com/sagemaker/ so no need to use gcloud

pvhee commented 6 years ago

For Google, we can turn Keras model into a TensorFlow estimator, then serve predictions using TensorFlow Serving as per https://cloud.google.com/blog/big-data/2017/12/new-in-tensorflow-14-converting-a-keras-model-to-a-tensorflow-estimator

pvhee commented 6 years ago

Having issues with exporting our model (into a directory) as our input receiver function is incorrect. To help debug this, it is useful to inspect the SavedModel using

saved_model_cli show --dir export/1521414113/ --tag_set serve --signature_def serving_default

which returns

The given SavedModel SignatureDef contains the following input(s):
inputs['examples'] tensor_info:
    dtype: DT_STRING
    shape: (-1)
    name: input_example_tensor:0
The given SavedModel SignatureDef contains the following output(s):
outputs['labels'] tensor_info:
    dtype: DT_FLOAT
    shape: (-1, 6, 11)
    name: labels/truediv:0
Method name is: tensorflow/serving/predict
pvhee commented 6 years ago

Options around sending image data as input: https://stackoverflow.com/questions/46216095/using-gcloud-ml-serving-for-large-images/46222990#46222990

pvhee commented 6 years ago

Convert an image (daisy.jpg) into b64 encoded JSON string

python -c 'import base64, sys, json; img = base64.b64encode(open(sys.argv[1], "rb").read()); print json.dumps({"key":"0", "image_bytes": {"b64": img}})' daisy.jpg

pvhee commented 6 years ago

Latest update: we can generate predictions using Cloud ML Prediction API via https://github.com/pvhee/deeplearning_experiments/blob/master/svhn/predict_gcloud.py. This returns for example

python -m svhn.predict_gcloud
[ 2  3  4 10 10 10]
[ 3  2  1  5 10 10]
[ 4  1  0  3 10 10]
[ 3  1  1  0 10 10]
[ 2  1  0 10 10 10]

✌️

Next up are:

Almost there... 👍