> [!NOTE]
> **Note:** The AutoML Vision Edge image labeling API has been deprecated. The custom model APIs (image labeling and object detection and tracking) support models trained by AutoML. This migration guide explains how to migrate an existing AutoML Vision Edge implementation to use the new custom model API.

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 use the AutoML Vision Edge API, 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 lets you use AutoML-trained models
for Object Detection and Tracking, in addition to Image Labeling which we
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.kts`) 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 To host and download custom models, move your models to Cloud Storage and add download logic in your app to load them using LocalModel. For details, see the \[Firebase ML to Cloud Storage migration guide\]\[migrate-storage\]. |

### 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.LocalModel Your app must include logic to download remotely-hosted models and initialize them using LocalModel. |
| com.google.mlkit.vision.label.automl.AutoMLImageLabelerOptions | com.google.mlkit.vision.label.custom.CustomImageLabelerOptions |

> [!NOTE]
> **Note:** Previously with `AutoMLImageLabelerOptions`, if the `confidenceThreshold` is not set, a default confidence threshold value of `0.5` will be used. Now with `CustomImageLabelerOptions`, if the `confidenceThreshold` is not set, it will use the confidence threshold value included in the model metadata, if available. If that does not exist, a value of **`0.0`** will be used instead.

### Step 3: Update method names

There are minimal code changes:

- `LocalModel` can now be initialized with either a model path (if the model has metadata containing the label map) or a model manifest path (if the manifest, model, and labels are in separate files).
- Add logic to your app to download remotely-hosted models to local storage and load them using `LocalModel`.

Here are some examples of old and new Kotlin methods:

### Old

```kotlin
val localModel = AutoMLImageLabelerLocalModel.Builder()
    .setAssetFilePath("automl/manifest.json")
    // or .setAbsoluteFilePath(absolute 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

```kotlin
// Similar process for both local and remotely-hosted models (that have been downloaded)
val localModel = LocalModel.Builder()
    .setAssetManifestFilePath("automl/manifest.json")
    // or .setAbsoluteManifestFilePath(absolute path to manifest file)
    .build()

val optionsWithLocalModel = CustomImageLabelerOptions.Builder(localModel)
    .setConfidenceThreshold(0.5f)
    .build()
```

Here are some examples of old and new Java methods:

### Old

```java
AutoMLImageLabelerLocalModel localModel =
    new AutoMLImageLabelerLocalModel.Builder()
        .setAssetFilePath("automl/manifest.json")
        // or .setAbsoluteFilePath(absolute 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

```java
// Similar process for local models and remotely-hosted models (that have been downloaded)
LocalModel localModel =
    new LocalModel.Builder()
        .setAssetManifestFilePath("automl/manifest.json")
        // or .setAbsoluteManifestFilePath(absolute path to manifest file)
        .build();
CustomImageLabelerOptions optionsWithLocalModel =
    new CustomImageLabelerOptions.Builder(localModel)
        .setConfidenceThreshold(0.5f)
        .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 To host and download custom models, move your models to Cloud Storage and add download logic in your app to load them as local models. For details, see the \[Firebase ML to Cloud Storage migration guide\]\[migrate-storage\]. |

### Step 2: Update class names

If your class appears in this table, make the indicated change:

### Swift

| Old class | New class |
|---|---|
| AutoMLImageLabelerLocalModel | LocalModel |
| AutoMLImageLabelerRemoteModel | LocalModel To host and download custom models, move your models to Cloud Storage and add download logic in your app to load them as local models. For details, see the \[Firebase ML to Cloud Storage migration guide\]\[migrate-storage\]. |
| AutoMLImageLabelerOptions | CustomImageLabelerOptions |

### Objective-C

| Old class | New class |
|---|---|
| MLKAutoMLImageLabelerLocalModel | MLKLocalModel |
| MLKAutoMLImageLabelerRemoteModel | MLKLocalModel To host and download custom models, move your models to Cloud Storage and add download logic in your app to load them as local models. For details, see the \[Firebase ML to Cloud Storage migration guide\]\[migrate-storage\]. |
| MLKAutoMLImageLabelerOptions | MLKCustomImageLabelerOptions |

> [!NOTE]
> **Note:** Previously with `AutoMLImageLabelerOptions`, if the `confidenceThreshold` is not set, a default confidence threshold value of `0.5`will be used. Now with `CustomImageLabelerOptions`, if the `confidenceThreshold` is not set, it will use the confidence threshold value included in the model metadata, if available. If that does not exist, a value of **`0.0`** will be used instead.

### Step 3: Update method names

There are minimal code changes:

- `LocalModel` can now be initialized with either a model path (if the model has metadata containing the label map) or a model manifest path (if the manifest, model, and labels are in separate files).
- Add logic to your app to download remotely-hosted models to local storage and load them using `LocalModel`.

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

```
// Similar process for local models and remotely-hosted models (that have been downloaded)
guard let localModel = LocalModel(manifestPath: "automl/manifest.json") else { return }
let optionsWithLocalModel = CustomImageLabelerOptions(localModel: localModel)
```

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

```
// Similar process for local models and remotely-hosted models (that have been downloaded)
MLKLocalModel *localModel =
    [[MLKLocalModel alloc] initWithManifestPath:"automl/manifest.json"];
MLKCustomImageLabelerOptions *optionsWithLocalModel =
    [[MLKCustomImageLabelerOptions alloc] initWithLocalModel:localModel];
```