迁移指南
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
2020 年 6 月 3 日,我们对适用于 Firebase 的机器学习套件进行了一些更改,以便更好地区分设备端 API 和云端 API。当前的 API 集现在分为以下两个产品:
如果您只需要设备端解决方案,经过这项更改后,您还可以更轻松地将机器学习套件集成到您的应用中。本文档介绍如何将您的应用从 Firebase ML Kit SDK 迁移到新的机器学习套件 SDK。
有何变化?
设备端基础 API
以下 API 已迁移到新的独立机器学习套件 SDK。
- 条形码扫描
- 人脸检测
- 图片标注
- 对象检测和跟踪
- 文本识别
- 语言 ID
- 智能回复
- 翻译
- AutoML Vision Edge 推断 API
适用于 Firebase SDK 的机器学习套件中的现有设备端基础 API 已弃用,将不再接收更新。
如果您现在在应用中使用这些 API,请按照适用于 Android 的机器学习套件迁移指南和适用于 iOS 的机器学习套件迁移指南迁移到新的机器学习套件 SDK。
自定义模型 API
对于下载 Firebase 中托管的模型,我们将通过 Firebase ML SDK 继续提供自定义模型下载程序。SDK 提取最新的可用模型,并将其传递给单独的 TensorFlow Lite 运行时以进行推理。
适用于 Firebase SDK 的机器学习套件中的现有自定义模型解释器已弃用,将不再接收更新。我们建议直接使用 TensorFlow Lite 运行时进行推断。或者,如果您只想将自定义模型用于为图片加标签以及对象检测和跟踪 API,现在可以直接在机器学习套件的这些 API 中使用自定义模型。
如需查看详细说明,请参阅适用于 Android 和 iOS 的迁移指南。
哪些方面未发生变化?
Firebase ML 将继续提供云端 API 和服务:
常见问题解答
此次变更的原因
我们进行这一更改是为了明确此产品提供的解决方案。
通过此变更,新的机器学习套件 SDK 完全专注于设备端机器学习,所有数据处理均在设备端进行,开发者可免费使用。之前属于 Firebase ML Kit 的云服务仍通过 Firebase ML 提供,您仍然可以将这些云服务与机器学习套件 API 并行使用。
对于设备端 API,借助新的机器学习套件 SDK,开发者可以更轻松地将机器学习套件集成到其应用中。今后,您只需向应用的项目添加依赖项,然后开始使用该 API 即可。无需仅仅为了使用设备端 API 就设置 Firebase 项目。
使用 Firebase 托管的模型会怎么样?
Firebase Machine Learning 将继续像以前一样传送您的模型。该功能并未改变。具体改进如下:
迁移到新的机器学习套件 SDK 能为我带来哪些好处?
迁移到新版 SDK 可确保您的应用受益于最新的 bug 修复和对设备端 API 的改进。例如,以下是第一个版本中的一些更改:
如需查看最新变更的完整列表,请参阅机器学习套件 SDK 版本说明。
我目前使用的是适用于 Firebase 的机器学习套件,何时需要迁移?
这取决于您当前在应用中使用的是哪个适用于 Firebase API 的机器学习套件。
适用于 Firebase SDK 的机器学习套件中的设备端基础 API 在可预见的未来将继续有效。但是,如果延迟切换到新的机器学习套件 SDK,您将无法从新功能和更新中受益。此外,更新应用中的其他组件后,您可能会遇到依赖项冲突。当您的一些其他依赖项(直接或间接)比旧版 ML Kit for Firebase SDK 预期的依赖项更新时,就可能发生这种情况。例如,OkHttp 和 firebase-common 等库可能会发生这种情况。
如果您通过适用于 Firebase SDK 的机器学习套件使用 Cloud API,目前无需进行任何更改。
如果您使用的是自定义模型部署,我们建议您升级到最新版本,以便直接在 TensorFlow Lite 运行时上运行推断。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eML Kit is now split into two products: ML Kit (on-device APIs) and Firebase Machine Learning (cloud-based APIs and custom model deployment).\u003c/p\u003e\n"],["\u003cp\u003eOn-device APIs like barcode scanning and text recognition have moved to the standalone ML Kit SDK; existing on-device APIs in Firebase ML Kit are deprecated.\u003c/p\u003e\n"],["\u003cp\u003eCloud-based APIs, such as image labeling and text recognition, remain available through Firebase ML.\u003c/p\u003e\n"],["\u003cp\u003eMigrating to the new ML Kit SDK ensures access to the latest features, bug fixes, and improvements, including custom models and lifecycle support.\u003c/p\u003e\n"],["\u003cp\u003eWhile on-device APIs in Firebase ML Kit will continue to function, developers are encouraged to migrate to the new ML Kit SDK to benefit from ongoing updates and avoid potential dependency conflicts.\u003c/p\u003e\n"]]],[],null,["# Migration guide\n\nOn June 3, 2020, we made some changes to ML Kit for Firebase to better distinguish the\non-device APIs from cloud based APIs. The current set of APIs is now split into\nthe following two products:\n\n- A new product, simply called [**ML Kit**](/ml-kit/guides), which will contain all the on-device APIs\n\n- [**Firebase Machine Learning**](https://firebase.google.com/docs/ml), focused on cloud-based APIs and custom model\n deployment.\n\nThis change will also make it easier to integrate ML Kit into your app if you only\nneed an on-device solution. This document explains how to migrate your app from the\nFirebase ML Kit SDK to the new ML Kit SDK.\n\nWhat's changing?\n----------------\n\n### On-device base APIs\n\nThe following APIs have moved to the new standalone ML Kit SDK.\n\n- Barcode scanning\n- Face detection\n- Image labeling\n- Object detection and tracking\n- Text recognition\n- Language ID\n- Smart reply\n- Translate\n- AutoML Vision Edge inference API\n\nThe existing on-device base APIs in the ML Kit for Firebase SDK are\ndeprecated and will no longer receive updates.\n\nIf you are using these APIs in\nyour app today, please migrate to the new ML Kit SDK, by following the\n**[ML Kit migration guide for Android](/ml-kit/migration/android)** and the\n**[ML Kit migration guide for iOS](/ml-kit/migration/ios)**.\n\n### Custom model APIs\n\nFor downloading models hosted in Firebase, the custom model downloader continues\nto be offered through the Firebase ML SDK. The SDK fetches the latest available\nmodel and passes it to the separate TensorFlow Lite runtime for inference.\n\nThe existing custom model interpreter in the ML Kit for Firebase SDK is deprecated\nand will no longer receive updates. We recommend using the TensorFlow Lite runtime\ndirectly for inference. Alternatively, if you only want to use custom models for\nimage labeling and object detection and tracking APIs, you can now use\n[custom models](/ml-kit/custom-models) in these APIs in ML Kit directly.\n\nSee the migration guides for\n[Android](https://firebase.google.com/docs/ml/android/migrate-from-legacy-api/)\nand [iOS](https://firebase.google.com/docs/ml/ios/migrate-from-legacy-api/)\nfor detailed instructions.\n\nWhat hasn't changed?\n--------------------\n\nCloud-based APIs and services will continue to be offered with Firebase ML:\n\n- The cloud-based image labeling, text recognition, and landmark recognition APIs\n are still available from the Firebase ML SDK.\n\n- Firebase ML also continues to offer [Model deployment](https://firebase.google.com/docs/ml/use-custom-models)\n\nFrequently asked questions\n--------------------------\n\n### Why this change?\n\nWe are making this change to clarify what solutions the product is offering.\nWith this change, the new ML Kit SDK is fully focused on on-device machine\nlearning where all data processing happens on-device and is available to\ndevelopers at no cost. The cloud services that were part of Firebase ML Kit\nbefore remain available through Firebase ML and you can still use these in\nparallel with ML Kit APIs.\n\nFor on-device APIs, the new ML Kit SDK makes it easier for developers to\nintegrate ML Kit into their app. Going forward, you just need to add\ndependencies to the app's project and then start using the API. There is no need\nto set up a Firebase project just to use on-device APIs.\n\n### What happens to my models that are being hosted with Firebase?\n\nFirebase Machine Learning will continue to serve your models as before. That\nfunctionality isn't changing. Here are a couple of improvements:\n\n- You can now deploy your models to Firebase programmatically using the\n [Python or Node SDKs](https://firebase.google.com/docs/ml/manage-hosted-models#manage_models_with_the_firebase_admin_sdk).\n\n- You can now use the Firebase ML SDK in conjunction with the TensorFlow\n Lite runtime. The Firebase SDK downloads the model to the device, and the TensorFlow\n Lite runtime performs the inference. This allows you to easily choose the\n runtime version you prefer, including a custom build.\n\n### What benefits do I get from migrating to the new ML Kit SDK?\n\nMigrating to the new SDK will ensure your applications benefit from the latest\nbug fixes and improvements to the on-device APIs. For example, here are a\ncouple of changes in the first release:\n\n- You can now use the new\n [custom image labeling](/ml-kit/vision/image-labeling#custom-tflite) and\n [custom object detection and tracking](/ml-kit/vision/object-detection#custom-tflite)\n APIs to easily integrate custom image classification models in your apps\n and build real-time interactive user experiences.\n\n- [Android Jetpack Lifecycle](https://developer.android.com/reference/androidx/lifecycle/Lifecycle)\n support is added to all APIs. You can now use `addObserver` to automatically\n manage the initiation and teardown of ML Kit APIs as the app goes through screen\n rotation or closure by the user / system. This makes integration with CameraX\n easier.\n\nA full list of the latest changes can be found in the [ML Kit SDK release\nnotes](/ml-kit/release-notes).\n\n### I am using ML Kit for Firebase today, when do I need to migrate over?\n\nThis depends on which ML Kit for Firebase APIs you currently use in your app.\n\n- The **on-device base APIs** in the ML Kit for Firebase SDK will continue to work for\n the foreseeable future. However, by delaying the switch to the new ML Kit SDK,\n you will not benefit from new features and updates. In addition, once you update\n other components in your app there is a risk you may\n run into dependencies conflicts. This can happen when some of your other dependencies (direct or indirect) are\n newer than the ones expected by the old ML Kit for Firebase SDK. Examples of\n libraries for which this may happen are OkHttp and firebase-common.\n\n- If you are using **Cloud APIs** via the ML Kit for Firebase SDK, no change is\n required at this time.\n\n- If you are using **Custom Model Deployment**, we recommend you upgrade to the latest\n version which allows running inferences directly on the TensorFlow Lite runtime."]]