[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eThis guide is deprecated and users should refer to the TensorFlow with Vertex AI guide for updated information.\u003c/p\u003e\n"],["\u003cp\u003eEarth Engine facilitates the use of TensorFlow for machine learning by providing methods for data export/import in TFRecord format and integration with AI Platform for model hosting.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eee.Model\u003c/code\u003e package enables interaction with TensorFlow models, specifically allowing predictions on Earth Engine images using models hosted on AI Platform.\u003c/p\u003e\n"],["\u003cp\u003eWhen using AI Platform models, ensure compatibility with TensorFlow's SavedModel format and configure necessary permissions for model access.\u003c/p\u003e\n"],["\u003cp\u003eBe mindful of potential costs associated with using billable components of Google Cloud, such as AI Platform and Cloud Storage.\u003c/p\u003e\n"]]],["This content outlines using TensorFlow models with Earth Engine, focusing on `ee.Model` for AI Platform interaction. Key actions include creating `ee.Model` instances with `ee.Model.fromAiPlatformPredictor()`, packaging Earth Engine data into tensors for AI Platform prediction requests, and reassembling responses. Models must use TensorFlow's SavedModel format, prepared using the Earth Engine CLI. Image predictions utilize `model.predictImage()`, returning an `ee.Image`. The document warns about costs associated with AI Platform and Cloud Storage and recommend using regional endpoints.\n"],null,["# Predictions using TensorFlow and Cloud AI Platform\n\n| **Deprecated!** This guide uses datasets that may be removed from the\n| Earth Engine catalog and/or methods that may be removed in future versions of the Earth\n| Engine API. See [](/earth-engine/guides/earth-engine/guides/tensorflow-vertex)instead.\n\n[TensorFlow](https://www.tensorflow.org/) is an open source ML platform that\nsupports advanced ML methods such as deep learning. This page describes TensorFlow\nspecific features in Earth Engine. Although TensorFlow models are developed and trained\noutside Earth Engine, the Earth Engine API provides methods for exporting training and\ntesting data in TFRecord format and importing/exporting imagery in TFRecord format. See\n[the TensorFlow examples page](/earth-engine/guides/tf_examples) for more information about how to\ndevelop pipelines for using TensorFlow with data from Earth Engine. See\n[the TFRecord page](/earth-engine/guides/tfrecord) to learn more about how Earth Engine writes data to\nTFRecord files.\n\n`ee.Model`\n----------\n\n\nThe `ee.Model` package handles interaction with TensorFlow backed machine\nlearning models.\n\n### Interacting with models hosted on AI Platform\n\n\nA new `ee.Model` instance can be created with\n`ee.Model.fromAiPlatformPredictor()`. This is an `ee.Model` object\nthat packages Earth Engine data into tensors, forwards them as predict requests to\n[Google AI Platform](https://cloud.google.com/ai-platform/) then automatically\nreassembles the responses into Earth Engine data types. Note that depending on the size\nand complexity of your model and its inputs, you may wish to\n[adjust\nthe minimum node size](https://cloud.google.com/ml-engine/docs/prediction-overview#node-allocation) of your AI Platform model to accommodate a high volume of\npredictions.\n\nEarth Engine requires AI Platform models to use TensorFlow's\n[SavedModel](https://www.tensorflow.org/guide/saved_model#save_and_restore_models)\nformat. Before a hosted model can interact with Earth Engine, its inputs/outputs need to\nbe compatible with the TensorProto interchange format, specifically serialized\nTensorProtos in base64. To make this easier, the Earth Engine CLI has the\n[`model prepare`](/earth-engine/guides/command_line#model) command that wraps an existing\nSavedModel in the required operations to convert input/output formats.\n\n\nTo use a model with `ee.Model.fromAiPlatformPredictor()`, you must have sufficient\npermissions to use the model. Specifically, you (or anyone who uses the model) needs at\nleast the [ML Engine Model User role](https://cloud.google.com/ai-platform/prediction/docs/access-control#model_user_role). You can inspect and set model permissions from the\n[models page of the Cloud\nConsole](https://console.cloud.google.com/ai-platform/models).\n\n### Regions\n\n\nYou should use regional endpoints for your models, specifying the region at model creation,\nversion creation and in `ee.Model.fromAiPlatformPredictor()`. Any region will\nwork (don't use global), but `us-central1` is preferred. Don't specify the\n`REGIONS` parameter. If you are are creating a model from the\n[Cloud Console](https://console.cloud.google.com/ai-platform/models),\nensure the regional box is checked.\n\nCosts\n-----\n\n| **Warning!** These guides use billable components of Google Cloud including:\n|\n| - AI Platform Training ([pricing](https://cloud.google.com/ai-platform/training/pricing))\n| - AI Platform Prediction ([pricing](https://cloud.google.com/ai-platform/prediction/pricing))\n| - Cloud Storage ([pricing](https://cloud.google.com/storage/pricing))\n|\n| You can use the\n| [Pricing Calculator](https://cloud.google.com/products/calculator) to generate\n| a cost estimate based on your projected usage.\n\n### Image Predictions\n\n\nUse `model.predictImage()` to make predictions on an `ee.Image`\nusing a hosted model. The return type of `predictImage()` is an\n`ee.Image` which can be added to the map, used in other computations,\nexported, etc. Earth Engine will automatically tile the input bands and adjust\nthe output projection for scale changes and overtiling as needed. (See\n[the TFRecord doc](/earth-engine/guides/tfrecord#exporting-images) for more information on how tiling\nworks). Note that Earth Engine will always forward 3D tensors to your model even when\nbands are scalar (the last dimension will be 1).\n\n\nNearly all convolutional models will have a fixed input projection (that of the data\non which the model was trained). In this case, set the `fixInputProj` parameter\nto **true** in your call to `ee.Model.fromAiPlatformPredictor()`.\nWhen visualizing predictions, use caution when zooming out on a model that has a fixed\ninput projection. This is for the same reason as [described\nhere](/earth-engine/guides/projections#reprojecting). Specifically, zooming to a large spatial scope can result in requests for too\nmuch data and may manifest as slowdowns or rejections by AI Platform."]]