Search code examples
pythontensorflowmachine-learninggoogle-cloud-platformautoml

Can I use exported AutoML Tables model in Python?


Can I export a model from AutoML tables and use it locally with tensorflow?

I've discovered that you can export some of the Vision models in multiple formats but for Tables I can only export a tf edges model to Cloud Storage. So can I run it locally somehow to perform predictions? Or is there another way to export/convert a model in a format that can be used locally?

enter image description here


Solution

  • It is possible for AutoML tables to export a tf saved model (.pb format). You can do this by sending a request using curl. See Exporting Models in AutoML Tables on detailed instructions on how to use models.export.

    NOTE: Exported model used for testing is from AutoML Tables quickstart.

    JSON request (Use tf_saved_model to export a tensorflow model in SavedModel format):

    {
      "outputConfig": {
        "modelFormat": "tf_saved_model",
        "gcsDestination": {
          "outputUriPrefix": "your-gcs-destination"
        }
      }
    }
    

    Curl command (assuming that the model is in us-central1):

    curl -X POST \
    -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
    -H "Content-Type: application/json; charset=utf-8" \
    -d @request.json \
    https://automl.googleapis.com/v1beta1/projects/your-project-id/locations/us-central1/models/your-model-id:export
    

    Exported model: enter image description here

    enter image description here