Deploying a Model on Google AI Platform
STEP 1: Setup your Google Cloud Account
Assumes: you have google cloud account and billing credits setup. You create a new project and then enable the
AI platform API
STEP 2: In your project enable the AI platform and then go to Storage and create S3 (storage) Bucket --give it a meaningful name and upload the directory of your Tensorflow SavedModel : fill out name, region in cloud,
STEP 3: in newly created bucket upload the SavedModel you previously created --here is a tensorflow 1.14 python 3.5 CatDog CNN model
STEP 4: in your created project go back to AI Platform and choose create new model--you may choose
to enable logging for additional costs
>>then click on model and create a version and associate it with the model stored in your S3 bucket from previous step
>>>NOTE: it seems that AI Platform does not necessarily support the latest Tensorflow version!!!
HERE you can see this version of the model is correctly deployed
STEP 5: Connect on your local machine with gcloud command line sdk tools and send
a REST api call to test if your model is working
>> assumes you have already installed them
>> step 5.1: get some input data and make sure it is formatted correctly.
-
Example for CNN: If your input is a raw image, resize it and then use the pyton script (image-to-json.py which you must copy to your machine) to convert any image you want to pass to the CNN model created above for classification to a json file called request.json
>> step 5.2: use glcould tool to call prediction on the image
STEP 5.1 INPUT Data Format -- HERE are 2 files you can use that have been processed: requestDogSize.json and requestCatSize.jsonIMPORTANT: you must understand the input needed for your Network you deployed.>> If a CNN you will most probably be passing an image as input, but MUST MAKE sure it is the CORRECT SIZE (see example below).
>>IF an LSTM, the output will again be a json file but, represent the input to the LSTM which is typically a series of feature vectors --each representing the output of a feature extraction stage on an image in the video sequence you will input toCall the code to create json file to represent your input image dog.jpg (assumes in same directory as the python image-to-json.py script)
python image-to-json.py --input dog.jpg --output request.json --scale 1
|
STEP 5.1-part A: In command prompt launch the Google Cloud consoleNOTE: your model name and version name may be different --see the ones I created above are used here
|
|