Firebase Machine Learning 是一个移动端 SDK,它通过一个强大且易用的软件包将 Google 的机器学习专业知识融入到 Android 和 Apple 应用中。无论您是刚开始接触机器学习,还是拥有丰富的相关经验,都只需几行代码即可实现所需的功能。您无需具备丰富的神经网络或模型优化知识即可开始使用该 SDK。如果您是一名经验丰富的机器学习开发者,Firebase ML 提供了便捷的 API,可帮助您在移动应用中使用自定义 TensorFlow Lite 模型。
主要功能
托管和部署自定义模型
使用您自己的 TensorFlow Lite 模型进行设备端推断。您只需将自己的模型部署到 Firebase,我们就会负责托管该模型并将其用于您的应用。Firebase 将为您的用户动态地提供最新版本的模型,让您可以定期更新模型,而无需向用户推送应用的新版本。
Firebase ML 包含一组适用于以下常见移动使用场景的现成 API:识别文字、给图片加标签以及识别地标。您只需将数据传递到 Firebase ML 库,即可获得所需的信息。这些 API 利用 Google Cloud 机器学习技术的强大功能,为您提供高级别的准确度。
云端与设备端
Firebase ML 具有可在云端或设备端使用的 API。如果我们将 ML API 描述为云端 API 或设备端 API,我们是在描述哪台机器执行推断:即哪台机器使用机器学习模型来从您所提供的数据中发掘洞见。在 Firebase ML 中,这种情况发生在 Google Cloud 或用户的移动设备上。
文字识别、给图片加标签以及地标识别 API 会在云端执行推断。与类似的设备端模型相比,这些模型可获得的计算能力和内存更多,因此能以高于设备端模型的准确率和精确度执行推断。但另一方面,对这些 API 的每个请求都需要网络往返,因此它们不适合视频处理等实时和低延迟应用。
自定义模型 API 可处理在设备上运行的机器学习模型。这些功能使用和生成的模型是 TensorFlow Lite 模型,这些模型经过优化,可在移动设备上运行。这些模型的最大优势是它们不需要网络连接并且可以快速运行,例如以足够快的速度实时处理视频帧。
Firebase ML 可以通过将自定义模型上传到我们的服务器,将自定义模型部署到用户的设备。启用了 Firebase 的应用会根据需要将模型下载到设备上。这样一来,您就可以将应用的初始安装大小保持在较小范围内,并且无需重新发布应用即可更换机器学习模型。
[null,null,["最后更新时间 (UTC):2025-08-04。"],[],[],null,["Firebase Machine Learning \nplat_ios plat_android plat_flutter \nUse machine learning in your apps to solve real-world problems. \n\nFirebase Machine Learning is a mobile SDK that brings Google's machine\nlearning expertise to Android and Apple apps in a powerful yet easy-to-use\npackage. Whether you're new or experienced in machine learning, you can\nimplement the functionality you need in just a few lines of code. There's no\nneed to have deep knowledge of neural networks or model optimization to get\nstarted. On the other hand, if you are an experienced ML developer,\nFirebase ML provides convenient APIs that help you use your custom\nTensorFlow Lite models in your mobile apps.\n| This is a beta release of Firebase ML. This API might be changed in backward-incompatible ways and is not subject to any SLA or deprecation policy.\n\nKey capabilities\n\n|---------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Host and deploy custom models | Use your own TensorFlow Lite models for on-device inference. Just deploy your model to Firebase, and we'll take care of hosting and serving it to your app. Firebase will dynamically serve the latest version of the model to your users, allowing you to regularly update them without having to push a new version of your app to users. When you use Firebase ML with [Remote Config](/docs/remote-config), you can serve different models to different user segments, and with [A/B Testing](/docs/ab-testing), you can run experiments to find the best performing model (see the [Apple](/docs/ml/ios/ab-test-models) and [Android](/docs/ml/android/ab-test-models) guides). |\n| Production-ready for common use cases | Firebase ML comes with a set of ready-to-use APIs for common mobile use cases: recognizing text, labeling images, and identifying landmarks. Simply pass in data to the Firebase ML library and it gives you the information you need. These APIs leverage the power of Google Cloud's machine learning technology to give you the highest level of accuracy. |\n\nCloud vs. on-device\n\nFirebase ML has APIs that work either in the cloud or on the device.\nWhen we describe an ML API as being a cloud API or on-device API, we are\ndescribing *which machine performs inference* : that is, which machine uses the\nML model to discover insights about the data you provide it. In Firebase ML,\nthis happens either on Google Cloud, or on your users' mobile devices.\n\nThe text recognition, image labeling, and landmark recognition APIs perform\ninference in the cloud. These models have more computational power and memory\navailable to them than a comparable on-device model, and as a result, can\nperform inference with greater accuracy and precision than an on-device model.\nOn the other hand, every request to these APIs requires a network round-trip,\nwhich makes them unsuitable for real-time and low-latency applications such as\nvideo processing.\n\nThe custom model APIs deal with ML models that run on the\ndevice. The models used and produced by these features are\n[TensorFlow Lite](https://tensorflow.org/lite) models, which are\noptimized to run on mobile devices. The biggest advantage to these models is\nthat they don't require a network connection and can run very quickly---fast\nenough, for example, to process frames of video in real time.\n\nFirebase ML provides\nthe ability to deploy custom models to your users' devices by\nuploading them to our servers. Your Firebase-enabled app will download the\nmodel to the device on demand. This allows you to keep your app's initial\ninstall size small, and you can swap the ML model without having to republish\nyour app.\n\nML Kit: Ready-to-use on-device models On June 3, 2020, we started offering ML Kit's on-device APIs through a\n| [new\n| standalone SDK](https://developers.google.com/ml-kit).\n| Google Cloud APIs and custom model deployment will\n| continue to be available through Firebase Machine Learning.\n\nIf you're looking for pre-trained models that run on the device, check out\n[ML Kit](https://developers.google.com/ml-kit). ML Kit is available\nfor iOS and Android, and has APIs for many use cases:\n\n- Text recognition\n- Image labeling\n- Object detection and tracking\n- Face detection and contour tracing\n- Barcode scanning\n- Language identification\n- Translation\n- Smart Reply\n\nNext steps\n\n- Explore the ready-to-use APIs: [text recognition](/docs/ml/recognize-text), [image labeling](/docs/ml/label-images), and [landmark recognition](/docs/ml/recognize-landmarks).\n- Learn about using mobile-optimized [custom models](/docs/ml/use-custom-models) in your app."]]