ML Kit AutoML Vision Edge 移行ガイド

AutoML でトレーニングされた画像分類モデルをカスタムモデルに渡すことができます。 API引き続き、モデルをアプリ内にバンドルするかホストできます カスタムモデルとして利用できますAutoML Image Labeling API が カスタムモデル イメージに完全に置き換えられているため、ML Kit から削除されています Labeling API

API変更内容
AutoML Vision Edge Image Labeling API この API は、Custom Model image Labeling API に完全に置き換えられます。既存 AutoML Vision Edge 画像ラベル付け API が削除されました。

現在 AutoML Vision Edge API を使用している ML Kit ユーザーは、 Android と iOS 向けの移行手順に沿ってください。

よくある質問

変更の理由

これにより、ML Kit API が簡素化され、ML Kit を 説明します。この変更により、AutoML でトレーニングされたモデルを正確な カスタムモデルと同じように使用できますまた、AutoML でトレーニングされたモデルを使用して、 主な機能の一つは、オブジェクト検出とトラッキングの サポートしています。さらに、カスタムモデル API は、 メタデータに埋め込まれたラベルマップ、および個別のマニフェストと 作成します。

新しい SDK への移行にはどのようなメリットがありますか?

  • 新機能: AutoML でトレーニングされたモデルを画像のラベル付けに使用できる オブジェクト検出とラベルマップを使用したモデルの追跡と使用 メタデータに埋め込まれます

Android 向け移行ガイド

ステップ 1: Gradle のインポートを更新する

モジュール内の ML Kit Android ライブラリの依存関係を更新する 以下に基づく(アプリレベル)Gradle ファイル(通常は app/build.gradle) table:

機能古いアーチファクト新しいアーティファクト
リモートモデルのダウンロードを使用しない AutoML の画像ラベル付け com.google.mlkit:image-labeling-automl:16.2.1 com.google.mlkit:image-labeling-custom:16.0.0-beta5
リモートモデルのダウンロードを使用した画像のラベル付け AutoML 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

ステップ 2: クラス名を更新する

クラスがこの表に含まれている場合は、示されている変更を加えます。

以前のクラス新しいクラス
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

ステップ 3: メソッド名を更新する

コードの変更が最小限です。

  • LocalModel を、モデルファイルのパス(モデルにラベルマップを含むメタデータがある場合)またはモデル マニフェスト ファイルのパス(マニフェスト、モデル、ラベルが別々のファイルにある場合)のいずれかで初期化できるようになりました。
  • Firebase コンソールを介してリモートでカスタムモデルをホストし、FirebaseModelSourceCustomRemoteModel を初期化できます。

以下に、古い Kotlin メソッドと新しい Kotlin メソッドの例を示します。

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()

新規

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()

以下に、古い Java メソッドと新しい Java メソッドの例を示します。

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();

新規

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();

iOS 向け移行ガイド

前提条件

  • Xcode 13.2.1 以降が必要です。

ステップ 1: Cocoapods を更新する

アプリの Podfile で ML Kit の iOS cocoapods の依存関係を更新します。

機能古い Pod 名新しい Pod 名
リモートモデルのダウンロードを使用しない AutoML の画像ラベル付け GoogleMLKit/ImageLabelingAutoML GoogleMLKit/ImageLabelingCustom
リモートモデルのダウンロードを使用した画像のラベル付け AutoML GoogleMLKit/ImageLabelingAutoML
GoogleMLKit/LinkFirebase
GoogleMLKit/ImageLabelingCustom
GoogleMLKit/LinkFirebase

ステップ 2: クラス名を更新する

クラスがこの表に含まれている場合は、示されている変更を加えます。

Swift

以前のクラス新しいクラス
AutoMLImageLabelerLocalModel LocalModel
AutoMLImageLabelerRemoteModel CustomRemoteModel
AutoMLImageLabelerOptions CustomImageLabelerOptions

Objective-C

以前のクラス新しいクラス
MLKAutoMLImageLabelerLocalModel MLKLocalModel
MLKAutoMLImageLabelerRemoteModel MLKCustomRemoteModel
MLKAutoMLImageLabelerOptions MLKCustomImageLabelerOptions

Objective-C

ステップ 3: メソッド名を更新する

コードの変更が最小限です。

  • LocalModel を、モデルファイルのパス(モデルにラベルマップを含むメタデータがある場合)またはモデル マニフェスト ファイルのパス(マニフェスト、モデル、ラベルが別々のファイルにある場合)のいずれかで初期化できるようになりました。
  • Firebase コンソールを介してリモートでカスタムモデルをホストし、FirebaseModelSourceCustomRemoteModel を初期化できます。

以下に、古い Swift メソッドと新しい Swift メソッドの例を示します。

let localModel =
    AutoMLImageLabelerLocalModel(manifestPath: "automl/manifest.json")
let optionsWithLocalModel = AutoMLImageLabelerOptions(localModel: localModel)
let remoteModel = AutoMLImageLabelerRemoteModel(name: "automl_remote_model")
let optionsWithRemoteModel = AutoMLImageLabelerOptions(remoteModel: remoteModel)

新規

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)

Objective-C の古いメソッドと新しいメソッドの例を次に示します。

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];

新規

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];