How do I get a TensorFlow/Keras model that takes images as input to serve predictions on Cloud ML Engine?

前端 未结 2 1937
囚心锁ツ
囚心锁ツ 2020-11-29 06:08

There are multiple questions (examples: 1, 2, 3, 4, 5, 6, etc.) trying to address the question of how to handle image data when serving predictions for TensorFlow/Keras mode

2条回答
  •  借酒劲吻你
    2020-11-29 06:46

    The answer by @rhaertel above is the best treatment of this subject I've seen. For anyone working on deploying TensorFlow image-based models on Google Cloud ML, I'd recommend also having a look at the following repo:

    https://github.com/mhwilder/tf-keras-gcloud-deployment.

    I spent a while trying to get all of this working for several use cases and did my best to document the whole process in this repo. The repo covers the following topics:

    1. Training a fully convolutional tf.keras model locally (mostly just to have a model for testing the next parts)
    2. Example code for exporting models that work with the Cloud ML Engine
    3. Three model versions that accept different JSON input types (1. An image converted to a simple list string, 2. An image converted to a base64 encoded string, and 3. A URL that points to an image in a Google Storage bucket)
    4. Instructions and references for general Google Cloud Platform setup
    5. Code for preparing the input JSON files for the 3 different input types
    6. Google Cloud ML model and version creation instructions from the console
    7. Examples using the Google Cloud SDK to call predict on the models

提交回复
热议问题