You can pass an AutoML-trained image classification model to the custom model APIs. You can continue to either bundle the model inside your app or host it on Firebase Console as a custom model. The AutoML image labeling API has been removed from ML Kit since it’s fully replaced by the Custom Model Image Labeling API.
API | What is changing? |
---|---|
AutoML Vision Edge image labeling API | It’s fully replaced by the Custom Model image labeling API. Existing AutoML Vision Edge image labeling API is removed. |
If you are currently an ML Kit user using AutoML Vision Edge API, please follow the migration instructions for Android and iOS.
Frequently Asked Questions
Why this change?
It helps simplify ML Kit APIs, and make it easier to integrate ML Kit into your app. With this change, you can use an AutoML-trained model in the exact same way as a custom model. It also enables you to use AutoML-trained models for Object Detection and Tracking, in addition to Image Labeling which we currently support. Furthermore, the custom model API supports both models with label map embedded in its metadata, and models with separate manifest and label files.
What benefits do I get from migrating to the new SDK?
- New features: Ability to use AutoML-trained models for both Image Labeling and Object Detection & Tracking and ability to use models with label map embedded in its metadata.
Migration Guide for Android
Step 1: Update Gradle Imports
Update the dependencies for the ML Kit Android libraries in your module
(app-level) Gradle file (usually app/build.gradle
) according to the following
table:
Feature | Old Artifacts | New Artifact |
---|---|---|
Image labeling AutoML without remote model downloading | com.google.mlkit:image-labeling-automl:16.2.1 | com.google.mlkit:image-labeling-custom:16.0.0-beta5 |
Image labeling AutoML with remote model downloading |
com.google.mlkit:image-labeling-automl:16.2.1 com.google.mlkit:linkfirebase:16.0.1 |
com.google.mlkit:image-labeling-custom:16.0.0-beta5 com.google.mlkit:linkfirebase:17.0.0 |
Step 2: Update class names
If your class appears in this table, make the indicated change:
Old class | New class |
---|---|
com.google.mlkit.vision.label.automl.AutoMLImageLabelerLocalModel | com.google.mlkit.common.model.LocalModel |
com.google.mlkit.vision.label.automl.AutoMLImageLabelerRemoteModel | com.google.mlkit.common.model.CustomRemoteModel |
com.google.mlkit.vision.label.automl.AutoMLImageLabelerOptions | com.google.mlkit.vision.label.custom.CustomImageLabelerOptions |
Step 3: Update method names
There are minimal code changes:
LocalModel
can now be initialized with either a model file path (if the model has metadata containing the label map) or a model manifest file path (if the manifest, model, and labels are in separate files).- You can host a custom model remotely via Firebase Console and initialize a
CustomRemoteModel
with aFirebaseModelSource
.
Here are some examples of old and new Kotlin methods:
Old
val localModel = AutoMLImageLabelerLocalModel.Builder() .setAssetFilePath("automl/manifest.json") // or .setAbsoluteFilePath(absolute file path to manifest file) .build() val optionsWithLocalModel = AutoMLImageLabelerOptions.Builder(localModel) .setConfidenceThreshold(0.5f) .build() val remoteModel = AutoMLImageLabelerRemoteModel.Builder("automl_remote_model") .build() val optionsWithRemoteModel = AutoMLImageLabelerOptions.Builder(remoteModel) .build()
New
val localModel = LocalModel.Builder() .setAssetManifestFilePath("automl/manifest.json") // or .setAbsoluteManifestFilePath(absolute file path to manifest file) .build() val optionsWithLocalModel = CustomImageLabelerOptions.Builder(localModel) .setConfidenceThreshold(0.5f) .build() val firebaseModelSource = FirebaseModelSource.Builder("automl_remote_model") .build() val remoteModel = CustomRemoteModel.Builder(firebaseModelSource).build() val optionsWithRemoteModel = CustomImageLabelerOptions.Builder(remoteModel) .build()
Here are some examples of old and new Java methods:
Old
AutoMLImageLabelerLocalModel localModel = new AutoMLImageLabelerLocalModel.Builder() .setAssetFilePath("automl/manifest.json") // or .setAbsoluteFilePath(absolute file path to manifest file) .build(); AutoMLImageLabelerOptions optionsWithLocalModel = new AutoMLImageLabelerOptions.Builder(localModel) .setConfidenceThreshold(0.5f) .build(); AutoMLImageLabelerRemoteModel remoteModel = new AutoMLImageLabelerRemoteModel.Builder("automl_remote_model").build(); AutoMLImageLabelerOptions optionsWithRemoteModel = new AutoMLImageLabelerOptions.Builder(remoteModel) .build();
New
LocalModel localModel = new LocalModel.Builder() .setAssetManifestFilePath("automl/manifest.json") // or .setAbsoluteManifestFilePath(absolute file path to manifest file) .build() CustomImageLabelerOptions optionsWithLocalModel = new CustomImageLabelerOptions.Builder(localModel) .setConfidenceThreshold(0.5f) .build(); FirebaseModelSource firebaseModelSource = new FirebaseModelSource.Builder("automl_remote_model").build(); CustomRemoteModel remoteModel = new CustomRemoteModel.Builder(firebaseModelSource).build(); CustomImageLabelerOptions optionsWithRemoteModel = new CustomImageLabelerOptions.Builder(remoteModel).build();
Migration Guide for iOS
Prerequisites
- Xcode 13.2.1 or greater is required.
Step 1: Update Cocoapods
Update the dependencies for the ML Kit iOS cocoapods in your app’s Podfile:
Feature | Old pod name(s) | New pod name(s) |
---|---|---|
Image labeling AutoML without remote model downloading | GoogleMLKit/ImageLabelingAutoML | GoogleMLKit/ImageLabelingCustom |
Image labeling AutoML with remote model downloading |
GoogleMLKit/ImageLabelingAutoML GoogleMLKit/LinkFirebase |
GoogleMLKit/ImageLabelingCustom GoogleMLKit/LinkFirebase |
Step 2: Update class names
If your class appears in this table, make the indicated change:
Swift
Old class | New class |
---|---|
AutoMLImageLabelerLocalModel | LocalModel |
AutoMLImageLabelerRemoteModel | CustomRemoteModel |
AutoMLImageLabelerOptions | CustomImageLabelerOptions |
Objective-C
Old class | New class |
---|---|
MLKAutoMLImageLabelerLocalModel | MLKLocalModel |
MLKAutoMLImageLabelerRemoteModel | MLKCustomRemoteModel |
MLKAutoMLImageLabelerOptions | MLKCustomImageLabelerOptions |
Objective-C
Step 3: Update method names
There are minimal code changes:
LocalModel
can now be initialized with either a model file path (if the model has metadata containing the label map) or a model manifest file path (if the manifest, model, and labels are in separate files).- You can host a custom model remotely via Firebase Console and initialize a
CustomRemoteModel
with aFirebaseModelSource
.
Here are some examples of old and new Swift methods:
Old
let localModel = AutoMLImageLabelerLocalModel(manifestPath: "automl/manifest.json") let optionsWithLocalModel = AutoMLImageLabelerOptions(localModel: localModel) let remoteModel = AutoMLImageLabelerRemoteModel(name: "automl_remote_model") let optionsWithRemoteModel = AutoMLImageLabelerOptions(remoteModel: remoteModel)
New
guard let localModel = LocalModel(manifestPath: "automl/manifest.json") else { return } let optionsWithLocalModel = CustomImageLabelerOptions(localModel: localModel) let firebaseModelSource = FirebaseModelSource(name: "automl_remote_model") let remoteModel = CustomRemoteModel(remoteModelSource: firebaseModelSource) let optionsWithRemoteModel = CustomImageLabelerOptions(remoteModel: remoteModel)
Here are some examples of old and new Objective-C methods:
Old
MLKAutoMLImageLabelerLocalModel *localModel = [[MLKAutoMLImageLabelerLocalModel alloc] initWithManifestPath:"automl/manifest.json"]; MLKAutoMLImageLabelerOptions *optionsWithLocalModel = [[MLKAutoMLImageLabelerOptions alloc] initWithLocalModel:localModel]; MLKAutoMLImageLabelerRemoteModel *remoteModel = [[MLKAutoMLImageLabelerRemoteModel alloc] initWithManifestPath:"automl/manifest.json"]; MLKAutoMLImageLabelerOptions *optionsWithRemoteModel = [[MLKAutoMLImageLabelerOptions alloc] initWithRemoteModel:remoteModel];
New
MLKLocalModel *localModel = [[MLKLocalModel alloc] initWithManifestPath:"automl/manifest.json"]; MLKCustomImageLabelerOptions *optionsWithLocalModel = [[MLKCustomImageLabelerOptions alloc] initWithLocalModel:localModel]; MLKFirebaseModelSource *firebaseModelSource = [[MLKFirebaseModelSource alloc] initWithName:@"automl_remote_model"]; MLKCustomRemoteModel *remoteModel = [[MLKCustomRemoteModel alloc] initWithRemoteModelSource:firebaseModelSource]; MLKCustomImageLabelerOptions *optionsWithRemoteModel = [[MLKCustomImageLabelerOptions alloc] initWithRemoteModel:remoteModel];
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-29 UTC.