Anda dapat meneruskan model klasifikasi gambar yang dilatih AutoML ke API model kustom. Anda dapat terus memaketkan model di dalam aplikasi atau menghostingnya di Firebase Console sebagai model kustom. API pelabelan gambar AutoML telah dihapus dari ML Kit karena sepenuhnya diganti dengan Custom Model Image Labeling API.
API | Apa saja yang berubah? |
---|---|
API pelabelan gambar AutoML Vision Edge | Versi ini sepenuhnya diganti dengan API pelabelan gambar Model Kustom. API pelabelan gambar AutoML Vision Edge yang ada akan dihapus. |
Jika saat ini Anda adalah pengguna ML Kit yang menggunakan AutoML Vision Edge API, ikuti petunjuk migrasi untuk Android dan iOS.
Pertanyaan Umum (FAQ)
Apa alasan perubahan ini?
Solusi ini membantu menyederhanakan API ML Kit, dan mempermudah integrasi ML Kit ke dalam aplikasi Anda. Dengan perubahan ini, Anda dapat menggunakan model yang dilatih AutoML dengan cara yang sama persis seperti model kustom. Selain itu, Anda juga dapat menggunakan model yang dilatih AutoML untuk Deteksi dan Pelacakan Objek, selain Pelabelan Gambar yang saat ini kami dukung. Selain itu, API model kustom mendukung kedua model dengan peta label yang disematkan dalam metadatanya, dan model dengan file manifes dan label yang terpisah.
Apa manfaat yang saya dapatkan dengan bermigrasi ke SDK baru?
- Fitur baru: Kemampuan untuk menggunakan model yang dilatih AutoML untuk Pelabelan Gambar dan Deteksi & Pelacakan Objek, serta kemampuan untuk menggunakan model dengan peta label yang disematkan dalam metadatanya.
Panduan Migrasi untuk Android
Langkah 1: Perbarui Impor Gradle
Update dependensi untuk library Android ML Kit dalam file Gradle modul
(level aplikasi), biasanya app/build.gradle
, sesuai dengan tabel
berikut:
Fitur | Artefak Lama | Artefak Baru |
---|---|---|
Pelabelan gambar AutoML tanpa download model jarak jauh | com.google.mlkit:image-labeling-automl:16.2.1 | com.google.mlkit:image-labeling-custom:16.0.0-beta5 |
Pelabelan gambar AutoML disertai proses download model jarak jauh |
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 |
Langkah 2: Perbarui nama class
Jika kelas Anda muncul dalam tabel ini, lakukan perubahan yang ditunjukkan:
Kelas lama | Kelas baru |
---|---|
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 |
Langkah 3: Perbarui nama metode
Hanya ada sedikit perubahan kode:
LocalModel
kini dapat diinisialisasi dengan jalur file model (jika model memiliki metadata yang berisi peta label) atau jalur file manifes model (jika manifes, model, dan label ada dalam file terpisah).- Anda dapat menghosting model kustom dari jarak jauh melalui Firebase Console dan melakukan inisialisasi
CustomRemoteModel
denganFirebaseModelSource
.
Berikut ini beberapa contoh metode Kotlin lama dan baru:
Lama
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()
Baru
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()
Berikut ini beberapa contoh metode Java lama dan baru:
Lama
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();
Baru
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();
Panduan Migrasi untuk iOS
Prasyarat
- Memerlukan Xcode 13.2.1 atau yang lebih baru.
Langkah 1: Perbarui Cocoapod
Perbarui dependensi untuk cocoapod iOS ML Kit di Podfile aplikasi Anda:
Fitur | Nama pod lama | Nama pod baru |
---|---|---|
Pelabelan gambar AutoML tanpa download model jarak jauh | GoogleMLKit/ImageLabelingAutoML | GoogleMLKit/ImageLabelingCustom |
Pelabelan gambar AutoML disertai proses download model jarak jauh |
GoogleMLKit/ImageLabelingAutoML GoogleMLKit/LinkFirebase |
GoogleMLKit/ImageLabelingCustom GoogleMLKit/LinkFirebase |
Langkah 2: Perbarui nama class
Jika kelas Anda muncul dalam tabel ini, lakukan perubahan yang ditunjukkan:
Swift
Kelas lama | Kelas baru |
---|---|
AutoMLImageLabelerLocalModel | LocalModel |
AutoMLImageLabelerRemoteModel | CustomRemoteModel |
AutoMLImageLabelerOptions | CustomImageLabelerOptions |
Objective-C
Kelas lama | Kelas baru |
---|---|
MLKAutoMLImageLabelerLocalModel | MLKLocalModel |
MLKAutoMLImageLabelerRemoteModel | MLKCustomRemoteModel |
MLKAutoMLImageLabelerOptions | MLKCustomImageLabelerOptions |
Objective-C
Langkah 3: Perbarui nama metode
Hanya ada sedikit perubahan kode:
LocalModel
kini dapat diinisialisasi dengan jalur file model (jika model memiliki metadata yang berisi peta label) atau jalur file manifes model (jika manifes, model, dan label ada dalam file terpisah).- Anda dapat menghosting model kustom dari jarak jauh melalui Firebase Console dan melakukan inisialisasi
CustomRemoteModel
denganFirebaseModelSource
.
Berikut adalah beberapa contoh metode Swift lama dan baru:
Lama
let localModel = AutoMLImageLabelerLocalModel(manifestPath: "automl/manifest.json") let optionsWithLocalModel = AutoMLImageLabelerOptions(localModel: localModel) let remoteModel = AutoMLImageLabelerRemoteModel(name: "automl_remote_model") let optionsWithRemoteModel = AutoMLImageLabelerOptions(remoteModel: remoteModel)
Baru
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)
Berikut adalah beberapa contoh metode Objective-C lama dan yang baru:
Lama
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];
Baru
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];